RHEL / Fedora /CentOS Linux: Set RPM Build Environment

How do I set an rpm build environment on CentOS / RHEL / Red Hat Enterprise Linux version 6.x? How can I set rpm build environment on latest version of Fedora Linux?

You can setup a basic development environment. This includes the following tools:

=> Compilers such as GNU gcc compiler collection, bison, flex and others.Build tools such as make, autoconf, automake and others.

=> redhat-rpm-config – Red Hat specific rpm configuration files.

=> rpm-build – The rpm-build package contains the scripts and executable programs that are used to build packages using the RPM Package Manager.

You can install these tools with a single command. Open a terminal or login over the ssh session and type the following command as root user:
# yum groupinstall "Development tools"
$ sudo yum groupinstall "Development tools"
Sample outputs:


Create directories

You need to create directories for RPM building under your home directory such as /home/nixcraft. Open a terminal and type the following command:

 ## cd to $HOME, just in case ##
##  create dirs ##
mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
## add macros (site specific) ##
echo '%_topdir %(echo $HOME)/rpmbuild' >> ~/.rpmmacros
echo '%debug_package %{nil}' >> ~/.rpmmacros

A note about Fedora Linux users

You can create directories in your home directory is using fedora-rpmdevtools. This package is not avilable on CentOS / RHEL / SL version <= 6.x. If you are Fedora Linux user, enter: # yum -y install fedora-rpmdevtools
$ sudo yum -y install fedora-rpmdevtools
Login as a non-root user, and type the following command create rpmbuild directory:
$ fedora-buildrpmtree


Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Previous Post

How to Make Website WCAG Compliant?

Next Post

Link download Kali Linux 2020.1 (ISO + Torrent)

Related Posts