From 4f490ad7f9794af4abe7cb9404e57b3f665c6b1d Mon Sep 17 00:00:00 2001 From: Otto Urpelainen Date: Feb 03 2022 06:44:04 +0000 Subject: Check result in GNU Hello tutorial In the GNU Hello tutorial, in order to better explain what was produces, run some basic checks against the produced package: list files, list requires, list provides. Finally, install and run the package. Adding these checks closes the gap to another similar docs page, "Creating RPM Packages" in Fedora Quick Docs. Adding the missing parts in the GNU Hello Tutorial allows removing that page. --- diff --git a/modules/ROOT/pages/Packaging_Tutorial_GNU_Hello.adoc b/modules/ROOT/pages/Packaging_Tutorial_GNU_Hello.adoc index 3c72692..5b1e691 100644 --- a/modules/ROOT/pages/Packaging_Tutorial_GNU_Hello.adoc +++ b/modules/ROOT/pages/Packaging_Tutorial_GNU_Hello.adoc @@ -21,6 +21,10 @@ If you plan to create an RPM package for the Fedora repository, follow the process for xref:Joining_the_Package_Maintainers.adoc[Joining the Package Maintainers], including following the various Fedora guidance. +This tutorial is intended to be run on a Fedora {MAJOROSVER} system. +It should, however, work also for other releases. +Just replace strings like `f{MAJOROSVER}` with your release number. + [#dev_env] == Development Environment @@ -37,11 +41,13 @@ you need to configure your non-privileged account to be a member of the `mock` g $ sudo usermod -a -G mock ---- -Those are the only commands requiring `+sudo+` privileges. -All the remaining work should be done from your regular, non-privileged account, +This is the only setup requiring `+sudo+` privileges. +The remaining work should be done from your regular, non-privileged account, or even from a separate account created just for development work. Modern RPM-based systems, including Fedora, -are set up to build and test RPM packages purely from within a non-privileged account. +are set up to build packages purely from within a non-privileged account. +Later in the tutorial, +installing the pacakge to test it also requires `+sudo+` privileges. [#building] == Building the RPM @@ -151,8 +157,9 @@ To get as close to a production build as is locally possible, we use the `fedpkg mockbuild` command which also invokes Mock: +[subs="attributes+"] ---- -$ fedpkg --release rawhide mockbuild +$ fedpkg --release f{MAJOROSVER} mockbuild ---- The build environment created by Mock is very basic. @@ -353,7 +360,7 @@ Pass files to check as arguments: [subs="attributes+"] ---- -$ rpmlint hello.spec results_hello/2.10/1.fc{NEXTOSVER}/hello-2.10*.{x86_64,src}.rpm +$ rpmlint hello.spec results_hello/2.10/1.fc{MAJOROSVER}/hello-2.10*.{x86_64,src}.rpm ---- If all is good, there should be no warnings or errors. @@ -432,6 +439,117 @@ With this `.spec` file, you should be able to successfully complete the build process, and create the source and binary RPM packages. +== Checking the result + +Having a working specfile and rpms built from it, +the result can be checked. +Before checking the result by installing the package, +let us do some simple checks. + +=== Files + +List the files contained in the package: + +[subs="attributes+"] +---- +$ dnf -C repoquery --list ./results_hello/2.10/1.fc{MAJOROSVER}/hello-2.10-1.fc{MAJOROSVER}.x86_64.rpm +/usr/bin/hello +/usr/lib/.build-id +/usr/lib/.build-id/39 +/usr/lib/.build-id/39/c97ecb15c6292ce23e8b00e15e6e72a61e5072 +/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/zh_TW/LC_MESSAGES/hello.mo +/usr/share/man/man1/hello.1.gz +---- + +You can see that all the files listed in the specfile `+%files+` section are included, +including the automatically processed locale files. +Also, under `+/usr/lib/.build-id+`, +there is an automatically generated file. +It is actually a symlink, +mapping an build id to the `+hello+` binary for debugging purposes. + +=== Requires + +List the package's runtime dependencies with the following command: + +[subs="attributes+"] +---- +$ dnf -C repoquery --requires ./results_hello/2.10/1.fc{MAJOROSVER}/hello-2.10-1.fc{MAJOROSVER}.x86_64.rpm +libc.so.6()(64bit) +libc.so.6(GLIBC_2.14)(64bit) +libc.so.6(GLIBC_2.2.5)(64bit) +libc.so.6(GLIBC_2.3)(64bit) +libc.so.6(GLIBC_2.3.4)(64bit) +libc.so.6(GLIBC_2.34)(64bit) +libc.so.6(GLIBC_2.4)(64bit) +libc.so.6(GLIBC_2.7)(64bit) +rpmlib(CompressedFileNames) <= 3.0.4-1 +rpmlib(FileDigests) <= 4.6.0-1 +rpmlib(PayloadFilesHavePrefix) <= 4.0-1 +rpmlib(PayloadIsZstd) <= 5.4.18-1 +rtld(GNU_HASH) +---- + +You can check what packages provide these dependencies as follows: + +[subs="attributes+"] +---- +$ dnf -C repoquery --whatprovides 'libc.so.6()(64bit)' +glibc-0:2.34-11.fc{MAJOROSVER}.x86_64 +glibc-0:2.34-7.fc{MAJOROSVER}.x86_64 +---- + +You will see that the only dependency of GNU Hello is `+glibc+`, +which provides symbols in `+libc.so.6+` as well as `+rtld(GNU_HASH)+`. + +The `+rpmlib+` requires are special. +These specify various rpm features used in the rpm package itself, +constraining the version of `+rpm+` that can be used to install the package. + +=== Provides + +Conversely, to check what capabilities the package provides, you can do: + +[subs="attributes+"] +---- +$ dnf -C repoquery --provides ./results_hello/2.10/1.fc{MAJOROSVER}/hello-2.10-1.fc{MAJOROSVER}.x86_64.rpm +hello = 2.10-1.fc{MAJOROSVER} +hello(x86-64) = 2.10-1.fc{MAJOROSVER} +---- + +The provides of this package are very simple. +It simply provides its own name, +in plain and architecture specific forms. + +=== Installing + +As a final check, the package can be installed and ran: + +[subs="attributes+"] +---- +$ sudo dnf -C -y install ./results_hello/2.10/1.fc{MAJOROSVER}/hello-2.10-1.fc{MAJOROSVER}.x86_64.rpm +$ hello --greeting="Hello, rpm!" +Hello, rpm! +---- + +To clean up your system, undo the installation: + +---- +$ sudo dnf -C -y history undo last +---- + == References * https://rpm-software-management.github.io/rpm/manual/[RPM Reference Manual]