https://github.com/arlac77/rpm-codec
rpm-codec is a streaming rpm packer, basically the rpm version of tar-stream
https://github.com/arlac77/rpm-codec
Last synced: 3 months ago
JSON representation
rpm-codec is a streaming rpm packer, basically the rpm version of tar-stream
- Host: GitHub
- URL: https://github.com/arlac77/rpm-codec
- Owner: arlac77
- License: mit
- Created: 2017-10-21T17:24:26.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2026-02-28T22:40:36.000Z (3 months ago)
- Last Synced: 2026-03-01T01:41:57.321Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 2.05 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://www.npmjs.com/package/rpm-codec)
[](https://spdx.org/licenses/0BSD.html)
[](https://bundlejs.com/?q=rpm-codec)
[](https://npmjs.org/package/rpm-codec)
[](https://github.com/arlac77/rpm-codec/issues)
[](https://actions-badge.atrox.dev/arlac77/rpm-codec/goto)
[](https://github.com/prettier/prettier)
[](http://commitizen.github.io/cz-cli/)
[](https://snyk.io/test/github/arlac77/rpm-codec)
# rpm-codec
Encode/decode rpm lead/header(s)
\== Which version of RPM is supported?
According to <> there are, well, three versions of rpm:
1. 'THE' rpm
2. rpm.org, a public effort starting around 2007 producing versions 4.8 to 4.10
3. 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 file format specification
RPM files are persisted in network byte order and consist of four parts.
# Lead
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
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.
# Header
Supported index types:
* NULL = 0
* CHAR = 1
* INT8 = 2
* INT16 = 3
* INT32 = 4
* INT64 = 5
* STRING = 6
* BIN = 7
* STRING\_ARRAY = 8
# Payload
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.
# API
### Table of Contents
* [RPMHeader](#rpmheader)
* [Properties](#properties)
* [RPMDecoder](#rpmdecoder)
* [Parameters](#parameters)
* [defaultEntryHandler](#defaultentryhandler)
* [Parameters](#parameters-1)
* [contentDecoder](#contentdecoder)
* [Parameters](#parameters-2)
* [TYPE\_NULL](#type_null)
* [TYPE\_STRING](#type_string)
* [TYPE\_STRING\_ARRAY](#type_string_array)
* [TYPE\_I18NSTRING](#type_i18nstring)
## RPMHeader
decoded rpm header
Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)
### Properties
* `lead` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
* `signature` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
* `header` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
## RPMDecoder
Decodes the rpm header.
### Parameters
* `stream` **[Stream](https://nodejs.org/api/stream.html)**
Returns **[RPMHeader](#rpmheader)**
## defaultEntryHandler
null handler simply skips content
### Parameters
* `header` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** file header
* `stream` **ReadStream**
* `callback` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)**
## contentDecoder
Decode the body part of an rpm stream
### Parameters
* `result` **[RPMHeader](#rpmheader)**
* `entryHandler` **EntryHandler** (optional, default `defaultEntryHandler`)
## TYPE\_NULL
Not Implemented
Type: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)
## TYPE\_STRING
variable, NUL terminated
Type: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)
## TYPE\_STRING\_ARRAY
Variable, sequence of NUL terminated strings
Type: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)
## TYPE\_I18NSTRING
Variable, sequence of NUL terminated strings
Type: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)
# Bibliography
\[bibliography]
* [wikipedia](http://en.wikipedia.org/wiki/RPM_Package_Manager)
RPM Package Manager
* *maxrpm* Edward C. Bailey. Maximum rpm. Red Hat Software, Inc. 1997.
* [LSB Linux Base RPM File Format](http://refspecs.linuxbase.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-generic/pkgformat.html)
* [cpio FreeBSD cpio (odc and newc) file format spec](http://people.freebsd.org/%7Ekientzle/libarchive/man/cpio.5.txt)
* [kernel Al Viro, H. Peter Anvin. initramfs buffer format. Linux Kernel. 2002](https://www.kernel.org/doc/Documentation/early-userspace/buffer-format.txt)