
You may need to create the following directories to make a build tree:
BUILD is the directory where all building occurs by RPM. You don't have to do your test building anywhere in particular, but this is where RPM will do it's building.
SOURCES is the directory where you should put your original source tar files and your patches. This is where RPM will look by default.
SPECS is the directory where all spec files should go.
RPMS is where RPM will put all binary RPMs when built.
SRPMS is where all source RPMs will be put.
diff -uNr dirname.orig dirname > ../SOURCES/dirname-linux.patch
|
This will create a patch for you that you can use in your spec file. Note that the "linux" that you see in the patch name is just an identifier. You might want to use something more descriptive like "config" or "bugs" to describe why you had to make a patch. It's also a good idea to look at the patch file you are creating before using it to make sure no binaries were included by accident.
rpm -ba foobar-1.0.spec
|
There are other options useful with the -b switch as well:
p means just run the prep section of the specfile.
l is a list check that does some checks on %files.
c do a prep and compile. This is useful when you are unsure of whether your source will build at all. It seems useless because you might want to just keep playing with the source itself until it builds and then start using RPM, but once you become accustomed to using RPM you will find instances when you will use it.
ido a prep, compile, and install.
b prep, compile, install, and build a binary package only.
abuild it all (both source and binary packages).
There are several modifiers to the -b switch. They are as follows:
--short-circuit will skip straight to a specified stage (can only be used with c and i).
--clean removes the build tree when done.
--keep-temps will keep all the temp files and scripts that were made in /tmp. You can actually see what files were created in /tmp using the -v option.
--test does not execute any real stages, but does keep-temp.
You can do an rpm -e packagename on the package to test, but that can be deceiving because in building the package, you did a make install. If you left something out of your file list, it will not get uninstalled. You'll then reinstall the binary package and your system will be complete again, but your rpm still isn't. Make sure and keep in mind that just because you do a rpm -ba package, most people installing your package will just be doing the rpm -i package. Make sure you don't do anything in the build or install sections that will need to be done when the binaries are installed by themselves.
Once you've made your own RPM of something (assuming its something that hasn't already been RPM'ed), you can contribute your work to others (also assuming you RPM'ed something freely distributable). To do so, you'll want to upload it to ftp.redhat.com.