I used "The Fight" over at FreshRPMS to learn. I am by no means an expert but I have a little repository going:
http://voidmain.is-a-geek.net/files/RPMS/
I hesitate to put anything large or popular out there as I don't really have the bandwidth. I'm thinking it would be nice if someone had some spare bandwidth and would let us create our own repository. Or maybe contribute to one of the existing repositories. It would be cool if we could all consolidate down to one giant reliable repository like Debian has.
I have a couple of suggestions about building RPMS that I think are important and I believe Matthias stresses in his document at FreshRPMS. The first thing is that you shouldn't be root when you build RPMS. I create a subdirectory tree under my home directory:
- Code: Select all
~/redhat/BUILD
~/redhat/RPMS
~/redhat/RPMS/athlon
~/redhat/RPMS/i386
~/redhat/RPMS/i486
~/redhat/RPMS/i586
~/redhat/RPMS/i686
~/redhat/RPMS/noarch
~/redhat/SOURCES
~/redhat/SPECS
~/redhat/SRPMS
Then I have a ~/.rpmmacros file that contains:
- Code: Select all
%packager Void Main
%distribution Void Main RPMS
%vendor voidmain.is-a-geek.net
%_signature gpg
%_gpg_name Void Main
%_topdir /home/voidmain/redhat
%_tmppath /var/tmp
%_rpmtopdir %{_topdir}
%_builddir %{_rpmtopdir}/BUILD
%_buildhost voidmain.is-a-geek.net
%_rpmdir %{_rpmtopdir}/RPMS
%_sourcedir %{_rpmtopdir}/SOURCES
%_srcrpmdir %{_rpmtopdir}/SRPMS
%_specdir %{_rpmtopdir}/SPECS
%_menudir /usr/lib/menu
%_iconsdir /usr/share/icons
%_miconsdir /usr/share/icons/mini
%_liconsdir /usr/share/icons/large
%debug_package %{nil}
Once you have your RPM building environment set up like above then install a few source RPMS and take a look at the spec files and see how they are put together. You can install source RPMS without being root with either the "rpm -i package.src.rpm" command or the "apt-get source package" command.
Some things I found easy as a starting point is to grab the very latest source for a package in tar.gz format and then grab the latest source RPM available (presuming the tar.gz is newer than than what you can find in RPM format) for that package. Install it "rpm -i package.src.rpm". You should find the original *.tar.gz (or *.tar.bz) source tarball in ~/redhat/SOURCES. Copy your new source tarball into the SOURCES directory and then edit the spec file for the package (found in ~/redhat/SPECS) and update all the version numbers and source tar ball file name in the spec file. Then build the new binary and source RPMS with this command in the SPECS directory:
$ rpmbuild -ba package.spec
This will create the binary RPM(s) in ~/redhat/RPMS/i386 (or whatever arch you are building for) and the new source RPM will end up in ~/redhat/SRPMS. You can view the contents of the package with the usual "rpm" commands like "rpm -qilp package.i386.rpm" or "rpm -qilp package.src.rpm".
I have built a few from scratch but not many. I have hacked Apache slightly and created a couple of my own *.patch files and included them in the spec file for my own custom Apache RPM (httpd-xxx.i386.rpm). That's fun stuff there (not meaning hard, but actually fun).
Some example patch files and spec files:
http://voidmain.is-a-geek.net/files/patches/
There are special sections you can put in the spec file where you can put code to be executed when the RPM is installed and when it is removed. This allows you to stop/start services, add/remove usernames, or any other system changes that may need to happen when you install or remove an RPM.
Once you get the hang of it it's really fun. Hopefully I can answer some of your questions if you have any. Also, hopefully I will learn more in the process because as I said, there is a lot more to know about building RPMs than what I know and I would like to get better at it. The next thing I really need to do is to sign all of my RPMS and put a GPG key out there for people to download/import. I haven't looked into what needs to be done for this but I don't believe it should be too hard.