DNF Issue
I am preparing to release LiterateX and implemented RPM packaging. It seems that people who use RPM-based distributions currently use DNF for package management. When installing my package, however, not all of the files were installed! I spent too much time trying to debug the issue and finally figured it out. I am writing this blog entry because it may help others solve the issue more quickly.
The Issue
The RPM file, created by first creating a source RPM (SRPM) and
running rpmbuild --rebuild
to build the binary RPM from the
source RPM, contains all of the files that should be installed.
[literatex] $ docker run --rm -it -v $(pwd)/build:/host:ro fedora:34 \
rpm -qlp /host/literatex-haskell-0.0.0.0-1.fc34.x86_64.rpm
/usr/bin/literatex
/usr/lib/.build-id
/usr/lib/.build-id/b0
/usr/lib/.build-id/b0/8d2c239a90163a0c98bc99b11115b252b0128a
/usr/share/doc/literatex-haskell
/usr/share/doc/literatex-haskell/LICENSE.gz
/usr/share/doc/literatex-haskell/README.md.gz
/usr/share/doc/literatex-haskell/changelog.gz
/usr/share/man/man1/literatex.1.gz
When installed using dnf
,
however, none of the files under /usr/share
are installed!
Running the install command with verbose output gives no clues.
[literatex] $ docker run --rm -it -v $(pwd)/build:/host:ro fedora:34 \
/bin/bash
[root@c9ebc90b6a13 /]# dnf install -v -y \
/host/literatex-haskell-0.0.0.0-1.fc34.x86_64.rpm
...
[root@c9ebc90b6a13 /]# literatex --version
literatex-haskell 0.0.0.0
[root@c9ebc90b6a13 /]# test -d /usr/share/doc/literatex-haskell \
|| echo not found
not found
[root@c9ebc90b6a13 /]# test -f /usr/share/man/man1/literatex.1.gz \
|| echo not found
not found
Installing with yum
has the
same results.
[literatex] $ docker run --rm -it -v $(pwd)/build:/host:ro fedora:34 \
/bin/bash
[root@8a372c0a7e50 /]# yum localinstall -v -y \
/host/literatex-haskell-0.0.0.0-1.fc34.x86_64.rpm
...
[root@8a372c0a7e50 /]# literatex --version
literatex-haskell 0.0.0.0
[root@8a372c0a7e50 /]# test -d /usr/share/doc/literatex-haskell \
|| echo not found
not found
[root@8a372c0a7e50 /]# test -f /usr/share/man/man1/literatex.1.gz \
|| echo not found
not found
The issue does not happen when using the rpm
command.
All of the files are installed.
[literatex] $ docker run --rm -it -v $(pwd)/build:/host:ro fedora:34 \
/bin/bash
[root@b89504bdbe46 /]# rpm -i \
/host/literatex-haskell-0.0.0.0-1.fc34.x86_64.rpm
[root@b89504bdbe46 /]# literatex --version
literatex-haskell 0.0.0.0
[root@b89504bdbe46 /]# ls /usr/share/doc/literatex-haskell
LICENSE.gz README.md.gz changelog.gz
[root@b89504bdbe46 /]# ls /usr/share/man/man1/literatex.1.gz
/usr/share/man/man1/literatex.1.gz
The Cause
The RPM file contains all of the files, and the rpm
command installs all of the files, so I searched for some kind of
configuration that makes yum
/dnf
not install
files that are not necessary to run a program. I finally found
a DNF
configuration option called tsflags
that sets RPM
transactions options. The value nodocs
sets RPM transaction
flag RPMTRANS_FLAG_NODOCS
!
There is no further documentation about this flag, unfortunately. I
observe that files under %{_mandir}
and
%{_datadir}/doc/%{name}
are not installed when this flag is
set. I wonder if files under %{_datadir}/%{name}
are
installed or not, as such files may be required by the software.
LiterateX does not have such files, so I will not worry about it at this
time.
Checking the DNF configuration of the Docker container, the
nodocs
flag is indeed set. Its use makes sense because
container images should be kept small, but it is unfortunate that the
behavior is not documented in the description of the
fedora
image.
[literatex] $ docker run --rm -it -v $(pwd)/build:/host:ro fedora:34 \
/bin/bash
[root@bd140b7da91c /]# grep nodocs /etc/dnf/dnf.conf
tsflags=nodocs
After removing this flag, dnf
installs all files.
[root@bd140b7da91c /]# sed -i '/^tsflags=/d' /etc/dnf/dnf.conf
[root@bd140b7da91c /]# dnf install -v -y \
/host/literatex-haskell-0.0.0.0-1.fc34.x86_64.rpm
...
[root@bd140b7da91c /]# literatex --version
literatex-haskell 0.0.0.0
[root@bd140b7da91c /]# ls /usr/share/doc/literatex-haskell
LICENSE.gz README.md.gz changelog.gz
[root@bd140b7da91c /]# ls /usr/share/man/man1/literatex.1.gz
/usr/share/man/man1/literatex.1.gz