Creating RPMS
Page by Page

Because the class is written in PDF format only, it is a bit hard to make notes and links and things. These notes are primarily for the students, but also good for the teacher.

Starting Out

Page 1

Page 2

Page 3

Page 4
rpm2cpio
To get all the files out using rpm2cpio you need to pipe it through cpio. An example would be
rpm2cpio glibc-2.3.2-95.6.i386.rpm | cpio -id

Page 5

Page 6
rpmquery (or rpm -q)
You can query rpm's that are not installed using all the query options. You just put a -p (for package) in the options. Example
rpm -qpl glibc-2.3.2-95.6.i386.rpm
You can have the output from a query be in a different format using the --qf (or --queryformat) option. You will need to then give it the format in printf type format. Examples
rpm -q --qf "%{name}-%{url}\n" nedit
rpm -qa --qf "%{size}\t%{name}\n" | sort -n
To find all the tags you can use, do 'rpm --querytags'

Page 7

Page 8

Page 9
yum grouplist | grep -i devel

Page 10
Do Lab 1 after this page.

Page 11

Page 12
Bookmark this page
Good instructions on patching

Page 13

Page 14

Page 15
Bookmark this page
Good instruction on making menu entries for the graphical desktop

The Spec File

Page 16

Page 17
Bookmark this page
Good overview of the rpm building workflow

Page 18
Defining macros in the spec file
To define a macro in the spec file you need to use the format
%define macro macro-setting
an example is
%define LDAP 0
This is explained more on page 33

Page 19
For full Macros list look at /usr/lib/rpm/macros

Page 20
Required Header Fields

Page 21
Do this page after doing page 32

Page 22

Page 23

Page 24
Hidden Gem - Accessing your Source files in the %install section
cp %{SOURCE3} $RM_BUILD_ROOT/usr/share/icons/

Page 25

Page 26
Do this page after doing page 32
Page is missing vital info.
Look at the triggers document that comes with rpm to find out the order that the various scripts get run in when doing an Upgrade
/usr/share/doc/rpm-4.3.3/triggers

  new-%pre	for new version of package being installed
  ...		(all new files are installed)
  new-%post	for new version of package being installed

  any-%triggerin (%triggerin from other packages set off by new install)
  new-%triggerin
  old-%triggerun
  any-%triggerun (%triggerun from other packages set off by old uninstall)

  old-%preun	for old version of package being removed
  ...		(all old files are removed)
  old-%postun	for old version of package being removed

  old-%triggerpostun
  any-%triggerpostun (%triggerpostun from other packages set off by old uninstall)

Because of the strange ordering, the %postun script usually should only be run when it is the final rpm being removed. This is done by doing the following in your %postun and/or %preun script
    %postun
	if [ "$1" == "0" ]; then
	    rm -f /tmp/all.my.temp.files
	fi
  

Page 27

Page 28

Page 29

Page 30

Page 31

Advanced Packaging

Page 32
Do Page 21
Do Page 26

Page 33

Page 34

Page 35

Page 36

Page 37

Page 38

Lab 1

Page 39
To save you having to type everything in, since it really doesn't have much to do with building and rpm, I have a script, or you can do a cut and paste from here.
download.labfiles.sh
mkdir labfiles
cd labfiles
wget http://www.gurulabs.com/GURULABS-RPM-LAB/ltris-1.0.4-2.src.rpm
wget http://www.gurulabs.com/GURULABS-RPM-LAB/lbreakout2-2.4.1.tar.gz
wget http://www.gurulabs.com/GURULABS-RPM-LAB/lbreakout2.spec-example
wget http://www.gurulabs.com/GURULABS-RPM-LAB/lbreakout2.spec-example2
wget http://www.gurulabs.com/GURULABS-RPM-LAB/nmap-3.70-1.src.rpm
wget http://www.gurulabs.com/GURULABS-RPM-LAB/nmap-3.81.tar.bz2
wget http://www.gurulabs.com/GURULABS-RPM-LAB/template.spec

Page 40

Page 41
To make this easier, and to give people a reference, here is how to create a rpm build area in your home area, as well as setup rpm to use that area when you are a user.
cd
mkdir -p rpmbuild/{SOURCES,SPECS,BUILD,SRPMS,RPMS}
mkdir rpmbuild/RPMS/{i386,i586,i686,noarch}
echo "%_topdir $HOME/rpmbuild" >> .rpmmacros
echo "%debug_package %{nil}" >> .rpmmacros

Page 42

Lab 2

Page 43

Page 44

Page 45

Page 46

Page 47

Page 48

Page 49

Page 50

Page 51

Lab 3

Page 52

Page 53

Page 54

Page 55

Page 56

Page 57

Page 58

Page 59

Page 60

Page 61

Page 62

Page 63

Page 64

Page 65

Page 66

Page 67

Page 68

Page 69

Page 70

Page 71

Page 72

Page 73

Page 74

Page 75

Page 76

Page 77

Page 78

Page 79

Lab 4

Page 80

Page 81

Page 82
When entering your e-mail address, make it something that you plan on lasting. So something like myname@fnal.gov would be good. Something like root@farmnode534.fnal.gov would be bad.

Page 83

Page 84

Page 85

Page 86