For me I chose to package Irssi a text based irc client.
My reference source through out this process was off the Fedora Wiki site and also from my prefessor Chris
To start, we would actually need to create a directory where all our packing setup would be kept. The command to do so is "rpmdev-setuptree" and a rpmbuild directory will be made on your home directory
As well we would also need to get the tarball file of the package we want to create an rpm for and then place it in the rpmbuild/SOURCES directory
Next we would need to create a spec file, which is a file that contains a set of instructions to create an rpm. To create an empty spec file the command we would use is "rpmdev-newspec 'package name'
You would later have to move that to your rpmbuild/SPECS directory once you have finished setting up your spec file .
In your spec file you need to completed all the necessary containers i.e.
- preamble - basic metadata**
- %prep - commands to prepare the package for building**
- %build - commands to build the package**
- %install - commands to install the built files**
- %check - commands to check/test the built files (optional, often not included)**
- %clean - commands to clean up the disk space**
- %files - list of files to be included in the pacakge**
- %changelog - record of the package's change-history**
After you complete your spec file and placed it in the proper directory ,your directory structure should look like this
After moving your spec file in the right directory, you would need to test it out to see if there are any errors in the file when you were creating it.
The command for that is "rpmlint 'spec file'
If there were any errors it will report it at the bottom for me it was successful

When you have successfully checked your spec file, build your spec file with the following command
rpmbuild -ba 'spec file'
If your build is perfect you can move on to the next step if not correct your spec file and rebuild till it successfully finishes. For me it failed the first two times because I forgot to place some important directory locations in the spec file which caused it to fail. I fixed the issue by placing the proper parameter under the %files container
After the rebuild, your tree structure should resemble this or close to this

To check if your RPMS are working correctly you would use the mock command
the syntax would be mock -
"mock -r 'system architecture*'
*i.e. fedora-11-x86_64
Source rpm would be found in the rpmbuild/SRPM. To find what architecture you are running is to check your /etc/mock with this command ls /etc/mock. For me, since I am using the Scotland machine my fedora-10-x86_64
For me the process failed.

So I asked Chris and he explained to me to check the build result log, and apparently I was missing some lines in my spec file regarding build requirements line. I had to add glib2-devel and pckconfig.
Instead of rebuilding the spec file, I used mock on the srcrpm and I spent about 1/2 hour till I remembered I needed to rebuild my spec file.
After rebuilding my spec file and re-issuing the mock command, it told me I had it had successfully checked my rpm and it was error free.

After tearing out my hair for half an hour, try to mock build a source RPM i forgot to rebuild from spec, I finally remembered, and finally success, perfect no error rpm. What a headache it was trying to figure out whats wrong, changing the spec file all the time, without rebuilding the source. Oh well, it was a lesson I will not forget.
Here is my finished RPM
Boy this was a long blog...my bad = P

0 comments:
Post a Comment