Encode/decode rpm lead/header(s)
== Which version of RPM is supported?
According to <> there are, well, three versions of rpm:
- 'THE' rpm
- rpm.org, a public effort starting around 2007 producing versions 4.8 to 4.10
- rpm v5 creating version 5
The first rpm i got my hand on was 4.4, so for now the one and only implementation is 4.4. Do not expect any newer features such as compression other than gzip (lzma, xz, ...).
RPM files are persisted in network byte order and consist of four parts.
Our lead looks like this:
magic (0-3):: Magic value for both 'file' and rpm utilities ('ED AB EE DB')
major (4):: RPM Major version ('03')
minor (5):: RPM minor version ('00')
type (6-9):: Type binary ('00 00 00 00'). Type source ('00 00 00 01') not supported yet.
deprecated (10-95):: The rest is not used any more because its format is inflexible. Content is superseded by the header. It's only use is to support non-rpm utilities such as 'file' that can identify rpms based on a magic value. (85 times '00')
Signature format is equal to header format. This lib does not support checksums because the order of the checksum field would require the complete rpm structure to be processed before streaming could continue.
Supported index types:
- NULL = 0
- CHAR = 1
- INT8 = 2
- INT16 = 3
- INT32 = 4
- INT64 = 5
- STRING = 6
- BIN = 7
- STRING_ARRAY = 8
A gzip,xz compressed cpio structure carries the rpm payload. Other compressions algorithms exist, and are supported by newer versions of 'rpm', but for now it's gzip.
- RPMHeader
- RPMDecoder
- defaultEntryHandler
- contentDecoder
- TYPE_NULL
- TYPE_STRING
- TYPE_STRING_ARRAY
- TYPE_I18NSTRING
decoded rpm header
Type: Object
Decodes the rpm header.
stream
Stream
Returns RPMHeader
null handler simply skips content
Decode the body part of an rpm stream
result
RPMHeaderentryHandler
EntryHandler (optional, defaultdefaultEntryHandler
)
Not Implemented
Type: number
variable, NUL terminated
Type: number
Variable, sequence of NUL terminated strings
Type: number
Variable, sequence of NUL terminated strings
Type: number
[bibliography]
- wikipedia RPM Package Manager
- maxrpm Edward C. Bailey. Maximum rpm. Red Hat Software, Inc. 1997.
- LSB Linux Base RPM File Format
- cpio FreeBSD cpio (odc and newc) file format spec
- kernel Al Viro, H. Peter Anvin. initramfs buffer format. Linux Kernel. 2002