The spec file contains metadata, macro definitions and installation paths to the package. This information and instructions are divided into different sections, the % mark is used as separator.
The preamble describes the basic information about the package, e.g. name, version, release, license, etc.
The %description directive provides a longer, multi-line description of the package.
The %prep directive defines script commands to prepare the software before starting the creation process.
The %build directive defines the script commands for compiling the software in preparation for installation.
The %check directive sets script commands to self-check the program; these are executed after %build and before %install.
The %install directive defines script commands to install the binaries, for example with “make install”.
The %clean directive defines instructions on how to clean up the build root.
The %files directive contains a list of files of the package to be installed.
The %changelog directive lists the changes of the package.