Building Units Package with rpmbuild

Rpmbuild with the Units package

Units Package 2.00

Fill in the basic information into the units.spec file

Name: units
Version: 2.00
License: GPLv3+
URL: http://ftp.gnu.org/gnu/units/
Source0: http://ftp.gnu.org/gnu/units/units-2.00.tar.gz

Don’t forget to write a short discription under the %description macro.

Remove the build requires line and run
rpmbuild -ba ~/rpmbuild/SPECS/units.spec

and an error occured, if you look up a little higher from the bottom, you can see where the error happens

./mkinstalldirs /usr/share/units/ /home/acoatley-willis/rpmbuild/BUILDROOT/units-2.00-1.fc17.x86_64/usr/bin
mkdir /usr/share/units
mkdir: cannot create directory `/usr/share/units’: Permission denied

In this case it seems like during the make install phase, it’s trying to make directories outside the build root.
This error can be solve by making a patch to change the Makefile.in after extracting the files. The steps to do this are shown here: https://andrewow.wordpress.com/2012/09/25/how-to-patch-units-makefile-in/

Next lets run it again
rpmbuild -ba ~/rpmbuild/SPECS/units.spec

and some more errors

error: Installed (but unpackaged) file(s) found:
/usr/bin/units
/usr/bin/units_cur
/usr/share/info/units.info.gz
/usr/share/man/man1/units.1.gz
/usr/share/units/currency.units
/usr/share/units/definitions.units
/usr/share/units/locale.map

These mean that I did not include the files and folders in the %files section of the spec file, I should also take this time to look through the source file(.tar.gz) for all the information documents, such as README.

%files
%doc README COPYING NEWS ChangeLog
%{_bindir}/*
%{_mandir}/man1/*
%{_infodir}/*
%{_datadir}/%{name}/

These are all the macros for the files and directories, along with the documents I found. Lets build again.
rpmbuild -ba ~/rpmbuild/SPECS/units.spec

Now there has been a successful build, but now we must check the .spec file, the 2 binary RPMs and the SRPM with the command
rpmlint ~/rpmbuild/SPECS/units.spec
0 packages and 1 specfiles checked; 0 errors, 0 warnings.

rpmlint ~/rpmbuild/RPMS/x86_64/units-2.00-1.fc17.x86_64.rpm
units.x86_64: E: no-changelogname-tag
units.x86_64: W: manual-page-warning /usr/share/man/man1/units.1.gz 945: warning: macro `++’ not defined
units.x86_64: E: info-files-without-install-info-postin /usr/share/info/units.info.gz
units.x86_64: E: info-files-without-install-info-postun /usr/share/info/units.info.gz
units.x86_64: W: no-manual-page-for-binary units_cur
1 packages and 0 specfiles checked; 3 errors, 2 warnings.

The no-changelogname-tag is telling us we forgot to put a change log in the spec file

%changelog
* Thu Sep 27 2012 Andrew Oatley-Willis – 2.00-1
– Initial Packaging

Now lets rebuild, then run rpmlint again

rpmlint ~/rpmbuild/RPMS/x86_64/units-2.00-1.fc17.x86_64.rpm
units.x86_64: W: manual-page-warning /usr/share/man/man1/units.1.gz 945: warning: macro `++’ not defined
units.x86_64: E: info-files-without-install-info-postin /usr/share/info/units.info.gz
units.x86_64: E: info-files-without-install-info-postun /usr/share/info/units.info.gz
units.x86_64: W: no-manual-page-for-binary units_cur
1 packages and 0 specfiles checked; 2 errors, 2 warnings.

Now we only have these last 2 errors which look the same, they are saying that this package requires the installation of texinfo files, which are used for documentation. These errors can be solved with a little scriptlet.

Requires(post): info
Requires(preun): info

%post
/sbin/install-info %{_infodir}/%{name}.info %{_infodir}/dir || :

%preun
if [ $1 = 0 ] ; then
/sbin/install-info –delete %{_infodir}/%{name}.info %{_infodir}/dir || :
fi

After Rebuilding and running rpmlint

rpmlint ~/rpmbuild/RPMS/x86_64/units-2.00-1.fc17.x86_64.rpm
units.x86_64: W: manual-page-warning /usr/share/man/man1/units.1.gz 945: warning: macro `++’ not defined
units.x86_64: W: no-manual-page-for-binary units_cur
1 packages and 0 specfiles checked; 0 errors, 2 warnings.

There are no more errors and we can procede, to checking the other RPM and SRPM

rpmlint ~/rpmbuild/RPMS/x86_64/units-debuginfo-2.00-1.fc17.x86_64.rpm
1 packages and 0 specfiles checked; 0 errors, 0 warnings.

rpmlint ~/rpmbuild/SRPMS/units-2.00-1.fc17.src.rpm
1 packages and 0 specfiles checked; 0 errors, 0 warnings.

No errors, you can safely move on to mock.

Advertisements

About oatleywillisa

Computer Networking Student
This entry was posted in SBR600. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s