| LPMtool - LPMtool is a Package Management tool | ||
|---|---|---|
| <<< Previous | Next >>> | |
lpbuild is a tool that creates installable package files. lpbuild reads a package specification file, a specfile, which is a collection of shell scripts and configuration directives that describe the application. The shell scripts take the application's source, compile, and build it, after which lpbuild takes over and generates the package archive files that make up the application, which are then subsequently installed by lpm.
A specfile may contain instructions for creating multiple, related installable packages. It is common to have more than one package file created at the same time. A complex application typically consists of the main package, and additional sub-packages that contain optional components.
The specfile contains fragments of shell scripts that compile and install the application into a temporary staging area, called an "installation image" (see Section 7.7). The specfile also contains additional information about the package that lpbuild needs to know. This chapter describes the format of the specfile.
The following sample specfile provides an example of its major components:
Name: testpackage # Package name.
Version: 1
Release: 1
Source: test-1.tar.gz
Repository(pgpkeys.txt): http://www.example.com/repository
%package
Requires: glibc
This is a test package.
%package doc
Documentation for the <b>test</b> package.
%begin
%setup
%begin build
%{__make}
cc -o hello hello.c
%begin install
%{__make} install DESTDIR="$__installdir"
%post
/sbin/ldconfig
%postun
/sbin/ldconfig
%files
%{_bindir}/*
%{_libdir}/*
%files doc
%doc README NEWS COPYING |
The specfile has a well-defined, structured layout. It begins with the "build header" section. The build header runs from the beginning of the specfile until the first "%package" section. The build header provides the general information about this application.
The build header is followed by one or more package declaration sections. Each package declaration begins with the "%package" line. Simple applications will only one package declaration. Large, complex, applications that consists of a main package, and subpackages, will have additional "%package" lines, one for each subpackage.
The build header, and the package sections, contain all the information lpbuild needs to begin building the application. After the package sections comes the shell script, or scripts, that actually build the application and install it into a temporary staging area, an installation image tree. The "%begin" line marks the beginning of each shell script. lpbuild runs the system's shell interpreter to execute the shell script. The shell scripts should unpack the source code, compile it and install it.
Only one "%begin" section is required, but usually there's more than one. Multiple "%begin" sections are very useful when developing the specfile itself. The process of building and installing an application is rarely straightforward. It is nearly impossible to create a complete specfile from scratch, in one shot. Multiple "%begin" sections allow a specfile's construction one step at a time. By default, lpbuild executes each "%begin" section, one after the other. Optional command line parameters can instruct lpbuild to run only a specific, single, "%begin" section, allowing individual portions of the overall build script to be debugged, one piece at a time.
The "%begin" sections are ordinarily scripts, which are executed by /bin/sh, except that lpbuild does macro expansion on each shell script, before it gets executed. Macros, like "%{name}" are explained later in Section 7.12.
The specfile ends with one or more file manifest sections. These sections contain an explicit manifest of files that the shell scripts placed in the installation image directory. Although the application gets installed in a separate, dedicated directory, an explicit file list is still required. Furthermore, there will be additional %files sections when subpackages are built. A separate %files section appears for the main package and each subpackage.
| <<< Previous | Home | Next >>> |
| Package files | The build header |