rpkg is an RPM packaging utility based on python-rpkg library.

It works with both DistGit and standard Git repositories.

It handles two types of directory content: packed and unpacked.

  • Packed (unexpanded) content is that composed of tarballs, patches, and a .spec file
  • Unpacked (expanded) content is that composed of plain source files and a .spec file

There are currently two ways of handling those two different content types:

  • spec templates
  • autopacking (deprecated)

Spec templates

Apart from being useful as a means to handle unpacked (as well as packed) content, they also make it possible to generate potentially large parts of your spec file automatically from a Git repository where your spec file is located.

An example spec template might look like this:

Name:       {{{ git_name }}}
Version:    {{{ git_version }}}
Release:    1%{?dist}
Summary:    This is a test package.

License:    GPLv2+

Source: {{{ git_pack }}}

This is a test package.

{{{ git_setup_macro }}}

{{{ git_changelog }}}

Having a spec template like this in your project (instead of just a plain spec file) allows your built source packages to automatically follow git history of your project.

Read more here.

Auto-packing (deprecated)

Auto-packing works only if auto_pack configuration option is set to True and only if the content you are working with is not packed (see rpkg is-packed).

When invoking rpkg srpm on an unpacked content, rpkg will download external sources (if any) and then it will generate a tarball from the whole content of the working directory named according to Source0 definition present in the associated .spec file. This tarball and the .spec file are then passed to rpmbuild to generate the resulting srpm.

More examples

Run %prep phase of an rpm build:

    $ rpkg prep
    git_pack: Source file already exists. No action taken.
    Wrote: /tmp/rpkg/rpkg-client.spec
    Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.4iFciz
    + umask 022
    + cd /tmp/rpkg/
    + cd /tmp/rpkg
    + rm -rf rpkg-client-1.0.git.122.e59a5b11
    + /usr/bin/gzip -dc /tmp/rpkg/rpkg-client-1.0.git.122.e59a5b11.tar.gz
    + /usr/bin/tar -xof -
    + STATUS=0
    + '[' 0 -ne 0 ']'
    + cd rpkg-client-1.0.git.122.e59a5b11
    + /usr/bin/chmod -Rf a+rX,u+w,g-w,o-w .
    + exit 0

For the following command, you need to have a project in COPR created. See quick tutorial here on how to do it.

    $ rpkg copr-build @releng/rpkg-client
    git_pack: Wrote: /tmp/rpkg/rpkg-client-1.0.git.122.e59a5b11.tar.gz
    Wrote: /tmp/rpkg/rpkg-client.spec
    Wrote: /tmp/rpkg/rpkg-client-1.0.git.122.e59a5b11-1.fc27.src.rpm
    Uploading package /tmp/rpkg/rpkg-client-1.0.git.122.e59a5b11-1.fc27.src.rpm
    100% |################################| 57kB 339kB/s eta 0:00:00
    Build was added to rpkg-client:
    Created builds: 724892
    Watching build(s): (this may be safely interrupted)
      15:50:12 Build 724892: importing ...

Other useful commands that you can use:

  • rpkg lint to check the .spec file and the overall package conformance to RPM standard
  • rpkg local to locally build the package into an rpm
  • rpkg copr-build to build an srpm and send it for build to COPR
  • rpkg ... (see rpkg --help or man rpkg)