12.07.2015 Views

Red Hat Enterprise Linux 5 Administration Unleashed

Red Hat Enterprise Linux 5 Administration Unleashed

Red Hat Enterprise Linux 5 Administration Unleashed

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Building RPM Packages 137such as your user account or perhaps a special user account set up for building RPM. Thisis to make sure the build process does not accidentally corrupt the filesystem or overwritecritical files owned by root. A small error in a script can do unintentional damage thatmight be irreversible.To set up build directories for your own personal use, create a .rpmmacros file in yourhome directory with the contents from Listing 5.7, replacing with your username.This file must be created by each user building packages.LISTING 5.7~/.rpmmacros File%_topdir /home//RPMBUILDThe line in Listing 5.7 defines the directory to use when building the RPM files. You needto create this directory and some additional subdirectories. Change into your home directoryand then execute the following commands:mkdir RPMBUILDmkdir -p RPMBUILD/{BUILD,RPMS/x86_64,SOURCES,SRPMS,SPECS}The command assumes you are using a x86_64 system. RPMs build for the x86_64 architectureare saved to the /home//RPMBUILD/RPMS/x86_64/ directory. If you needto build RPMs for different architectures compatible with your system such as the noarchor i386 architectures on an x86_64 system, create directories for them as well. The directorynames should be the same as the RPM architecture abbreviations in Table 5.1. In ourexample, the RPMBUILD/RPMS/noarch/ directory must be created since the examplepackage is a noarch RPM.5TIPAdditional macros can be defined in the .rpmmacros file. Refer to /usr/lib/rpm/macros file for a full list. For example, if you want to save the SRPMs in a differentdirectory, you can add the following line to your .rpmmacros file:%_srcrpmdir /home//SRPMSThe .rpmmacros file and the build directories only need to be created once. After that,your build environment is set up for any RPMs and SRPMs you need to create.Creating the Spec FileBuilding a package requires a package specification file (often called a spec file for short)and the files to be included in the package. For example, you might want to package acustom VPN script used by laptop users to connect to the company’s private networkwhile traveling or working from home. The name of the script is called startvpn. EveryVPN solution is a bit different, so for the purpose of this example, use Listing 5.8 for thecontents of this script. It does not actually start a VPN, but it does display a message sothat we can test our RPM file.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!