RPM Specs

Overview

A RPM file consists of the lead, a RPM signature and a RPM header followed by a CPIO archive.

The lead is not used any more. All informations are obsolete or are duplicated in the RPM signature and RPM header. But the lead is used to recognize rpm files with the file command. See here to find out how the lead is organized.

The RPM signature and RPM header share the same datastructure. They consist of a header, a number of indexes and a store.

The header contains the number of indexes that follow the header and the size of the store.

Every index describes a bit of data stored in the store. It consist of a tag (see signature tags and header tags), a data type, an offset in the store and a count, describing the number of items stored as the described data type.

Allowed data types are:

typecount description
NULLNumber of nulls in the data field
CHARNumber of chars in the data field
INT8Number of int8 in the data field
INT16Number of int16 in the data field
INT32Number of int32 in the data field
INT64Number of int64 in the data field
STRINGThere can be only one string per entry. The String is terminated by a \0 character
BINNumber of bytes in the data field (as an binary array)
STRING_ARRAYNumber of strings in the data field. All strings are terminated with a \0 character
I18NSTRINGA string array that contains several entries in different locales. Every entry correspond with a locale defined at the same position as in the tag HEADERI18NTABLES in the RPM header

Dataspecs

RPM Lead

   unsigned char magic[4];     (4  byte)  (ed ab ee db)
   unsigned char major, minor; (1  byte each)
   short type;                 (2  byte)
   short archnum;              (2  byte)
   char name[66];              (66 byte)
   short osnum;                (2  byte)
   short signature_type;       (2  byte)
   char reserved[16];          (16 byte)
                               =96 byte
         

Header

   unsigned char magic[3];     (3  byte)  (8e ad e8)
   unsigned char version;      (1  byte)
   char reserved[4];           (4  byte)
   int num_index;              (4  byte)
   int num_data;               (4  byte)
                               =16 byte
         

Index

   int tag;                    (4  byte)
   int type;                   (4  byte)
   int offset;                 (4  byte)
   int count;                  (4  byte)
                               =16 byte
         

RPM Signature

( HEADER )
[ INDEX * HEADER.num_data ]
[ DATA (num_data bytes) ]
( as many empty bytes as required so that total size % 8 != 0 )

Allowed tags

TAG-NameTAG-ID
HEADERSIGNATURES62
BADSHA1_1264
BADSHA1_2265
DSA267
RSA268
SHA1269
SIZE1000
LEMD5_11001
PGP1002
LEMD5_21003
MD51004
GPG1005
PGP51006
PAYLOADSIZE1007

RPM Header

( HEADER )
[ INDEX * HEADER.num_data ]
[ DATA (num_data bytes) ]

Allowed tags

TAG-NameTAG-ID
HEADERIMAGE61
HEADERSIGNATURES62
HEADERIMMUTABLE63
HEADERREGIONS64
HEADERI18NTABLE100
SIG_BASE256
SIGSIZE257
SIGLEMD5_1258
SIGPGP259
SIGLEMD5_2260
SIGMD5261
SIGGPG262
SIGPGP5263
BADSHA1_1264
BADSHA1_2265
PUBKEYS266
DSAHEADER267
RSAHEADER268
SHA1HEADER269
NAME1000
VERSION1001
RELEASE1002
SERIAL1003
SUMMARY1004
DESCRIPTION1005
BUILDTIME1006
BUILDHOST1007
INSTALLTIME1008
SIZE1009
DISTRIBUTION1010
VENDOR1011
GIF1012
XPM1013
COPYRIGHT1014
PACKAGER1015
GROUP1016
CHANGELOG1017
SOURCE1018
PATCH1019
URL1020
OS1021
ARCH1022
PREIN1023
POSTIN1024
PREUN1025
POSTUN1026
FILENAMES1027
FILESIZES1028
FILESTATES1029
FILEMODES1030
FILEUIDS1031
FILEGIDS1032
FILERDEVS1033
FILEMTIMES1034
FILEMD5S1035
FILELINKTOS1036
FILEFLAGS1037
ROOT1038
FILEUSERNAME1039
FILEGROUPNAME1040
EXCLUDE1041
EXCLUSIVE1042
ICON1043
SOURCERPM1044
FILEVERIFYFLAGS1045
ARCHIVESIZE1046
PROVIDES1047
REQUIREFLAGS1048
REQUIRENAME1049
REQUIREVERSION1050
NOSOURCE1051
NOPATCH1052
CONFLICTFLAGS1053
CONFLICTNAME1054
CONFLICTVERSION1055
DEFAULTPREFIX1056
BUILDROOT1057
INSTALLPREFIX1058
EXCLUDEARCH1059
EXCLUDEOS1060
EXCLUSIVEARCH1061
EXCLUSIVEOS1062
AUTOREQPROV1063
RPMVERSION1064
TRIGGERSCRIPT1065
TRIGGERNAME1066
TRIGGERVERSION1067
TRIGGERFLAGS1068
TRIGGERINDEX1069
VERIFYSCRIPT1079
CHANGELOGTIME1080
CHANGELOGNAME1081
CHANGELOGTEXT1082
BROKENMD51083
PREREQ1084
PREINPROG1085
POSTINPROG1086
PREUNPROG1087
POSTUNPROG1088
BUILDARCHS1089
OBSOLETENAME1090
VERIFYSCRIPTPROG1091
TRIGGERSCRIPTPROG1092
DOCDIR1093
COOKIE1094
FILEDEVICES1095
FILEINODES1096
FILELANGS1097
PREFIXES1098
INSTPREFIXES1099
TRIGGERIN1100
TRIGGERUN1101
TRIGGERPOSTUN1102
AUTOREQ1103
AUTOPROV1104
CAPABILITY1105
SOURCEPACKAGE1106
OLDORIGFILENAMES1107
BUILDPREREQ1108
BUILDREQUIRES1109
BUILDCONFLICTS1110
BUILDMACROS1111
PROVIDEFLAGS1112
PROVIDEVERSION1113
OBSOLETEFLAGS1114
OBSOLETEVERSION1115
DIRINDEXES1116
BASENAMES1117
DIRNAMES1118
ORIGDIRINDEXES1119
ORIGBASENAMES1120
ORIGDIRNAMES1121
OPTFLAGS1122
DISTURL1123
PAYLOADFORMAT1124
PAYLOADCOMPRESSOR1125
PAYLOADFLAGS1126
INSTALLCOLOR1127
INSTALLTID1128
REMOVETID1129
SHA1RHN1130
RHNPLATFORM1131
PLATFORM1132
PATCHESNAME1133
PATCHESFLAGS1134
PATCHESVERSION1135
CACHECTIME1136
CACHEPKGPATH1137
CACHEPKGSIZE1138
CACHEPKGMTIME1139
FILECOLORS1140
FILECLASS1141
CLASSDICT1142
FILEDEPENDSX1143
FILEDEPENDSN1144
DEPENDSDICT1145
SOURCEPKGID1146

Reference

For further informations on rpm see www.rpm.org. You can find there the book Maximum RPM and the source for rpm.