Link

As mentioned in last week’s blog, installing packages from a tarball should be avoided, the reason being that the process can install files into locations throughout your system which makes them difficult to find if you need to remove them later. Also, if the package needs to be updated, you will have to manually remove the old version and install the newer version. If instead you build an rpm package and install it with a package manager, you can use package manager tools to easily query, update or remove the package going forward.
In keeping with that thinking, this week I attempted to build rpm packages for wdiff and rottlog.
I read somewhere that it’s a good idea to create a separate user for development work, so I created an alter ego user for this purpose. Her name is Patience, and I think she will be very helpful this semester.

I started with rottlog, but after a few bungled build attempts following poor spec file edits and completely baffling error messages, I gave it up temporarily to work on wdiff instead. Wipe out the build directory and start over.

After getting basic information into the spec file (and commenting out the BuildRequires line) there was some real progress happening, but it would end with error messages about files not being found, similar to:

rpmbuild/BUILDROOT/somefile: No such file or directory

I could see that my build was making it past the configure stage, but stalled during the install stage. I reviewed the %install section from Fedora’s wiki and noticed that my skeleton spec file was using the %make_install macro, which the site points out is an “inferior” method. So I replaced my %install section with their recommendation:

%install
rm -rf %{buildroot}
make DESTDIR=%{buildroot} install

That got it working past the install stage and as far as the %files stage where I encountered the very common “error: Installed (but unpackaged) file(s) found”. Thankfully a lot of students posting on the planet came across this first. It seems that you just need to add all those files to the %files section of the spec file. And as my classmate Richard pointed out in his post, you don’t have to copy all the files in there verbatim. Use the macros.

So for example, if you see the following:

error: Installed (but unpackaged) file(s) found
/usr/bin/wdiff

Add this to the %files section of your spec file

%{_bindir}/wdiff

and that will fix it.

And use globbing to match several files. The following files:

/usr/share/locale/af/LC_MESSAGES/wdiff-gnulib.mo
/usr/share/locale/be/LC_MESSAGES/wdiff-gnulib.mo
/usr/share/locale/bg/LC_MESSAGES/wdiff-gnulib.mo
/usr/share/locale/ca/LC_MESSAGES/wdiff-gnulib.mo
/usr/share/locale/cs/LC_MESSAGES/wdiff-gnulib.mo
/usr/share/locale/da/LC_MESSAGES/wdiff-gnulib.mo
/usr/share/locale/de/LC_MESSAGES/wdiff-gnulib.mo
/usr/share/locale/el/LC_MESSAGES/wdiff-gnulib.mo

can all be added to the spec file with one simple line:

%{_datadir}/locale/*/LC_MESSAGES/wdiff-gnulib.mo

No errors reported when running rpmlint on the spec file or the SRPM; but there was one error in RPM:
wdiff.x86_64: E: info-dir-file /usr/share/info/dir

Checked the Fedora guide and found the problem. I had added post and preun sections to the spec file to deal with the info manual, but I’d missed adding a line to the install section that deletes empty info directories. By adding rm -f %{buildroot}%{_infodir}/dir to the %install section of the spec, that fixed the error.

What stands out for me most at the moment about building packages is this: follow the Fedora guide and use it to build a solid spec file. Understand the framework, i.e. what each section is meant to do. That will make the build process much smoother.

Leave a comment