Jun's Blog

Output, activities, memo and etc.

Fedora: setup packager tools

Install packager tools to do packaging on Fedora, seeing https://docs.fedoraproject.org/en-US/package-maintainers/Installing_Packager_Tools/.

Install the following packages.

$ sudo dnf install fedora-packager fedora-review

SSH keys

The type "ed25519" is accepted. See https://junaruga.hatenablog.com/entry/2021/04/08/054156. After setting the public key on https://accounts.fedoraproject.org/ , you need to wait for a hour for the public key setting to be actually set on the necessary servers in my experience.

Then you can download the RPM spec file (packaging recipe file).

$ fedpkg co hello
Cloning into 'hello'...
remote: Enumerating objects: 120, done.
remote: Counting objects: 100% (120/120), done.
remote: Compressing objects: 100% (76/76), done.
remote: Total 120 (delta 51), reused 81 (delta 34), pack-reused 0
Receiving objects: 100% (120/120), 13.69 KiB | 4.56 MiB/s, done.
Resolving deltas: 100% (51/51), done.

The default branch is "rawhide".

$ cd hello

$ git branch
* rawhide

$ vi hello.spec

Mock

Here is the initial setting to use the mock command to build RPM package on a chroot environment.

$ sudo usermod -a -G mock jaruga
$ pwd
/home/jaruga/fed/hello

$ fedpkg srpm
Downloading gnu-keyring.gpg
######################################################################## 100.0%
Downloading hello-2.10.tar.gz
######################################################################## 100.0%

setting SOURCE_DATE_EPOCH=1642636800
Wrote: /home/jaruga/var/pkg/fed/hello/hello-2.10-7.fc37.src.rpm

Build the SRPM file.

$ mock hello-2.10-7.fc37.src.rpm
...
+ exit 0
Finish: rpmbuild hello-2.10-7.fc37.src.rpm
Finish: build phase for hello-2.10-7.fc37.src.rpm
INFO: Done(hello-2.10-7.fc37.src.rpm) Config(default) 3 minutes 36 seconds
INFO: Results and/or logs in: /var/lib/mock/fedora-35-x86_64/result
Finish: run

The config file specified by mock is in /etc/mock/*.cfg. And the default config file used without mock -r CONFIG option is the fedora-35.

$ ls -l /etc/mock/default.cfg
lrwxrwxrwx. 1 root root 20 Dec 28 00:54 /etc/mock/default.cfg -> fedora-35-x86_64.cfg

But practically better to change like this. I much more often have built on the rawhide.

$ sudo rm default.cfg
$ sudo ln -s fedora-rawhide-x86_64.cfg default.cfg
$ sudo ln -s fedora-35-x86_64.cfg f35.cfg
$ ls -l default.cfg f35.cfg
lrwxrwxrwx. 1 root root 25 Feb 13 01:04 default.cfg -> fedora-rawhide-x86_64.cfg
lrwxrwxrwx. 1 root root 20 Feb 13 01:04 f35.cfg -> fedora-35-x86_64.cfg

Then I see the "Error: GPG check FAILED". Fix it later.

$ mock hello-2.10-7.fc37.src.rpm
...
 GPG Keys are configured as: file:///usr/share/distribution-gpg-keys/fedora/RPM-GPG-KEY-fedora-36-primary, file:///usr/share/distribution-gpg-keys/fedora/RPM-GPG-KEY-fedora-36-primary, file:///usr/share/distribution-gpg-keys/fedora/RPM-GPG-KEY-fedora-35-primary
Error: GPG check FAILED

Seeing /etc/mock/templates/fedora-rawhide.tpl called in /etc/mock/fedora-rawhide-x86_64.cfg, the gpgcheck is enabled as gpgcheck=1. I checked the setting from the mock command like this.

$ mock --debug-config | grep gpgcheck
INFO: mock.py version 2.15 starting (python version = 3.10.2, NVR = mock-2.15-1.fc35)...
Start(bootstrap): init plugins
INFO: selinux enabled
Finish(bootstrap): init plugins
Start: init plugins
INFO: selinux enabled
Finish: init plugins
INFO: Signal handler active
Start: run
 'gpgcheck=0\n'
 'gpgcheck=1\n'
 'gpgcheck=1\n'
 'gpgcheck=1\n'
 'gpgcheck=1\n'
 'gpgcheck=1\n'
 'gpgcheck=1\n'

As a temporary workflow, disable gpgcheck, but I didn't want to edit the /etc/mock/templates/fedora-rawhide.tpl file to always use the latest updated file. So, I set the following user defined config file. The file is actually Python file.

$ cat ~/.config/mock.cfg
# vim: set syntax=python:

# Disable gpgcheck in `/etc/mock/templates/fedora-rawhide.tpl`.
config_opts['dnf.conf'] = config_opts['dnf.conf'].replace('gpgcheck=1', 'gpgcheck=0')

I can see all the gpgcheck settings are disabled.

$ mock --debug-config | grep gpgcheck
INFO: mock.py version 2.15 starting (python version = 3.10.2, NVR = mock-2.15-1.fc35)...
Start(bootstrap): init plugins
INFO: selinux enabled
Finish(bootstrap): init plugins
Start: init plugins
INFO: selinux enabled
Finish: init plugins
INFO: Signal handler active
Start: run
 'gpgcheck=0\n'
 'gpgcheck=0\n'
 'gpgcheck=0\n'
 'gpgcheck=0\n'
 'gpgcheck=0\n'
 'gpgcheck=0\n'
 'gpgcheck=0\n'
Finish: run

Building on mock is succeeded.

$ mock hello-2.10-7.fc37.src.rpm
...
+ exit 0
Finish: rpmbuild hello-2.10-7.fc37.src.rpm
Finish: build phase for hello-2.10-7.fc37.src.rpm
INFO: Done(hello-2.10-7.fc37.src.rpm) Config(default) 0 minutes 26 seconds
INFO: Results and/or logs in: /var/lib/mock/fedora-rawhide-x86_64/result
Finish: run