RPM tips

Here you can find RPM and SPEC file gotchas rarely used and hard to found if needed.

Only mark file as documentation

%doc macro followed by relative path does lot of things. It removes the documentation directory (/usr/share/doc/%{name}-%{version}), creates it again, copies arguments from source directory and marks them as documentation.

All this stuff is done after proceeding whole %files section. This effectively forbids to install non-documentation files into the directory (e.g. needed within examples sub-package.

Solution is to add add absolute path (to BUILDROOT) after the %doc macro.

References: [1]

Mark translation file manually

The %find_lang macro works only for standard gettext paths and names. In addition, it produces file list in special file instead of installing the files into %files section. The installation is done by supplying the file list as -f option to %files macro.

This does not allow to find and mark non-standandard translations.

You can mark the files in %files section manually by prepending %lang(LANG_CODE) macro before absolute file (to RPM_BUILD_ROOT). E.g. %lang(cs) /usr/share/%{name}/translations/czech.mo

Reference: /usr/lib/rpm/find-lang.sh script from rpm-build package.

How to get know all metadata in binary RPM package

There is lot of attributes (like language or documentation markers) in package metadata not visible by casual tools.

You can get them (on installed package) by rpmquery utility. I found XML output most readable (e.g. rpmquery --xml rpm | less).

References: /usr/bin/rpmquery --help from rpm package.

How to determine BuildRequires

Manually. Or try auto-buildrequires tool. Packaged in Fedora already.