Thursday, December 3, 2009

CREATING RPM PACKAGES

I started working on Creating Packages and I have successfully done it taking the following steps:-
Before I start creating the rpm packages, I need to install some important tools and set up the account I will use. Then as a root, I executed the following commands:-
$ yum groupinstall "Development Tools"
$ yum install rpmdevtools
Secondly, I created a user specifically for working on the RPM packages. I am doing this because if something takes place wrongly the program or build process could not infiltrate my files, or expose my private files to the world. Actually, I should never create my packages as a user root.So, I create a user executing this command:-
$ /usr/sbin/useradd mjadenrpm.
Then I logged as mjadenrpm user who is creating the rpm packages, and created the directory structure in my home directory by running this command:-
$rpmdev-setuptree
The rpmdev-setuptree program will create an rpmbuild directory in my $HOME directory.
Now I am ready to create netcat package program. Firstly, I run this commad:
$yumdownloader --source netcat_src_rpm
Then once I have the source RPM, executing the following command installs the src.rpm
$ rpm ivh netcat-0.7.1-1.src.rp

This command places the package's .spec file into ~/rpmbuild/SPECS and other sources and patch files(if there is) in ~/rpmbuild/SOURCES.

Now I have to create the spec file for the netcat package.
$ cd ~/rpmbuild/SPECS
$ vi netcat.spec
netcat.spec

Creating RPMS from the spec file
Once I have done the spec file, netcat.spec, I can create source and binary RPMS by simply executing this command:
$ rpmbuild -ba netcat.spec
If I cd to the ~/rpmbuild/RPMS directory, and then change directory to the architecture subdirectory, I will find some binary rpms. Then to see quickly the files and their permissions in this subdirectory, I can run this command:
$ rpmls *.rpm
To see if there is any errors within the .spec files, binary RPMs, and source RPMs, I run this command:
$ rpmlint *rpm
If this works without problems, I run this command:
$ rpm -ivp netcat*.rpm
If this goes well with no errors at all, I can use Mock to do a rigorous test that I have accurate build requirements. See [[PackageMaintainers/MockTricks]] for more information about how to use Mock; once my account is a member of the "mock" group, you can run commands like this to do local testing:
$ mock -r fedora-9-i386 rebuild path_to_source_RPM

Once I have Mock worked on my system, I used Koji to do package buildings on different systems.
UsingKoji have more information about koji.
After setting up the koji, I tested my source RPM by executing this command:-
$ koji build --scratch dist-f10 netcat-0.7.1-1.fc10.src.rpm

No comments:

Post a Comment