rpkg 1.64 Release Notes

Released on January 27, 2022

Python compatibility

rpkg works with Python 2.7, 3.6, 3.9 and 3.10

What’s new in rpkg 1.64

Support building SRPMs in target mock

New arguments for building source RPMs are introduced:

  • x-pkg srpm --srpm-mock: Creates source RPM with ‘mock’ instead of ‘rpmbuild’

  • x-pkg mockbuild --srpm-mock: Generate source rpm with ‘mock’ and then run ‘mockbuild’ using this source rpm.

  • x-pkg build --srpm-mock: Use source rpm generated with mock for building.

  • x-pkg scratch-build --srpm-mock: same as above - but for scratch build.

It works for projects with single specfile.

Add support for mockbuild in lint command

Previously, the lint command assumed that linted srpm and binary rpms were in locations specified by the repository layout. However, the mockbuild command uses its own directory structure.

Support for mockbuild results linting is added here. As mockbuild is arguably even more important than local build, cases where both mockbuild and local build results are present, mockbuild results are selected.

Fix srpm and binary rpm lookup in lint subcommand

Subcommand lint was looking for srpm only in repository root, and for rpms only with globs of form %{ARCH}/*.rpm.

This works in many cases, but not when the config option ‘results_dir’ is set to ‘subdir’ or when (if ever) SRPMLayout is used. Fixed by using relevant layout parameters when looking for files to lint.

It is difficult to account for layout parameter ‘rpmfilename’ properly. In addition to a basename, that parameter can contain a path relative to ‘rpmdir’ and may contain rpm macros. Since macro evaluation is not possible in the ‘rpkg lint’ context, a simple heuristic is used instead, covering the known cases:

  1. only basename

  2. relative path ‘%{ARCH}’.

mockbuild: allow enforcing local mock config in fedpkg

The default automatic decision based on the (non-)existing local Mock configuration causes misleading user failures for Fedora EPEL 8:

  1. The new mock-core-configs package dropped the ‘epel-8-*’ configs.

  2. We fallback to downloading epel-8* configs from Kojihub, but this is useless because the Mock configuration in Koji uses some Koji-private RHEL repourls that can not be used to download packages on users’ machines.

  3. That causes 403 repo download errors; hiding the default Mock’s error message for absent epel-8 configuration.

For Fedora packages, we can actually afford defaulting to Mock’s configuration, _always_. For other packagers (e.g. RHEL) we probably can not because the related Mock config files aren’t normally installed with mock-core-configs (so while the local config is still preferred, we usually have to fall-back to the downloaded config).

So this commit provides a new protected method Commands.use_local_mock_config() that can be safely overridden in Fedpkg which will default to “local config”. While the other pyrpkg clones may keep the _default_ detection mechanism (== do nothing), or override the method as well.

While on it, two new options are added, --use-koji-mock-config and --use-local-mock-config that can be used to override the default specified by any pyrpkg fork.

By default, with both patched pyrpkg and fedpkg, mock’s help output is printed out:

$ fedpkg mockbuild
...
ERROR: Could not find required config file: /etc/mock/epel-8-x86_64.cfg
ERROR: There are those alternatives:
...

Support for custom completers

python-argcomplete library supports custom completers, but their assigning to arguments should be done before rpkg initialization. This commit introduces mechanism how to pass specific completers for rhpkg/fedpkg to rpkg.

Use unittest.mock on Python 3

Migrated from library python-mock to unittest.mock as per the guide. It allows building package for epel9 in future.

lint can run with different rpmlint versions

lint subcommand internally executes ‘rpmlint’ binary. With ‘rpmlint’ package version 2.x it changed some of its input arguments.

Rpkg has to recognize the installed ‘rpmlint’ version and use the corresponding switch/argument. Specifically, ‘-f’ switch for user config file has changed to ‘-r’ in the newer version.

Additionally, fixes some paths to source RPMs.

Continue execution if specfile parsing fails

The unused sources detection feature implemented by class SpecFile is simply an optimization to avoid downloading unused sources. The parsing is quite different from other steps performed by rpkg, which also meant it can fail in new ways.

To avoid situations where an error in this optimization step prevents usage that would otherwise succeed, this commit changes handling of such errors from exiting to logging the situation and continuing with the assumption that all sources in the sources file may be needed.

Consider Patch tags in specfile parser

Patch files can be uploaded to the lookaside cache and referred to by Patch tags in the specfile. The specfile parser did not consider this case, leading to an error if a dist-git repo has such confirmation.

Fixed by parsing the patch tags.

Pass sourcedir to rpmspec when specfile is parsed

In many cases, specfile parsing in class SpecFile failed when the specfile contained local sources like ‘Source2: local.txt’. This happened because rpm sourcedir configuration was not passed to utility rpmspec used for parsing, leading it to default to ‘~/rpmbuild/SOURCES’, which is not correct for many layouts supported by rpkg.

Fixed by passing sourcedir correctly.

Improve how the .spec file is selected

Fix the problem that fedpkg local in a clone of package X could use a.spec instead of X.spec. Prefer the spec file that matches the directory name, and issue a warning if there is any doubt.

list-side-tags - fix unavailable username

On rpmfusion, result of list-side-tags doesn’t bring username neither user id, so it results in KeyError. Use a default value instead.

Include fmf config in the list of reserved files

Do not remove fmf files during fedpkg import as these are configuration files used for enabling tmt tests. See the Fedora CI docs for details.

Accept also ~/.config/mock/<chroot>.cfg files

This has been originally reported by Maxwell G in Fedora mailing list.

During building from SRPM --path parameter is taken into account

Fixes fail during x-pkg --path build --srpm --scratch command execution.

The SRPM was correctly created but x-pkg was unable to locate it when uploading to Koji.

Other small fixes

  • improve x-pkg srpm --help description - Update the text to explain what the command does. Explain how to add new files to each SRPM.

  • Support for Python 3.10 and support for running tests there

  • Fixes import fail with sources already imported

  • Correct formatting in previous documentation pages

  • Fix unittests to be Python 2 compatible

  • Fix flake8 syntax

Change Logs

  • Fix: x-pkg now takes into account –path parameter while building SRPM - #580 (drumian)

  • ‘lint’ can run with different ‘rpmlint’ versions - rhbz#1967821 (onosek)

  • Support building SRPMs in target mock - #495 (onosek)

  • Use unittest.mock on Python 3 rhbz#2029012 (miro)

  • Add support for mockbuild in lint command (oturpe)

  • Fix srpm and binary rpm lookup in lint subcommand - #586 (oturpe)

  • mockbuild: allow enforcing local mock config in fedpkg - #461 (praiskup)

  • list-side-tags - fix unavailable username - #554 (sergio)

  • Accept also ~/.config/mock/<chroot>.cfg files (praiskup)

  • improve srpm –help description (kdreyer)

  • Improve how the .spec file is selected (mads)

  • Include fmf config in the list of reserved files - #452 (psplicha)

  • Fix flake8 syntax (onosek)

  • Continue execution if specfile parsing fails - #583 (oturpe)

  • Consider Patch tags in specfile parser - rhbz#2010518 (oturpe)

  • Support for custom completers (onosek)

  • Fixes import fail with sources already imported - #573 (drumian)

  • Also document Python 3.10 support in the README (miro)

  • Test and support Python 3.10 (miro)

  • Print SpecFile parsing debug info - rhbz#2000556 (onosek)

  • Pass sourcedir to rpmspec when specfile is parsed - #559 (oturpe)

  • Fix unittests to be Python 2 compatible (drumian)

  • Changing escaping of dash in docs - older releases (onosek)

  • Changing escaping of dash in docs. (drumian)