How to build RPM packages using Fedora packaging tools

How to build RPM packages using Fedora packaging tools

fedora_rpm_packaging

Here in this article we will see how we can build RPM packages using the Fedora packaging tools. We will be trying to setup a workstation with all the required packages installed and try to build a RPM package locally and also on the Fedora build system (ie. koji).

Test Environment

Fedora 38 Workstation

What is Pagure

Pagure is a Open source source code management and issue tracking application which is primarily used by Fedora for hosting its package source code.

What is Koji

Koji is the primary build system used by Fedora to build the RPM packages that are going to used in the Fedora OS further.

If you are interested in watching the video. Here is the YouTube video on the same step by step procedure outlined below.

Procedure

Step1: Create a FAS Account and Configure SSH key

As a first step in order to contribute to Fedora or use the Fedora systems you will need to get your FAS account created. Please Register for getting your FAS account created.

Once you have registered with Fedora, you need to generate SSH keypair on your system as shown below.

Create SSH keypair

[admin@fedcon ~]$ ssh-keygen 
Generating public/private rsa key pair.
Enter file in which to save the key (/home/admin/.ssh/id_rsa): 
Created directory '/home/admin/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/admin/.ssh/id_rsa
Your public key has been saved in /home/admin/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:mAR8MmgN8oLOw37nCwIXajELGoaeSjRJV0Q5QDGzQKE admin@fedcon.stack.com
The key's randomart image is:
+---[RSA 3072]----+
|o=+%B+.          |
|=o* O+.          |
|EOo. +o          |
|X+*. . o         |
|+@.   o S        |
|*..              |
|.o o .           |
|  o +            |
|     o.          |
+----[SHA256]-----+

Once the keypair is generated you need to configure SSH and GPG keys for your user profile by copying the SSH public key as shown below.

Step2: Create a Redhat Bugzilla Account

You can login with the FAS account into Redhat Bugzilla. But you still need to register your email address in order to get an account with Redhat Bugzilla which is used as Bug Reporting tool for any package.

Step3: Install and Configure Git

In this step we are going to install Git, which is a required tool in order for your to work with Pagure or Gitlab version control system which are primarily used by Fedora to Host the source code from which RPM packages are built.

[admin@fedcon ~]$ sudo dnf install git-all
...
Installed:
  cvs-1.11.23-63.fc38.x86_64                                cvsps-2.2-0.32.b1.fc38.x86_64                             git-all-2.41.0-1.fc38.noarch                           
  git-credential-libsecret-2.41.0-1.fc38.x86_64             git-cvs-2.41.0-1.fc38.noarch                              git-daemon-2.41.0-1.fc38.x86_64                        
  git-email-2.41.0-1.fc38.noarch                            git-gui-2.41.0-1.fc38.noarch                              git-instaweb-2.41.0-1.fc38.noarch                      
  git-p4-2.41.0-1.fc38.noarch                               git-subtree-2.41.0-1.fc38.noarch                          git-svn-2.41.0-1.fc38.noarch                           
  gitk-2.41.0-1.fc38.noarch                                 gitweb-2.41.0-1.fc38.noarch                               libserf-1.3.9-27.fc38.x86_64                           
  lighttpd-1.4.71-1.fc38.x86_64                             lighttpd-filesystem-1.4.71-1.fc38.noarch                  lighttpd-mod_authn_ldap-1.4.71-1.fc38.x86_64           
  lighttpd-mod_deflate-1.4.71-1.fc38.x86_64                 lighttpd-mod_magnet-1.4.71-1.fc38.x86_64                  lighttpd-mod_openssl-1.4.71-1.fc38.x86_64              
  lighttpd-mod_vhostdb_ldap-1.4.71-1.fc38.x86_64            lighttpd-mod_webdav-1.4.71-1.fc38.x86_64                  perl-Authen-SASL-2.16-29.fc38.noarch                   
  perl-CGI-4.57-1.fc38.noarch                               perl-Clone-0.46-2.fc38.x86_64                             perl-Compress-Raw-Bzip2-2.204-2.fc38.x86_64            
  perl-Compress-Raw-Zlib-2.204-2.fc38.x86_64                perl-DBD-SQLite-1.72-2.fc38.x86_64                        perl-DBI-1.643-15.fc38.x86_64                          
  perl-Digest-HMAC-1.04-7.fc38.noarch                       perl-Digest-SHA-1:6.04-1.fc38.x86_64                      perl-Email-Valid-1.203-1.fc38.noarch                   
  perl-Encode-Locale-1.05-26.fc38.noarch                    perl-File-Slurper-0.014-2.fc38.noarch                     perl-GSSAPI-0.28-41.fc38.x86_64                        
  perl-Git-SVN-2.41.0-1.fc38.noarch                         perl-HTML-Parser-3.81-1.fc38.x86_64                       perl-HTML-Tagset-3.20-53.fc38.noarch                   
  perl-HTTP-Date-6.05-12.fc38.noarch                        perl-HTTP-Message-6.44-2.fc38.noarch                      perl-I18N-Langinfo-0.21-497.fc38.x86_64                
  perl-IO-Compress-2.204-1.fc38.noarch                      perl-IO-Compress-Brotli-0.004001-7.fc38.x86_64            perl-IO-HTML-1.004-10.fc38.noarch                      
  perl-LWP-MediaTypes-6.04-14.fc38.noarch                   perl-MailTools-2.21-13.fc38.noarch                        perl-Math-BigInt-1:1.9998.37-3.fc38.noarch             
  perl-Math-BigRat-0.2624-3.fc38.noarch                     perl-Math-Complex-1.59-497.fc38.noarch                    perl-Memoize-1.03-497.fc38.noarch                      
  perl-Net-SMTP-SSL-1.04-20.fc38.noarch                     perl-PerlIO-utf8_strict-0.010-2.fc38.x86_64               perl-Sys-Hostname-1.24-497.fc38.x86_64                 
  perl-Term-ReadLine-1.17-497.fc38.noarch                   perl-Tie-4.6-497.fc38.noarch                              perl-Time-HiRes-4:1.9770-490.fc38.x86_64               
  perl-TimeDate-1:2.33-10.fc38.noarch                       perl-YAML-1.30-14.fc38.noarch                             perl-filetest-1.03-497.fc38.noarch                     
  subversion-1.14.2-13.fc38.x86_64                          subversion-libs-1.14.2-13.fc38.x86_64                     subversion-perl-1.14.2-13.fc38.x86_64                  
  tk-1:8.6.12-4.fc38.x86_64                                 utf8proc-2.7.0-4.fc38.x86_64                             

Complete!

Configure Git if you would like to contribute to the Fedora ecosystem of packages.

[admin@fedcon ~]$ git config --global user.name "novicejava1"
[admin@fedcon ~]$ git config --global user.email "sudhirbhoga@gmail.com"
[admin@fedcon ~]$ git config --global core.editor vim
[admin@fedcon ~]$ git config --global init.defaultBranch main

Step4: Install Fedora Packaging Tools

Here in this step we are going to install two important packages. They are fedora-packager and fedora-review packages. fedora-packager consist of a set of utilities useful for a fedora packager in setting up their environment. fedora-review does a lot of work behind the scenes. Here are the details.

* Downloading SRPM & SPEC.
* Download upstream source
* Check md5sums
* Build and install package in mock.
* Run rpmlint.
* Generate a review template, which becomes the starting
  point for the review work.
[admin@fedcon ~]$ sudo dnf install fedora-packager fedora-review
...
Installed:
  ansible-srpm-macros-1-10.fc38.noarch                 binutils-2.39-9.fc38.x86_64                         binutils-gold-2.39-9.fc38.x86_64                                 
  bodhi-client-7.2.0-1.fc38.noarch                     createrepo_c-0.21.1-1.fc38.x86_64                   createrepo_c-libs-0.21.1-1.fc38.x86_64                           
  dash-0.5.11.5-3.fc38.x86_64                          debugedit-5.0-7.fc38.x86_64                         devscripts-checkbashisms-2.23.0-1.fc38.x86_64                    
  dnf-utils-4.4.1-1.fc38.noarch                        drpm-0.5.2-1.fc38.x86_64                            dwz-0.15-2.fc38.x86_64                                           
  ed-1.19-2.fc38.x86_64                                efi-srpm-macros-5-7.fc38.noarch                     fakeroot-1.31-1.fc38.x86_64                                      
  fakeroot-libs-1.31-1.fc38.x86_64                     fedora-packager-0.6.0.7-3.fc38.noarch               fedora-packager-kerberos-0.6.0.7-3.fc38.noarch                   
  fedora-review-0.9.0-2.fc38.noarch                    fedpkg-1.44-4.fc38.noarch                           fonts-srpm-macros-1:2.0.5-11.fc38.noarch                         
  fpc-srpm-macros-1.3-7.fc38.noarch                    ghc-srpm-macros-1.6.1-1.fc38.noarch                 gnat-srpm-macros-6-2.fc38.noarch                                 
  go-srpm-macros-3.2.0-2.fc38.noarch                   http-parser-2.9.4-8.fc38.x86_64                     kernel-srpm-macros-1.0-19.fc38.noarch                            
  koji-1.33.0-1.fc38.noarch                            krb5-pkinit-1.20.1-8.fc38.x86_64                    krb5-workstation-1.20.1-8.fc38.x86_64                            
  libgit2-1.6.4-1.fc38.x86_64                          libkadm5-1.20.1-8.fc38.x86_64                       licensecheck-3.3.8-1.fc38.noarch                                 
  lua-srpm-macros-1-8.fc38.noarch                      mock-4.1-1.fc38.noarch                              mock-core-configs-38.6-1.fc38.noarch                             
  mock-filesystem-4.1-1.fc38.noarch                    ocaml-srpm-macros-7-3.fc38.noarch                   openblas-srpm-macros-2-13.fc38.noarch                            
  package-notes-srpm-macros-0.5-8.fc38.noarch          patch-2.7.6-19.fc38.x86_64                          perl-Array-IntSpan-2.004-10.fc38.noarch                          
  perl-B-Hooks-EndOfScope-0.26-5.fc38.noarch           perl-Data-OptList-0.113-2.fc38.noarch               perl-Devel-StackTrace-1:2.04-15.fc38.noarch                      
  perl-Dist-CheckConflicts-0.11-27.fc38.noarch         perl-Exporter-Tiny-1.006002-1.fc38.noarch           perl-Feature-Compat-Class-0.05-2.fc38.noarch                     
  perl-Feature-Compat-Try-0.05-3.fc38.noarch           perl-File-Compare-1.100.700-497.fc38.noarch         perl-File-Copy-2.39-497.fc38.noarch                              
  perl-Filter-2:1.64-2.fc38.x86_64                     perl-Hash-Util-FieldHash-1.26-497.fc38.x86_64       perl-IO-Interactive-1.023-7.fc38.noarch                          
  perl-IPC-System-Simple-1.30-10.fc38.noarch           perl-Importer-0.026-9.fc38.noarch                   perl-JSON-PP-1:4.16-2.fc38.noarch                                
  perl-Lexical-SealRequireHints-0.012-1.fc38.x86_64    perl-Lexical-Var-0.009-31.fc38.x86_64               perl-List-SomeUtils-0.59-2.fc38.noarch                           
  perl-Log-Any-1.714-1.fc38.noarch                     perl-Log-Any-Adapter-Screen-0.140-14.fc38.noarch    perl-MIME-Charset-1.013.1-2.fc38.noarch                          
  perl-Module-Implementation-0.09-36.fc38.noarch       perl-Module-Runtime-0.016-19.fc38.noarch            perl-Number-Compare-0.03-35.fc38.noarch                          
  perl-Object-HashBase-0.009-12.fc38.noarch            perl-Object-Pad-0.79-1.fc38.x86_64                  perl-Package-Generator-1.106-27.fc38.noarch                      
  perl-Package-Stash-0.40-4.fc38.noarch                perl-Package-Stash-XS-0.30-3.fc38.x86_64            perl-Params-Util-1.102-10.fc38.x86_64                            
  perl-Path-Iterator-Rule-1.015-5.fc38.noarch          perl-Path-Tiny-0.144-2.fc38.noarch                  perl-Pod-Constants-0.19-22.fc38.noarch                           
  perl-Pod-Parser-1.66-1.fc38.noarch                   perl-Regexp-Pattern-0.2.14-11.fc38.noarch           perl-Regexp-Pattern-License-3.10.0-1.fc38.noarch                 
  perl-Set-IntSpan-1.19-30.fc38.noarch                 perl-String-Copyright-0.003014-2.fc38.noarch        perl-String-Escape-2010.002-39.fc38.noarch                       
  perl-String-License-0.0.4-2.fc38.noarch              perl-Sub-Exporter-0.989-2.fc38.noarch               perl-Sub-Exporter-Progressive-0.001013-20.fc38.noarch            
  perl-Sub-Install-0.929-2.fc38.noarch                 perl-Sys-Syslog-0.36-491.fc38.x86_64                perl-Term-Size-Any-0.002-39.fc38.noarch                          
  perl-Term-Size-Perl-0.031-16.fc38.x86_64             perl-Term-Table-0.016-6.fc38.noarch                 perl-Test-Simple-3:1.302194-1.fc38.noarch                        
  perl-Text-Glob-0.11-20.fc38.noarch                   perl-Tie-RefHash-1.40-490.fc38.noarch               perl-Try-Tiny-0.31-5.fc38.noarch                                 
  perl-Unicode-LineBreak-2019.001-15.fc38.x86_64       perl-Unicode-UTF8-0.62-20.fc38.x86_64               perl-Variable-Magic-0.63-2.fc38.x86_64                           
  perl-XS-Parse-Keyword-0.34-1.fc38.x86_64             perl-XS-Parse-Sublike-0.18-1.fc38.x86_64            perl-autodie-2.36-1.fc38.noarch                                  
  perl-encoding-4:3.00-493.fc38.x86_64                 perl-experimental-0.031-1.fc38.noarch               perl-namespace-clean-0.27-22.fc38.noarch                         
  perl-open-1.13-497.fc38.noarch                       perl-srpm-macros-1-48.fc38.noarch                   perl-threads-1:2.27-490.fc38.x86_64                              
  perl-version-8:0.99.29-491.fc38.x86_64               pyproject-srpm-macros-1.9.0-1.fc38.noarch           python-srpm-macros-3.11-10.fc38.noarch                           
  python3-GitPython-3.1.30-2.fc38.noarch               python3-authlib-1.2.0-2.fc38.noarch                 python3-babel-2.11.0-2.fc38.noarch                               
  python3-bugzilla-3.2.0-5.fc38.noarch                 python3-cccolutils-1.5-23.fc38.x86_64               python3-construct-2.10.68-4.fc38.noarch                          
  python3-decorator-5.1.1-5.fc38.noarch                python3-fedora-1.1.1-8.fc38.noarch                  python3-gitdb-4.0.9-5.fc38.noarch                                
  python3-gssapi-1.7.3-4.fc38.x86_64                   python3-jinja2-3.0.3-7.fc38.noarch                  python3-kerberos-1.3.0-18.fc38.x86_64                            
  python3-kitchen-1.2.6-15.fc38.noarch                 python3-koji-1.33.0-1.fc38.noarch                   python3-libmodulemd-2.15.0-2.fc38.x86_64                         
  python3-lockfile-1:0.12.2-9.fc38.noarch              python3-munch-2.5.0-11.fc38.noarch                  python3-openidc-client-0.6.0-18.20220119git0e2ed81.fc38.noarch   
  python3-progressbar2-3.53.2-7.fc38.noarch            python3-pybeam-0.7-5.fc38.noarch                    python3-pygit2-1.12.2-1.fc38.x86_64                              
  python3-pyroute2-0.7.3-1.fc38.noarch                 python3-pytz-2023.3-1.fc38.noarch                   python3-requests-gssapi-1.2.3-7.fc38.noarch                      
  python3-requests-kerberos-0.12.0-19.fc38.noarch      python3-rpkg-1.66-8.fc38.noarch                     python3-rpmautospec-0.3.5-1.fc38.noarch                          
  python3-smmap-5.0.0-4.fc38.noarch                    python3-straight-plugin-1.5.0-20.fc38.noarch        python3-templated-dictionary-1.2-2.fc38.noarch                   
  python3-tomli-w-1.0.0-5.fc38.noarch                  python3-urlgrabber-4.1.0-12.fc38.noarch             python3-utils-3.3.3-2.fc38.noarch                                
  python3-zstandard-0.21.0-1.fc38.x86_64               qt5-srpm-macros-5.15.10-1.fc38.noarch               redhat-rpm-config-252-1.fc38.noarch                              
  rpkg-common-1.66-8.fc38.noarch                       rpm-build-4.18.1-3.fc38.x86_64                      rpmautospec-rpm-macros-0.3.5-1.fc38.noarch                       
  rpmdevtools-9.6-3.fc38.noarch                        rpmlint-2.4.0-6.fc38.noarch                         rpmlint-fedora-license-data-1.24-1.fc38.noarch                   
  rust-srpm-macros-24-2.fc38.noarch                    sombok-2.4.0-18.fc38.x86_64                         systemd-rpm-macros-253.5-1.fc38.noarch                           
  zstd-1.5.5-1.fc38.x86_64                            

Complete!

Step5: Add User to mock group

To be able to test the build procedure in a clean chroot with Mock, you need to configure your account to be a member of the mock group.

[admin@fedcon ~]$ sudo usermod -a -G mock admin

Step6: Acquire Kerberos ticket for koji authentication

In this step we are going to authenticate with FAS credentials on Koji system for acquiring a kerberos token. Here “novicejava1” is my FAS account for which i wanted to get a kerberos token.

[admin@fedcon ~]$ fkinit -u novicejava1
Enter your password and OTP concatenated. (Ignore that the prompt is for only the token)
Password for novicejava1@FEDORAPROJECT.ORG: 

Validate Authentication with koji

[admin@fedcon ~]$ koji moshimoshi
góðan daginn, novicejava1!

You are using the hub at https://koji.fedoraproject.org/kojihub
Authenticated via GSSAPI

Step7: Create package directory

Now its time get some code ready for RPM packaging. Here we are going to creata a package directory and name it as “hello” and switch into that directory as shown below.

[admin@fedcon ~]$ mkdir hello && cd hello

Step8: Create a .spec file

RPM packages are configured by .spec files. Tools such was rpmdev-newspec can be used to generate empty specfiles for different purposes. But for our case lets create this hello.spec file as shown below. You can refer to RPM reference manual – https://rpm-software-management.github.io/rpm/manual/ for understanding more about writing spec files.

[admin@fedcon hello]$ cat hello.spec 
Name:           hello
Version:        2.10
Release:        %autorelease
Summary:        Produces a familiar, friendly greeting

License:        GPL-3.0-or-later
URL:            http://ftp.gnu.org/gnu/%{name}
Source:         http://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.gz

BuildRequires:  bash
BuildRequires:  coreutils
BuildRequires:  gcc
BuildRequires:  gettext
BuildRequires:  glibc-common
BuildRequires:  make
BuildRequires:  sed

%description
The GNU Hello program produces a familiar, friendly greeting. Yes, this is
another implementation of the classic program that prints "Hello, world!" when
you run it.

%prep
%autosetup
mv THANKS THANKS.old
iconv --from-code=ISO-8859-1 --to-code=UTF-8 --output=THANKS THANKS.old

%build
%configure \
    --enable-nls \
    --disable-rpath
%make_build

%install
%make_install
test -f %{buildroot}/%{_infodir}/dir && rm %{buildroot}/%{_infodir}/dir
%find_lang %{name}

%check
make check

%files -f %{name}.lang
%{_mandir}/man1/hello.1.*
%{_infodir}/hello.info.*
%{_bindir}/hello
%doc AUTHORS ChangeLog NEWS README THANKS TODO
%license COPYING

%changelog
%autochangelog

Step9: Download Upstream source package

spectool is a part of “rpmdevtools” package contains scripts and (X)Emacs support files to aid in development of RPM packages. The “-g” option is basically used to get the sources/patches that are listed with a URL in the spec file as shown below.

[admin@fedcon hello]$ spectool -g hello.spec
Downloading: http://ftp.gnu.org/gnu/hello/hello-2.10.tar.gz
100% of 708.9 KiB |###################################################################################################################| Elapsed Time: 0:00:03 Time:  0:00:03
Downloaded: hello-2.10.tar.gz

[admin@fedcon hello]$ ls -ltr
total 716
-rw-r--r--. 1 admin admin    527 Jul  3 22:56 hello.spec
-rw-r--r--. 1 admin admin 725946 Jul  3 23:22 hello-2.10.tar.gz

Step10: Build the Package

Now we have our source tar package along with the spec file ready for building our pacakage. Here we are going to use “fedpkg” tool which help in getting a Local test build done using mock. Mock takes an SRPM and builds it in a chroot.

A chroot is an operation that changes the apparent root directory for the current running process and their children. A program that is run in such a modified environment cannot access files and commands outside that environmental directory tree. This modified environment is called a chroot jail.

[admin@fedcon hello]$ fedpkg --release f38 mockbuild
Failed to get repository name from Git url or pushurl
Failed to get ns from Git url or pushurl
sources file doesn't exist. Source files download skipped.

setting SOURCE_DATE_EPOCH=1688342400
Wrote: /home/admin/hello/hello-2.10-1.fc38.src.rpm
INFO: mock.py version 4.1 starting (python version = 3.11.4, NVR = mock-4.1-1.fc38)...
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
INFO: Start(/home/admin/hello/hello-2.10-1.fc38.src.rpm)  Config(fedora-38-x86_64)
Start: clean chroot
Finish: clean chroot
Start(bootstrap): chroot init
...
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.pZ02eZ
+ umask 022
+ cd /builddir/build/BUILD
+ cd hello-2.10
+ /usr/bin/rm -rf /builddir/build/BUILDROOT/hello-2.10-1.fc38.x86_64
+ RPM_EC=0
++ jobs -p
+ exit 0
Executing(rmbuild): /bin/sh -e /var/tmp/rpm-tmp.lsUPrj
+ umask 022
+ cd /builddir/build/BUILD
+ rm -rf hello-2.10 hello-2.10.gemspec
+ RPM_EC=0
++ jobs -p
+ exit 0
Finish: rpmbuild hello-2.10-1.fc38.src.rpm
Finish: build phase for hello-2.10-1.fc38.src.rpm
INFO: Done(/home/admin/hello/hello-2.10-1.fc38.src.rpm) Config(fedora-38-x86_64) 10 minutes 58 seconds
INFO: Results and/or logs in: /home/admin/hello/results_hello/2.10/1.fc38
INFO: Cleaning up build root ('cleanup_on_success=True')
Start: clean chroot
Finish: clean chroot
Finish: run

Validate the tree structure of our package after the build as shown below.

[admin@fedcon hello]$ tree .
.
├── hello-2.10-1.fc38.src.rpm
├── hello-2.10.tar.gz
├── hello.spec
└── results_hello
    └── 2.10
        └── 1.fc38
            ├── build.log
            ├── hello-2.10-1.fc38.src.rpm
            ├── hello-2.10-1.fc38.x86_64.rpm
            ├── hello-debuginfo-2.10-1.fc38.x86_64.rpm
            ├── hello-debugsource-2.10-1.fc38.x86_64.rpm
            ├── hw_info.log
            ├── installed_pkgs.log
            ├── root.log
            └── state.log
4 directories, 12 files

Step10: Check results with rpmlint

rpmlint is a tool for checking common errors in RPM packages. Binary and source packages as well as spec files can be checked. We can invoke it using fedpkg by passing the lint argument as shown below.

[admin@fedcon hello]$ fedpkg --release f38 lint
Failed to get repository name from Git url or pushurl
Failed to get ns from Git url or pushurl
Mockbuild results directory found. Linting mockbuild results.
=========================================================================== rpmlint session starts ==========================================================================
rpmlint: 2.4.0
configuration:
    /usr/lib/python3.11/site-packages/rpmlint/configdefaults.toml
    /etc/xdg/rpmlint/fedora-legacy-licenses.toml
    /etc/xdg/rpmlint/fedora-spdx-licenses.toml
    /etc/xdg/rpmlint/fedora.toml
    /etc/xdg/rpmlint/scoring.toml
    /etc/xdg/rpmlint/users-groups.toml
    /etc/xdg/rpmlint/warn-on-functions.toml
checks: 31, packages: 3

hello.src: W: strange-permission hello.spec 600
============================================ 2 packages and 1 specfiles checked; 0 errors, 1 warnings, 0 badness; has taken 0.2 s ===========================================

Step11: Check Package

We can now validate our package using the below rpm cli tool as retrieve information about our package files and information about the package.

[admin@fedcon hello]$ rpm -ql results_hello/2.10/1.fc38/hello-2.10-1.fc38.x86_64.rpm
/usr/bin/hello
/usr/lib/.build-id
/usr/lib/.build-id/66
/usr/lib/.build-id/66/f925ccfe5f7e9303308f8ea640a8da26fe9db1
/usr/share/doc/hello
/usr/share/doc/hello/AUTHORS
/usr/share/doc/hello/ChangeLog
/usr/share/doc/hello/NEWS
/usr/share/doc/hello/README
/usr/share/doc/hello/THANKS
/usr/share/doc/hello/TODO
/usr/share/info/hello.info.gz
/usr/share/licenses/hello
/usr/share/licenses/hello/COPYING
/usr/share/locale/bg/LC_MESSAGES/hello.mo
/usr/share/locale/ca/LC_MESSAGES/hello.mo
/usr/share/locale/da/LC_MESSAGES/hello.mo
/usr/share/locale/de/LC_MESSAGES/hello.mo
/usr/share/locale/el/LC_MESSAGES/hello.mo
/usr/share/locale/eo/LC_MESSAGES/hello.mo
/usr/share/locale/es/LC_MESSAGES/hello.mo
/usr/share/locale/et/LC_MESSAGES/hello.mo
/usr/share/locale/eu/LC_MESSAGES/hello.mo
/usr/share/locale/fa/LC_MESSAGES/hello.mo
/usr/share/locale/fi/LC_MESSAGES/hello.mo
/usr/share/locale/fr/LC_MESSAGES/hello.mo
/usr/share/locale/ga/LC_MESSAGES/hello.mo
/usr/share/locale/gl/LC_MESSAGES/hello.mo
/usr/share/locale/he/LC_MESSAGES/hello.mo
/usr/share/locale/hr/LC_MESSAGES/hello.mo
/usr/share/locale/hu/LC_MESSAGES/hello.mo
/usr/share/locale/id/LC_MESSAGES/hello.mo
/usr/share/locale/it/LC_MESSAGES/hello.mo
/usr/share/locale/ja/LC_MESSAGES/hello.mo
/usr/share/locale/ka/LC_MESSAGES/hello.mo
/usr/share/locale/ko/LC_MESSAGES/hello.mo
/usr/share/locale/lv/LC_MESSAGES/hello.mo
/usr/share/locale/ms/LC_MESSAGES/hello.mo
/usr/share/locale/nb/LC_MESSAGES/hello.mo
/usr/share/locale/nl/LC_MESSAGES/hello.mo
/usr/share/locale/nn/LC_MESSAGES/hello.mo
/usr/share/locale/pl/LC_MESSAGES/hello.mo
/usr/share/locale/pt/LC_MESSAGES/hello.mo
/usr/share/locale/pt_BR/LC_MESSAGES/hello.mo
/usr/share/locale/ro/LC_MESSAGES/hello.mo
/usr/share/locale/ru/LC_MESSAGES/hello.mo
/usr/share/locale/sk/LC_MESSAGES/hello.mo
/usr/share/locale/sl/LC_MESSAGES/hello.mo
/usr/share/locale/sr/LC_MESSAGES/hello.mo
/usr/share/locale/sv/LC_MESSAGES/hello.mo
/usr/share/locale/th/LC_MESSAGES/hello.mo
/usr/share/locale/tr/LC_MESSAGES/hello.mo
/usr/share/locale/uk/LC_MESSAGES/hello.mo
/usr/share/locale/vi/LC_MESSAGES/hello.mo
/usr/share/locale/zh_CN/LC_MESSAGES/hello.mo
/usr/share/locale/zh_TW/LC_MESSAGES/hello.mo
/usr/share/man/man1/hello.1.gz
[admin@fedcon hello]$ rpm -qi results_hello/2.10/1.fc38/hello-2.10-1.fc38.x86_64.rpm
Name        : hello
Version     : 2.10
Release     : 1.fc38
Architecture: x86_64
Install Date: (not installed)
Group       : Unspecified
Size        : 205505
License     : GPL-3.0-or-later
Signature   : (none)
Source RPM  : hello-2.10-1.fc38.src.rpm
Build Date  : Mon 03 Jul 2023 11:48:44 PM IST
Build Host  : fedcon.stack.com
URL         : http://ftp.gnu.org/gnu/hello
Summary     : Produces a familiar, friendly greeting
Description :
The GNU Hello program produces a familiar, friendly greeting. Yes, this is
another implementation of the classic program that prints "Hello, world!" when
you run it.

Step12: Building in Fedora Infrastrucuture

The mock build was carried out locally. But we can leverage the koji build system and try to do a scratch-build on this system using the below command. We will need to pass the source rpm for this remote build operation to be triggered as shown below.

[admin@fedcon hello]$ fedpkg --release f38 scratch-build --srpm results_hello/2.10/1.fc38/hello-2.10-1.fc38.src.rpm
[====================================] 100% 00:00:04 723.39 KiB 172.38 KiB/sec
Building hello-2.10-1.fc38.src.rpm for f38-candidate
Created task: 102887209
Task info: https://koji.fedoraproject.org/koji/taskinfo?taskID=102887209
Watching tasks (this may be safely interrupted)...
102887209 build (f38-candidate, hello-2.10-1.fc38.src.rpm): free
102887209 build (f38-candidate, hello-2.10-1.fc38.src.rpm): free -> open (buildvm-ppc64le-25.iad2.fedoraproject.org)
  102887212 rebuildSRPM (noarch): open (buildvm-ppc64le-20.iad2.fedoraproject.org)
  102887324 buildArch (hello-2.10-1.fc38.src.rpm, ppc64le): open (buildvm-ppc64le-29.iad2.fedoraproject.org)
  102887323 buildArch (hello-2.10-1.fc38.src.rpm, aarch64): open (buildvm-a64-37.iad2.fedoraproject.org)
  102887321 buildArch (hello-2.10-1.fc38.src.rpm, i686): open (buildvm-x86-23.iad2.fedoraproject.org)
  102887325 buildArch (hello-2.10-1.fc38.src.rpm, s390x): open (buildvm-s390x-21.s390.fedoraproject.org)
  102887322 buildArch (hello-2.10-1.fc38.src.rpm, x86_64): open (buildhw-x86-12.iad2.fedoraproject.org)
  102887212 rebuildSRPM (noarch): open (buildvm-ppc64le-20.iad2.fedoraproject.org) -> closed
  0 free  6 open  1 done  0 failed
  102887323 buildArch (hello-2.10-1.fc38.src.rpm, aarch64): open (buildvm-a64-37.iad2.fedoraproject.org) -> closed
  0 free  5 open  2 done  0 failed
102887209 build (f38-candidate, hello-2.10-1.fc38.src.rpm): open (buildvm-ppc64le-25.iad2.fedoraproject.org) -> closed
  0 free  4 open  3 done  0 failed
  102887324 buildArch (hello-2.10-1.fc38.src.rpm, ppc64le): open (buildvm-ppc64le-29.iad2.fedoraproject.org) -> closed
  0 free  3 open  4 done  0 failed
  102887321 buildArch (hello-2.10-1.fc38.src.rpm, i686): open (buildvm-x86-23.iad2.fedoraproject.org) -> closed
  0 free  2 open  5 done  0 failed
  102887325 buildArch (hello-2.10-1.fc38.src.rpm, s390x): open (buildvm-s390x-21.s390.fedoraproject.org) -> closed
  0 free  1 open  6 done  0 failed
  102887322 buildArch (hello-2.10-1.fc38.src.rpm, x86_64): open (buildhw-x86-12.iad2.fedoraproject.org) -> closed
  0 free  0 open  7 done  0 failed

102887209 build (f38-candidate, hello-2.10-1.fc38.src.rpm) completed successfully

As you can see from the output the koji build task id is provided which you can further verify if your build has been successful or not or the remote koji build system.

Hope you enjoyed reading this article. Thank you..