User:Jengelh

Jump to: navigation, search

Avoid small packages if possible

The overhead for recording a package can outweigh the on-disk contributions by the package.

# rpm --rebuilddb; rsync -Pa /usr/lib/sysimage/rpm/ /tmp/rpm-old/
# zypper in --no-recommends iproute2-bash-completion; rpm --rebuilddb
Package install size change:
              |      52.6 KiB  required by packages that will be installed
    52.6 KiB  |  -      0 B    released by packages that will be removed

# ls -al /tmp/rpm-old/P* /var/lib/rpm/P*
-rw-r--r--. 1 root root 102024864 Jul 27 13:50 /tmp/rpm-old/Packages.db
-rw-r--r--. 1 root root 102080656 Jul 27 13:51 /var/lib/rpm/Packages.db

The iproute2-bash-completion package has 4 file objects, about 53 KB of file content, and consumes 58 KB metadata to be recorded in rpm.

# rpm --rebuilddb; rsync -Pa /usr/lib/sysimage/rpm/ /tmp/rpm-old/
# zypper in --no-recommends xorg-x11; rpm --rebuilddb
Package download size:    79.2 KiB

Package install size change:
            |       794 B  required by packages that will be installed
     794 B  |  -      0 B  released by packages that will be removed
# ls -al /tmp/rpm-old/P* /var/lib/rpm/P*
-rw-r--r--. 1 root root 102477808 Jul 27 13:52 /tmp/rpm-old/Packages.db
-rw-r--r--. 1 root root 102555184 Jul 27 13:53 /var/lib/rpm/Packages.db

The xorg-x11 package contains just 2 file objects and 794 bytes of file text, and consumes 77 KB of metadata for rpm to record.

$ cat a.spec 
Name: a
Version: 0
Release: 0
License: a
Summary: a
%description
%files
$ rpmbuild -bb a.spec
$ ls -al
-rw-r--r--. 1 linux linux 5645 Jul 27 14:01 a-0-0.x86_64.rpm
$ rpm -qlvp a-0-0.x86_64.rpm 
(contains no files)

# rpm --rebuilddb; rsync -Pa /usr/lib/sysimage/rpm/ /tmp/rpm-old/

# rpm -Uhv a-0-0.x86_64.rpm; rpm --rebuilddb
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...
   1:a-0-0                            ################################# [100%]

# ls -al /tmp/rpm-old/P* /var/lib/rpm/P*
-rw-r--r--. 1 root root 104332016 Jul 27 14:02 /tmp/rpm-old/Packages.db
-rw-r--r--. 1 root root 104334016 Jul 27 14:02 /var/lib/rpm/Packages.db

Lower bound is still about 2 KB per package.

Changelog contributes a large portion, the histogram for which on my system as of 2025-07-27 is:

   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
      0    2305    4687   23329   11950 3922200 

sum: 74979241 (pkgs: 3251)

Use of build helper is mandated if offered

Background: A config helper ensures that the user of a library gets the correct flags for the installed version of a library. The helper may take the form of a /usr/lib/pkgconfig/foobar.pc file, a /usr/share/cmake/foobar.cmake file, a /usr/bin/foobar-config script, etc. The particular implementation is inconsequential.

Claim 1: A software piece offering a config helper values portability and consistency.

Reasoning: If the presence of a config helper were not to mean "use me", the raison d'ĂȘtre for said helper file would be naught.

Claim 2: A downstream sharing such portability goals would consistenly consume such config helpers. (it need only use one of the implemented methods, i.e. either the pc file or the cmake file, etc.)

Enforcing proper includes

Problem statement

Xlib.h shall be included by means of #include <X11/Xlib.h>, not #include <Xlib.h>, as per documentation. The latter may accidentally lead to a successfully compilable result when -I/usr/include/X11 is on the command-line for some reason. We want to detect erroneous uses of <Xlib.h>. xcb.h is the same, but a more modern project (née ~2006) so does not have the benefit of historical doubt.

mysql.h shall be included by means of #include <mysql.h>, not #include <mysql/mysql.h>, as per the documentation. The latter may accidentally lead to a successfully compilable result on some platforms due to the way packaging in the system was made. We want to detect erroneous uses of <mysql/mysql.h>.

Solution

For software pieces already mandating a config helper (see details in section above), move headers out of the compiler's standard search path and emit the alternate path via the config helper.

If each library gets a distinct -I prefix, we can ensure that a downstream package is properly declaring all dependencies, and that no output from one library's config helper accidentally brings a second library's headers in scope too.

A handful of software need simply be built with

./configure --includedir=%_includedir/%name

to make header files land in the desired location and .pc files featuring matching -I flags in the Cflags line.

Case studies

The unmodified freetype tarball from upstream defaults to placing its headers in a non-default search path.