Scripts

This section lists the various scripts found in a spec file.

Build-time Scripts

Every build-time script has the following environment variables defined:

For more information on these environment variables, and build-time scripts in general, please see the section called Build-time Scripts in Chapter 13.

The %prep Script

The %prep script is the first script RPM executes during a build. As the name implies, it is normally used to prepare the sources for building. The commands in the script can be any valid sh commands.
%prep
          

See also: the section called The %prep Script in Chapter 13.

The %build Script

The %build script is the second script RPM executes during a build. As the name implies, it is normally used to build the software. The commands in the script can be any valid sh commands.
%build
          

See also: the section called The %build Script in Chapter 13.

The %install Script

The %install script is the third script RPM executes during a build. As the name implies, it is normally used to install the software. The commands in the script can be any valid sh commands.
%install
          

See also: the section called The %install Script in Chapter 13.

The %clean Script

The %clean script, as the name implies, is used to clean up the software's build directory tree. RPM will normally do this for you, but in certain cases (most notably in those packages that use a build root) you'll need to include a %clean script. The commands in the script can be any valid sh commands.
%clean
          

See also: the section called The %clean Script in Chapter 13.

Install-/Erase-time Scripts

These scripts are executed whenever the package is installed or erased. Each script can consist of any valid sh commands.

Note: Each of the following scripts can be made specific to a particular subpackage by adding the subpackage name, and optionally, the -n option:
%post bar

%preun -n bar
        

The subpackage name and usage of the -n option must match those defined with the %package directive.

Each script has the following environment variable defined:

For more information on this environment variable please see the section called Install/Erase-time Scripts in Chapter 13.

The %pre Script

The %pre script executes just before the package is to be installed.
%pre
          

See also: the section called The %pre Script in Chapter 13.

The %post Script

The %post script executes just after the package is to be installed.
%post
          

See also: the section called The %post Script in Chapter 13.

The %preun Script

The %preun script executes just before the package is to be erased.
%preun
          

See also: the section called The %preun Script in Chapter 13.

The %postun Script

The %postun script executes just after the package is to be erased.
%postun
          

See also: the section called The %postun Script in Chapter 13.

Verification Script

This section describes the verification script.

The %verifyscript Script

The %verifyscript script executes whenever the package is verified using RPM's -V option. The script can consist of any valid sh commands.

See also: the section called Verification-Time Script — The %verifyscript Script in Chapter 13.