RPM packaging Process
Preparation
First and foremost, I installed the required packages: Fedora Packager (group of packages) and rpmlint and yum-utils
$ sudo yum -y groupinstall "Fedora Packager"
Next Package
$ sudo yum -y install rpmlint yum-utils
After installing the packages I created the ~/rpmbuild directories and the ~/.rpmmacros file through this command:
$ rpmdev-setuptree
I made sure that these directories and file are created. Here are the screenshots:
RPM-writing Steps:
1) From the previous packages on build-from-source blog, I get the two packages I chose and moved it to ~/rpmbuild/SOURCES directory. The packages should be in tarball.
$ mv Downloads/units-2.02.tar.gz rpmbuild/SOURCES/
$ mv Downloads/radius-1.6.1.tar.gz rpmbuild/SOURCES/
2) Change directory to ~/rpmbuild/SOURCES
$ cd ~/rpmbuild/SOURCES
3) From this directory, I created an empty spec file for the packages
$ rpmdev-newspec units-2.02.tar.gz
$ rpmdev-newspec radius-1.6.1.tar.gz
4) Using vi, I edited the specfile and fill in the corresponding metadata.
After my first try, I received this errors.
Name: units-2.02.tar.gz
Version: 2.02
Release: 1%{?dist}
Summary: Converting units from one to another
License: GPLv3
URL: http://www.gnu.org/software/units
Source0: http://ftp.gnu.org/gnu/units/units-2.02.tar.gz
#BuildRequires:
#Requires:
$ rpmbuild -ba units-2.02.tar.gz.spec
error: File /home/jfgiagonia/rpmbuild/SOURCES is smaller than 13 bytes
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.NXTyCn
+ umask 022
+ cd /home/jfgiagonia/rpmbuild/BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ cd /home/jfgiagonia/rpmbuild/BUILD
+ rm -rf units-2.02.tar.gz-2.02
+ /usr/bin/tar -xf /home/jfgiagonia/rpmbuild/SOURCES
/usr/bin/tar: /home/jfgiagonia/rpmbuild/SOURCES: Cannot read: Is a directory
/usr/bin/tar: At beginning of tape, quitting now
/usr/bin/tar: Error is not recoverable: exiting now
error: Bad exit status from /var/tmp/rpm-tmp.NXTyCn (%prep)
RPM build errors:
File /home/jfgiagonia/rpmbuild/SOURCES is smaller than 13 bytes
Bad exit status from /var/tmp/rpm-tmp.NXTyCn (%prep)
Solution: removed the forward slashes from both source and URL. solution found on this forum. http://www.redhat.com/archives/fedora-packaging/2009-December/msg00020.html
After the fix, a new error came.
$ rpmbuild -ba units-2.02.tar.gz.spec
error: File /home/jfgiagonia/rpmbuild/SOURCES/units: No such file or directory
Solution: Change Source0 to: http://ftp.gnu.org/gnu/units/units-2.02.tar.gz
New error: Bad exit status from /var/tmp/rpm-tmp.nADFQG (%prep)
Solution: Change the name to just units
New errors:
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
Solution: Added the files onto the %files section. Found the solution on Jason Carman's blog.
After the last solution, the build was successful. the rpms were successfully placed on /rpmbuild/RPMS/x86_64/ and /rpmbuild/SRPMS/
TESTING THE BUILD:
Using the rpmlint -i command, I received a lot of errors. Some errors were about the changelog, %post and %postun entries (scriptlets), and invalid urls. Most of the solution were found in the blogs of my classmates. After fixing the errors all that is left were the warnings for the specfile and the two rpms. The Radius package was also successfully built and the process and the solutions were the same as the Units package.