To set up the RPM build environment on RHEL, Fedora, or CentOS, you need to install the rpm-build
package and a few other required packages. Here are the steps to set up the RPM build environment:
- Install the required packages:
sudo yum install rpm-build redhat-rpm-config rpmdevtools
- Create the RPM build directories:
rpmdev-setuptree
- Copy the source files to the appropriate build directories: Source files should be placed in the
~/rpmbuild/SOURCES
directory. - Create a
.spec
file: The.spec
file is used to specify the build instructions for the RPM. It should be placed in the~/rpmbuild/SPECS
directory. - Build the RPM:
rpmbuild -ba ~/rpmbuild/SPECS/package.spec
- Install the RPM:
sudo yum install ~/rpmbuild/RPMS/arch/package.rpm
Note: This is a basic example, and the actual steps may vary depending on your build requirements and the version of RHEL, Fedora, or CentOS you are using.