Categorygithub.com/sassoftware/go-rpmutils
modulepackage
0.4.0
Repository: https://github.com/sassoftware/go-rpmutils.git
Documentation: pkg.go.dev

# README

Go RPM Utils

Go Reference

go-rpmutils is a library written in go for parsing and extracting content from RPMs.

Overview

go-rpmutils provides a few interfaces for handling RPM packages. There is a highlevel Rpm struct that provides access to the RPM header and CPIO payload. The CPIO payload can be extracted to a filesystem location via the ExpandPayload function or through a Reader interface, similar to the tar implementation in the go standard library.

Example

// Opening a RPM file
f, err := os.Open("foo.rpm")
if err != nil {
    panic(err)
}
rpm, err := rpmutils.ReadRpm(f)
if err != nil {
    panic(err)
}
// Getting metadata
nevra, err := rpm.Header.GetNEVRA()
if err != nil {
    panic(err)
}
fmt.Println(nevra)
provides, err := rpm.Header.GetStrings(rpmutils.PROVIDENAME)
if err != nil {
    panic(err)
}
fmt.Println("Provides:")
for _, p := range provides {
    fmt.Println(p)
}
// Extracting payload
if err := rpm.ExpandPayload("destdir"); err != nil {
    panic(err)
}

Validating Signatures

rpmutils supports validating PGP signatures embedded in RPM files.

import (
    "github.com/sassoftware/go-rpmutils"
    "github.com/ProtonMail/go-crypto/openpgp"
)

func main() {
    kf, err := os.Open("trusted.pgp")
    keyring, err := openpgp.ReadArmoredKeyRing(kf)
    f, err := os.Open("foo.rpm")
    hdr, sigs, err := rpmutils.Verify(f, keyring)
}

Passing nil as the keyring will parse the signature without validating it, so that the signers' key ID can be inspected.

By default rpmutils uses the ProtonMail PGP implementation, which supports PGP v4 and later signatures. PGP v4 was released in 1998, and yet some still-supported Linux distributions contain RPMs with v3 signatures.

Depending on your needs you may want to use the pgpkeys-eu soft fork, which re-adds v3 signature support. To consume it, the binary being built must have a replace directive, and must set the pgp3 tag to enable the related validation code in rpmutils:

go mod edit -replace github.com/ProtonMail/go-crypto=github.com/pgpkeys-eu/go-crypto@main
go build -tags pgp3

Upgrading from versions before v0.4.0

Previous versions of rpmutils used the standard library golang.org/x/crypto/openpgp implementation, which has been deprecated for some time. Most callers that are verifying or signing RPMs will just need to change imports to github.com/ProtonMail/go-crypto/openpgp .

There are two known regressions with the ProtonMail implementation. The first is that PGP v3 signatures are no longer supported. If this is important to you, then see the above note about using the pgpkeys-eu fork instead.

The second is that signing with a HSM-bound private key (crypto.Signer) of type other than RSA is currently not supported by ProtonMail. Hopefully a future release will restore this functionality.

Contributing

  1. Read contributor agreement
  2. Fork it
  3. Create your feature branch (git checkout -b my-new-feature)
  4. Commit your changes (git commit -a). Make sure to include a Signed-off-by line per the contributor agreement.
  5. Push to the branch (git push origin my-new-feature)
  6. Create new Pull Request

License

go-rpmutils is released under the Apache 2.0 license. See LICENSE.

# Packages

No description provided by the author
No description provided by the author

# Functions

GetFileAlgoName returns the name of a digest algorithm.
NEVRAcmp compares two RPM versions.
NewNoSuchTagError creates a NoSuchTagError for a given tag.
ReadHeader reads the signature and general headers from a RPM.
ReadRpm reads the header from a RPM file and prepares to read payload contents.
RewriteWithSignatures inserts raw signatures into a RPM header.
SignRpmFile signs infile and writes it to outpath, which may be the same file.
SignRpmStream reads an RPM and signs it, returning the set of headers updated with the new signature.
Vercmp compares two version strings using the same algorithm as rpm uses.
Verify the PGP signature over a RPM file.

# Constants

RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
BLINK*, FLINK*, and TRIGGERPREIN included from SUSE fork of RPM.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
AKA FILEMD5S.
bitmask: RPMFILE_* are bitmasks to interpret.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
bitmask: RPMVERIFY_* are bitmasks to interpret.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
Crypto algos.
Crypto algos.
Crypto algos.
Crypto algos.
Crypto algos.
Crypto algos.
Crypto algos.
Crypto algos.
Crypto algos.
Crypto algos.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
HAVAL-5-160.
MD2.
MD5.
RIPEMD160.
SHA1.
SHA224.
SHA256.
SHA384.
SHA512.
TIGER192.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
tag data types.
tag data types.
tag data types.
tag data types.
tag data types.
tag data types.
tag data types.
tag data types.
tag data types.
tag data types.
FILEFLAGS bitmask elements.
FILEFLAGS bitmask elements.
FILEFLAGS bitmask elements.
FILEFLAGS bitmask elements.
FILEFLAGS bitmask elements.
FILEFLAGS bitmask elements.
FILEFLAGS bitmask elements.
FILEFLAGS bitmask elements.
FILEFLAGS bitmask elements.
FILEFLAGS bitmask elements.
FILEFLAGS bitmask elements.
FILEFLAGS bitmask elements.
FILEFLAGS bitmask elements.
FILEFLAGS bitmask elements.
TRIGGERFLAGS bitmask elements -- not all rpmsenseFlags make sense in TRIGGERFLAGS.
TRIGGERFLAGS bitmask elements -- not all rpmsenseFlags make sense in TRIGGERFLAGS.
TRIGGERFLAGS bitmask elements -- not all rpmsenseFlags make sense in TRIGGERFLAGS.
TRIGGERFLAGS bitmask elements -- not all rpmsenseFlags make sense in TRIGGERFLAGS.
TRIGGERFLAGS bitmask elements -- not all rpmsenseFlags make sense in TRIGGERFLAGS.
TRIGGERFLAGS bitmask elements -- not all rpmsenseFlags make sense in TRIGGERFLAGS.
TRIGGERFLAGS bitmask elements -- not all rpmsenseFlags make sense in TRIGGERFLAGS.
TRIGGERFLAGS bitmask elements -- not all rpmsenseFlags make sense in TRIGGERFLAGS.
Header region tags.
Header region tags.
Header region tags.
FILEVERIFYFLAGS bitmask elements.
FILEVERIFYFLAGS bitmask elements.
FILEVERIFYFLAGS bitmask elements.
FILEVERIFYFLAGS bitmask elements.
FILEVERIFYFLAGS bitmask elements.
FILEVERIFYFLAGS bitmask elements.
FILEVERIFYFLAGS bitmask elements.
FILEVERIFYFLAGS bitmask elements.
FILEVERIFYFLAGS bitmask elements.
FILEVERIFYFLAGS bitmask elements.
FILEVERIFYFLAGS bitmask elements.
FILEVERIFYFLAGS bitmask elements.
RPM header tags found in the general header.
RPM header tags found in the signature header.
DSA signature over header only.
(same as SIG_PGP).
uncompressed payload bytes (uint64).
header + compressed payload (uint64).
MD5SUM of header + payload.
uncompressed payload bytes (uint32).
Signature over header + payload.
blank space that can be replaced by a signature.
RSA signature over header only.
SHA1 over header only (hex).
SHA256 over header only (hex).
Header + Payload size.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
bitmask: RPMSENSE_* are bitmasks to interpret.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.
RPM header tags found in the general header.

# Variables

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

HeaderRange indicates the byte offsets that the RPM header spans.
No description provided by the author
NEVRA holds the name, epoch, version, release and arch of the RPM, which uniquely identifies it.
NoSuchTagError is returned when a tag does not exist in the header.
Rpm is an open RPM header and payload.
RpmHeader holds the signature header and general header of a RPM Tags are drawn from both header areas, with IDs between _GENERAL_TAG_BASE and _SIGHEADER_TAG_BASE coming from the general header and all others coming from the signature header.
Signature describes a PGP signature found within a RPM while verifying it.
SignatureOptions describes additional configuration for SignRpm methods.

# Interfaces

FileInfo describes a file in the RPM payload.
PayloadReader is used to sequentially access the file contents of a RPM payload.

# Type aliases

NEVRASlice is used to sort a list of NEVRAs and implements sort.Interface.
VersionSlice provides the Sort interface for sorting version strings.