Building RPM packages at Rutgers

[ Return to main page ]

 

Process to create RPM package:

Step 1: Create the RPM SPEC file

Step 2: Test the package, fixing if needed

Step 3: GPG signing the package

Step 4: Placing the RPMs and sources on rpm.rutgers.edu

 

 

Step One: RPM SPEC files

To build an RPM package, one needs the original source code for the package and knowledge of how to compile the package. This document will only explain a simple build.

 

The SPEC file is made up of many parts, the first part describes what the software is and what it requires.

 

DESCRIPTIONS:

Summary: Sample program to make RPM package
Name: sample
Version: 3.0
Release: 1
Group: System Environment/Base
License: GPL
Source: %{name}-%{version}.tar.bz2
BuildRoot: %{_tmppath}/%{name}-root
Requires: thislibrary thatpackage
%description
This is a sample program, actually a sample spec file, as a quick tutorial on how to make an rpm package.

PREP/SETUP: These sections just un-gzip/bzip/tars the source file.

%prep
%setup -q

BUILD: Configures and makes the package

%build
PATH="/opt/SUNWspro/bin:${PATH}" \
CC="cc" CXX="CC" CPPFLAGS="-I/usr/local/include" \
LD="/usr/ccs/bin/ld" \
LDFLAGS="-L/usr/local/lib -R/usr/local/lib"
export PATH CC CXX CPPFLAGS LD LDFLAGS

./configure --prefix=/usr/local
gmake

INSTALL:

%install
rm -rf %{buildroot}
mkdir -p %{buildroot}
gmake install DESTDIR=%{buildroot}

POST: This gets run after the RPM is installed

%post
cat << EOF
You need to configure xxx by doing yyy.
EOF

CLEAN: Tells RPM to clean up the build root when done

%clean
rm -rf %{buildroot}

FILES: Describes which files to put in the package, and what permissions to give them

%files
%defattr(-, root, bin)
%doc YOUR_DOCUMENTATION
%attr(0755, root, bin) /usr/local/bin/yourbinary
%attr(0644, root, bin) /usr/local/man/man1/yourmanpage.1

CHANGELOG: Describes what has changed for each build of the package

%changelog
* Wed Aug 20 2008 "Packager Name" <"Packager Email"> - 3.0-1
- Initial build

IMPORTANT: The publish scripts will reject a package from "testing" if the spec file does not contain %files, %defattr, %doc, and %changelog. Such a package will not be rejected from "unstable", but a warning will be issued.

And that's all for a basic SPEC file. To build a package, put the source tarball in

/usr/local/src/rpm-packages/SOURCES

and then run

$ rpmbuild -ba sample.spec

You will see the progress of the build, and if successful the package will be placed in /usr/local/src/rpm-packages/RPMS

 

For more detailed reference, including patching, see the In-depth or External documentation linked from the main page.

 


STEP TWO: Test the package

Just install the package on a test machine (do not use the build machines for testing) and see if it works, use

# rpm -Uvh sample*rpm

 


STEP THREE: GPG Signing

Assuming that you have a valid GPG key on your system:

$ rpm --resign sample*rpm

 


STEP FOUR: Placing on rpm repository

You'll need to copy the RPMs, SPRMs, and sources to rpm.rutgers.edu. Please do not copy SPECs there, SVN is the correct place for SPEC files. Users in the studsys group can copy directly into the pending directory. If you had to use any patches to get the package to build, they should also placed in SVN, under the source-patches module.

scp <files> rpm:/rpm/CHECK_PEND.testing

The "testing" repository is where you want the file to go in most cases. Choices are "stable", "testing", and "unstable", but packages are generally never placed directly in "stable".

 


That's it!

The server has a daemon running that will automatically publish packages placed in the pending directories and email the owner the status of the publish.

 

 




[ Return to main page ]