rpkg
is an RPM packaging utility based on python-rpkg library. It works with both DistGit
and standard Git repositories and it handles two types of directory content: packed and unpacked:
There are currently two ways of handling those two different content types:
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.
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.
Generate source rpm ("srpm"):
$ rpkg srpm git_dir_pack: packing path /home/clime/rpkg-util git_dir_pack: Wrote: /tmp/rpkg/rpkg-util-1-q8ndilz4/rpkg-util-2.2.git.24.f032a4b.tar.gz Wrote: /tmp/rpkg/rpkg-util-1-q8ndilz4/rpkg-util.spec Wrote: /tmp/rpkg/rpkg-util-1-q8ndilz4/rpkg-util-2.2.git.24.f032a4b-1.fc28.src.rpm
Run %prep phase of an rpm build:
$ rpkg prep git_dir_pack: packing path /home/clime/rpkg-util git_dir_pack: Wrote: /tmp/rpkg/rpkg-util-2-yw2a9p57/rpkg-util-2.2.git.24.f032a4b.wtree.zm318p.tar.gz Wrote: /tmp/rpkg/rpkg-util-2-yw2a9p57/rpkg-util.spec Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.W3x7PT + umask 022 + cd /tmp/rpkg/rpkg-util-2-yw2a9p57 + cd /tmp/rpkg/rpkg-util-2-yw2a9p57 + rm -rf rpkg-util-2.2.git.24.f032a4b.wtree.zm318p + /usr/bin/gzip -dc /tmp/rpkg/rpkg-util-2-yw2a9p57/rpkg-util-2.2.git.24.f032a4b.wtree.zm318p.tar.gz + /usr/bin/tar -xof - + STATUS=0 + '[' 0 -ne 0 ']' + cd rpkg-util-2.2.git.24.f032a4b.wtree.zm318p + /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 build git_dir_pack: packing path /home/clime/rpkg-util git_dir_pack: Wrote: /tmp/rpkg/rpkg-util-3-zdqcfiu4/rpkg-util-2.2.git.24.f032a4b.wtree.zm3189.tar.gz Wrote: /tmp/rpkg/rpkg-util-3-zdqcfiu4/rpkg-util.spec Wrote: /tmp/rpkg/rpkg-util-3-zdqcfiu4/rpkg-util-2.2.git.24.f032a4b.wtree.zm3189-1.fc28.src.rpm Uploading package /tmp/rpkg/rpkg-util-3-zdqcfiu4/rpkg-util-2.2.git.24.f032a4b.wtree.zm3189-1.fc28.src.rpm 100% |################################| 131kB 383kB/s eta 0:00:00 Build was added to rpkg-util: https://copr.fedorainfracloud.org/coprs/build/783337/ Created builds: 783337
Other useful commands that you can use:
rpkg lint
to check the .spec file and the overall package conformance to RPM standardrpkg local
to locally build the package into an rpmrpkg upload
to upload a new source to DistGit lookaside cacherpkg ...
(see rpkg --help
or man rpkg
)Do not put sensitive data into directory with your sources, otherwise they might get published together with them.