Product SiteDocumentation Site

Creating an RPM build environment

If you start with the idea that you want to build RPMs for multiple versions of Linux, you can set up an RPM build environment that cleanly separates most vendor-specific issues.
The key issues with the build environment are:
*Detecting the vendors
*Using macros to define a clean build process
*Handling different dependencies

Detecting Vendors

To make a clean build environment, you need to be able to detect the Linux vendor and make build settings based on this vendor. To help with this, many Linux vendors install a special file with the vendor name, or a special package with the vendor name. You can query for either of these.
For files, the convention follows:
For example:
$ more /etc/redhat-release
Red Hat Linux release 8.0 (Psyche)
For packages, the convention is vendor-release for a package name. For example:
$ rpm -q redhat-release
You can use either approach or simply define a macro for the vendor and use the --define option to set the macro. For example:
# rpmbuild –ba --define 'linuxVendor suse'
With this definition, you can use the macro %linuxVendor inside your spec files. It is generally easier, though, if your scripts can automatically detect the Linux vendor instead of having to define it manually. The manual approach works, though, if it becomes too much effort to detect the vendor automatically.