6. Build scripts

The largest part of a specfile is the shell script that builds the package. LPMtool does not build an application directly. The specfile provides a shell script that does that.

The process of building an application, from source code, varies with each application, but it usually consists of the following, general steps:

Try to follow this general outline when creating a new specfile for an application. A %begin line should mark the beginning of the shell script that corresponds to each part of the build process. Each shell script should have a short name, which is given after the %begin. A %begin without a name gets a name called setup, this is usually the very first shell script in a specfile. By convention, the other shell scripts should be called build and install (as offered in the sample specfile from the beginning of Chapter 7, Building packages), but the names are purely arbitrary.

lpbuild automatically creates several work directories, when processing the specfile. The first work directory is allocated for the unpacked source code, and a second work directory is allocated for the installation image. The actual location of the work directory is not very important. LPMtool takes care of creating this directory, and removing it after the application package files are built.

By default, lpbuild runs each %begin script from specfile, one after another.

Note

Each %begin starts out with the current directory being reset to the top of the source code work directory. If the shell script changes the current directory to someplace else, it will be reset at the beginning of the next %begin script.

If %setup macros are used (see Section 13.4, “Predefined macros”) the first %setup macro resets the initial directory to the main source subdirectory. All subsequent %begin scripts will start from the main source subdirectory.

By default, lpbuild creates the work directories before executing the first %begin script. After the last %begin script completes successfully, the package files are created, and the work directories are automatically deleted. lpbuild has an option that runs a single %begin script only, without deleting the temporary work directories. This provides for incremental development and debugging of a new specfile.