initCommon(); $template->displayHeader(); ?>

22.3. Build Sections

After providing information about the package, you need to define the build stages, as described in Chapters 10 and 12.

22.3.1. Build preparation

The build preparation section sets the stage for the build. Usually this section has a %setup command. For example:

%prep

%setup -q

22.3.2. Build

The build section describes how to build the library or application. In most cases, the majority of the instructions are in the Makefile created by the prep section, leaving a build section something like the following:

%build

%configure

make

22.3.3. Installation

After building, the installation section holds the commands to install the library or application. For example:

%install

rm -rf %{buildroot}

%makeinstall

22.3.4. Clean up

The clean up section usually calls the make clean command to clean up the built files. For example:

%clean

rm -rf %{buildroot}

22.3.5. Install and uninstall scripts

RPM packages can run scripts prior to installation with %pre, and after installation with %post. You can also run scripts prior to an uninstall with %preun and after an uninstall with %postun. For example:

%post

/sbin/chkconfig --add ypbind

%preun

if [ "$1" = 0 ] ; then

/sbin/service ypbind stop > /dev/null 2>&1

/sbin/chkconfig --del ypbind

fi

exit 0

%postun

if [ "$1" -ge 1 ]; then

/sbin/service ypbind condrestart > /dev/null 2>&1

fi

exit 0

displayFooter('$Date: 2005/11/02 19:30:07 $'); ?>