Building from Source RPM
From Bonsai
Contents |
More Information
These instructions are based on the JPackage Rebuilding Instructions.
Initial Setup
Before you can run rpmbuild, you need to setup a directory tree and a .rpmmacros file.
You may already have one in /usr/src/RPM, but as rebuilding packages as root is evil, we recommend that you create one in a place where your normal user account allows you to write, such as your home directory. This build tree should have the following structure:
rpm |-- BUILD |-- RPMS |-- SOURCES |-- SPECS |-- SRPMS `-- tmp
The following command should build what you need:
mkdir -p ${HOME}/rpm/{BUILD,RPMS,SOURCES,SPECS,SRPMS,tmp}
Now you need to do some rpm configuration. A simple ~/.rpmmacros with the following contents should be enough:
cat > ~/.rpmmacros <<EOF
%_topdir %(echo ${HOME}/rpm)
%_tmppath %{_topdir}/tmp
%packager Firstname Lastname <your.address@here>
# Have built RPMs land in RPMS/ instead of RPMS/<arch>/
%_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm
EOF
Installing the Source RPM
Make sure to complete the "Initial Setup" section first as the install step uses the .rpmmacros file and rpm tree you created.
Download the source rpm to /tmp.
Install the rpm, you do not want or need to be root for this command.
rpm -U /tmp/xxx-yyy.src.rpm
The installation should have deposited a spec file in ${HOME}/rpm/SPECS and a bunch of source files in ${HOME}/rpm/SOURCES.
Building the Package
Change directories to the rpm/SPECS subdirectory.
cd ${HOME}/rpm/SPECS
Optionally edit spec file, append an OS version release suffix to the "Release:" entry. It should looke like this if you were building for Enterprise Linux 3, for example:
Release: 5.EL3
Kick off the build:
rpmbuild -bb packagename.spec
Some packages take quite a while to build.
Harvesting the Binary RPM
When the build completes, the binary rpms are deposited in rpm/RPMS.
ls -lart ${HOME}/rpm/RPMS
Enjoy!
Please let me know if there are issues/problems/confusion with these directions.
--Ken Sedgwick 21:01, 7 August 2006 (PDT)
