Product SiteDocumentation Site

Creating Non-Linux RPMS

Once you have RPM set up on a system, you should be able to create RPMs using the rpmbuild command on that system.
Warning
Do not build RPM packages logged in as a root or Administrator user. If something goes wrong, rpmbuild could destroy files in your system. Remember that spec files can define a number of commands and shell scripts. Any of these could have an error that could cause major damage when run as a root user.
Before building RPMs with the rpmbuild command, though, you may want to customize the build environment to better reflect your system. You may also find it is too difficult to build most RPMs on the non-Linux system and instead focus on cross-building packages, should the rpmbuild command not work on the target systems.
This section covers topics related to building RPMs on or for non-Linux systems.

Setting up a build environment

In RPM terms, your build environment consists of the directories where you build RPMs, as well as the rc and macro settings that define all of the variables in an RPM-based system. To set up your build environment, you need to ensure that all the rc and macro settings reflect the true environment on your non-Linux system.
The rpm --showrc command, discussed previously in the "Creating the RPM Environment" section, lists the settings for your system. You can use this command to verify all the settings.
You may want to change some settings, such as the top directory where RPMs are built. By default, this setting is something like the following:
_topdir %{_usrsrc}/redhat
Cross Reference
See Chapter 20, Customizing RPM Behavior for more on how to customize the rc and macro settings.
In most cases the _topdir setting on Red Hat Linux systems map to the /usr/src/redhat directory. Your system may not even have a /usr/src directory. Also you may not want to build RPMs in a redhat directory, which may cause confusion if you are building on a non-Red Hat Linux system.
Cross Reference
See Chapter 18, Using RPM on Non-Red Hat Linuxes for more information on setting up a build environment for RPMs. Chapter 18, Using RPM on Non-Red Hat Linuxes focuses on other Linux systems, but many of the same techniques apply.
With a build environment set up, you should be able to create RPMs with the rpmbuild command. If this doesn’t work, or is too difficult, then you can try cross-building packages.