Golang implementation of parsing RPM packages
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
cpio
fileutil
testdata
.gitignore
ContributorAgreement.txt
LICENSE
README.md
errors.go
fileinfo.go
filesigs.go
header.go
log.go
log_test.go
nevra.go
payload.go
rpmutils.go
rpmutils_test.go
signatures.go
signatures_test.go
tags.go
uncompress.go
vercmp.go
verify.go
writeheader.go

README.md

Go RPM Utils

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

func main() {
    f, err := os.Open("foo.rpm")
    if err != nil {
        panic(err)
    }

    // Parse the rpm
    rpm := rpmutils.ReadRpm(f)

    // Get the name, epoch, version, release, and arch
    nevra, err := rpm.Header.GetNEVRA()
    if err != nil {
        panic(err)
    }

    fmt.Printf("%s\n", nevra)

    // Reading the provides header
    provides, err := rpm.Header.GetStrings(rpmutils.PROVIDENAME)
    if err != nil {
        panic(err)
    }

    fmt.Printf("Provides:\n")
    for _, p := range provides {
        fmt.Printf("%s", p)
    }
}

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.