README.md

This project provides rpkg command-line tool. It is an rpm packaging utility that works with both DistGit and standard Git repositories and 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

Note: This project is a continuation of rpkg command-line script that used to be provided by python-rpkg package. The project is called rpkg-util (and not just rpkg) not to conflict in name with the python rpkg library that this project used to employ.

Spec templates

Apart from being useful as a means to handle unpacked (as well as packed) content, they also make it possible to generate certain 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_dir_name }}}
Version:    {{{ git_dir_version }}}
Release:    1%{?dist}
Summary:    This is a test package.

License:    GPLv2+
URL:        https://someurl.org
VCS:        {{{ git_dir_vcs }}}

Source:     {{{ git_dir_pack }}}

%description
This is a test package.

%prep
{{{ git_dir_setup_macro }}}

%changelog
{{{ git_dir_changelog }}}

Having a spec template like this in your project (instead of just a plain spec file) allows you to build rpm packages that automatically follow git history of your project. Read more here. If you just want to quickly start a new project with rpkg, go here. And if you are completely new to .spec files, you can find out a little bit more here.

Examples

Generate source rpm ("srpm"):

    $ rpkg srpm
    git_dir_pack: archiving /home/clime/rpkg-util:
    commit 77117acfc089de7eab46baa0308f46413e71b431 (HEAD -> master, tag: rpkg-util-3.beta-1)
    Author: clime <clime@fedoraproject.org>
    Date:   Fri Apr 30 18:22:21 2021 +0200

        mark beta version
    git_dir_pack: Wrote: /tmp/rpkg/rpkg-util-1-9dnhco7d/rpkg-util-77117acf.tar.gz
    Wrote: /tmp/rpkg/rpkg-util-1-9dnhco7d/rpkg-util.spec
    setting SOURCE_DATE_EPOCH=1619740800
    Wrote: /tmp/rpkg/rpkg-util-1-9dnhco7d/rpkg-util-3.beta-1.fc31.src.rpm

Run %prep phase of an rpm build:

    $ rpkg prep
    git_dir_pack: archiving /home/clime/rpkg-util:
    commit 77117acfc089de7eab46baa0308f46413e71b431 (HEAD -> master, tag: rpkg-util-3.beta-1)
    Author: clime <clime@fedoraproject.org>
    Date:   Fri Apr 30 18:22:21 2021 +0200

        mark beta version
    git_dir_pack: Wrote: /tmp/rpkg/rpkg-util-2-ts2unr3s/rpkg-util-77117acf.tar.gz
    Wrote: /tmp/rpkg/rpkg-util-2-ts2unr3s/rpkg-util.spec
    setting SOURCE_DATE_EPOCH=1619740800
    Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.NaPmFp
    + umask 022
    + cd /tmp/rpkg/rpkg-util-2-ts2unr3s
    + cd /tmp/rpkg/rpkg-util-2-ts2unr3s
    + rm -rf rpkg-util
    + /usr/bin/gzip -dc /tmp/rpkg/rpkg-util-2-ts2unr3s/rpkg-util-77117acf.tar.gz
    + /usr/bin/tar -xof -
    + STATUS=0
    + '[' 0 -ne 0 ']'
    + cd rpkg-util
    + /usr/bin/chmod -Rf a+rX,u+w,g-w,o-w .
    + RPM_EC=0
    ++ jobs -p
    + 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 build
    git_dir_pack: archiving /home/clime/rpkg-util:
    commit 77117acfc089de7eab46baa0308f46413e71b431 (HEAD -> master, tag: rpkg-util-3.beta-1)
    Author: clime <clime@fedoraproject.org>
    Date:   Fri Apr 30 18:22:21 2021 +0200

        mark beta version
    git_dir_pack: Wrote: /tmp/rpkg/rpkg-util-3-793uxgm5/rpkg-util-77117acf.tar.gz
    Wrote: /tmp/rpkg/rpkg-util-3-793uxgm5/rpkg-util.spec
    setting SOURCE_DATE_EPOCH=1619740800
    Wrote: /tmp/rpkg/rpkg-util-3-793uxgm5/rpkg-util-3.beta-1.fc31.src.rpm
    Uploading package /tmp/rpkg/rpkg-util-3-793uxgm5/rpkg-util-3.beta-1.fc31.src.rpm
     |################################| 204.8 kB 266.8 kB/s eta 0:00:00Build was added to rpkg-util:
      https://copr.fedorainfracloud.org/coprs/build/2157665
    Created builds: 2157665

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 upload to upload a new source to DistGit lookaside cache
  • rpkg ... (see rpkg --help or man rpkg)

Warning

Do not put sensitive data into directory with your sources, otherwise they might get published together with them.

Credits