PackageBuildingRPM

From GSLUG

Jump to: navigation, search

Notes and links from GSLUG talk given at the Sep 12, 2009 meeting

Building RPMs 3 different ways

Contents

Preparation

Satisfy pre-requisites

  • Installl RPMs for gcc, make, rpm-build etc.
sudo yum groupinstall 'Development Tools'
sudo yum install screen openssl-devel newt-devel pcre-devel libpcap-devel cups-devel \
readline-devel postgresql-devel libxml2-devel cyrus-sasl-devel \
gdbm-devel pam-devel libacl-devel libattr-devel openldap-devel \
apr-util-devel byacc flex  gtk2-devel xorg-x11-devel kernel-smp-devel \
createrepo repoview
  • Setup Folder structure (or use /usr/src/redhat)
mkdir -p redhat/{SPECS,RPMS,SRPMS,SOURCES,BUILD}
  • Setup .rpmmacros
 %_topdir     /home/mdf/redhat
 %_rpmfilename   %%{ARCH}/%%{NAME}-%%{VERSION}-%%{RELEASE}.el5.%%{ARCH}.rpm
 %_unpackaged_files_terminate_build 0
 %_missing_doc_files_terminate_build 0

Execution

Method 1

Compile from a "Source RPM" (SRPM)

cd ~/redhat/SRPMS
wget http://nmap.org/dist/nmap-5.00-1.src.rpm
rpmbuild --rebuild nmap-5.00-1.src.rpm

Method 2

Using a custom SPEC file

cd ~/redhat/SOURCES
wget http://dns.measurement-factory.com/tools/dnstop/src/dnstop-20070105.tar.gz
cd ../SPECS
(copy spec file into place) cp -f ~/rpmbuilding/dnstop.spec .
rpmbuild -bb dnstop.spec


Method 3

Using a bundled SPEC file. This command finds a .spec file embedded in a source tarball.

rpmbuild -tb TARBALL

Extras

1. Bundle RPMS into a "repo"

cd ~/redhat/RPMS
createrepo -v .

now rsync it somewhere accessible via ftp/web/nfs

2. Use repoview to publish your RPM repo to the web

repoview -f --template-dir=/share2/redhat/PUB/templates \
-t 'Centos-5 i386 Packages by mdf' .

now rsync it somewhere accessible via web

3. Put your redhat/ folder on a fileserver, mount from various build boxes

This enables building for different distros e.g. fedora 9, rhel4, centos3

Personal tools
Linux