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:
Tutorial details
Difficulty level Intermediate
Root privileges Yes
Requirements RHEL/CentOS/Fedorayum
Est. reading time N/A
=> 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"
OR
$ sudo yum groupinstall "Development tools"
Sample outputs:

Loaded plugins: downloadonly, fastestmirror, security
Loading mirror speeds from cached hostfile
 * base: mirrors.gigenet.com
 * extras: mirror.sanctuaryhost.com
 * updates: mirrors.cat.pdx.edu
Setting up Group Process
Checking for new repos for mirrors
Package 1:pkgconfig-0.23-9.1.el6.x86_64 already installed and latest version
Package binutils-2.20.51.0.2-5.36.el6.x86_64 already installed and latest version
Package elfutils-0.152-1.el6.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package autoconf.noarch 0:2.63-5.1.el6 will be installed
---> Package automake.noarch 0:1.11.1-4.el6 will be installed
---> Package bison.x86_64 0:2.4.1-5.el6 will be installed
---> Package byacc.x86_64 0:1.9.20070509-7.el6 will be installed
---> Package cscope.x86_64 0:15.6-6.el6 will be installed
---> Package ctags.x86_64 0:5.8-2.el6 will be installed
---> Package cvs.x86_64 0:1.11.23-15.el6 will be installed
---> Package diffstat.x86_64 0:1.51-2.el6 will be installed
---> Package doxygen.x86_64 1:1.6.1-6.el6 will be installed
---> Package flex.x86_64 0:2.5.35-8.el6 will be installed
---> Package gcc.x86_64 0:4.4.7-3.el6 will be installed
--> Processing Dependency: libgomp = 4.4.7-3.el6 for package: gcc-4.4.7-3.el6.x86_64
--> Processing Dependency: cpp = 4.4.7-3.el6 for package: gcc-4.4.7-3.el6.x86_64
--> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc-4.4.7-3.el6.x86_64
--> Processing Dependency: cloog-ppl >= 0.15 for package: gcc-4.4.7-3.el6.x86_64
--> Processing Dependency: libgomp.so.1()(64bit) for package: gcc-4.4.7-3.el6.x86_64
---> Package gcc-c++.x86_64 0:4.4.7-3.el6 will be installed
--> Processing Dependency: libstdc++-devel = 4.4.7-3.el6 for package: gcc-c++-4.4.7-3.el6.x86_64
--> Processing Dependency: libmpfr.so.1()(64bit) for package: gcc-c++-4.4.7-3.el6.x86_64
---> Package gcc-gfortran.x86_64 0:4.4.7-3.el6 will be installed
--> Processing Dependency: libgfortran = 4.4.7-3.el6 for package: gcc-gfortran-4.4.7-3.el6.x86_64
--> Processing Dependency: libgfortran.so.3()(64bit) for package: gcc-gfortran-4.4.7-3.el6.x86_64
---> Package gettext.x86_64 0:0.17-16.el6 will be installed
---> Package git.x86_64 0:1.7.1-3.el6_4.1 will be installed
--> Processing Dependency: perl-Git = 1.7.1-3.el6_4.1 for package: git-1.7.1-3.el6_4.1.x86_64
--> Processing Dependency: perl(Git) for package: git-1.7.1-3.el6_4.1.x86_64
--> Processing Dependency: perl(Error) for package: git-1.7.1-3.el6_4.1.x86_64
---> Package indent.x86_64 0:2.2.10-7.el6 will be installed
---> Package intltool.noarch 0:0.41.0-1.1.el6 will be installed
--> Processing Dependency: perl(XML::Parser) for package: intltool-0.41.0-1.1.el6.noarch
--> Processing Dependency: gettext-devel for package: intltool-0.41.0-1.1.el6.noarch
---> Package libtool.x86_64 0:2.2.6-15.5.el6 will be installed
---> Package make.x86_64 1:3.81-20.el6 will be installed
---> Package patch.x86_64 0:2.6-6.el6 will be installed
---> Package patchutils.x86_64 0:0.3.1-3.1.el6 will be installed
---> Package rcs.x86_64 0:5.7-37.el6 will be installed
---> Package redhat-rpm-config.noarch 0:9.0.3-42.el6 will be installed
---> Package rpm-build.x86_64 0:4.8.0-32.el6 will be installed
--> Processing Dependency: /usr/bin/gdb-add-index for package: rpm-build-4.8.0-32.el6.x86_64
---> Package subversion.x86_64 0:1.6.11-9.el6_4 will be installed
--> Processing Dependency: perl(URI) >= 1.17 for package: subversion-1.6.11-9.el6_4.x86_64
--> Processing Dependency: apr >= 1.3.0 for package: subversion-1.6.11-9.el6_4.x86_64
--> Processing Dependency: libneon.so.27()(64bit) for package: subversion-1.6.11-9.el6_4.x86_64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: subversion-1.6.11-9.el6_4.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: subversion-1.6.11-9.el6_4.x86_64
---> Package swig.x86_64 0:1.3.40-6.el6 will be installed
---> Package systemtap.x86_64 0:1.8-7.el6 will be installed
--> Processing Dependency: systemtap-devel = 1.8-7.el6 for package: systemtap-1.8-7.el6.x86_64
--> Processing Dependency: systemtap-client = 1.8-7.el6 for package: systemtap-1.8-7.el6.x86_64
--> Running transaction check
---> Package apr.x86_64 0:1.3.9-5.el6_2 will be installed
---> Package apr-util.x86_64 0:1.3.9-3.el6_0.1 will be installed
---> Package cloog-ppl.x86_64 0:0.15.7-1.2.el6 will be installed
--> Processing Dependency: libppl_c.so.2()(64bit) for package: cloog-ppl-0.15.7-1.2.el6.x86_64
--> Processing Dependency: libppl.so.7()(64bit) for package: cloog-ppl-0.15.7-1.2.el6.x86_64
---> Package cpp.x86_64 0:4.4.7-3.el6 will be installed
---> Package gdb.x86_64 0:7.2-60.el6_4.1 will be installed
---> Package gettext-devel.x86_64 0:0.17-16.el6 will be installed
--> Processing Dependency: gettext-libs = 0.17-16.el6 for package: gettext-devel-0.17-16.el6.x86_64
--> Processing Dependency: libgettextpo.so.0()(64bit) for package: gettext-devel-0.17-16.el6.x86_64
--> Processing Dependency: libgcj_bc.so.1()(64bit) for package: gettext-devel-0.17-16.el6.x86_64
--> Processing Dependency: libasprintf.so.0()(64bit) for package: gettext-devel-0.17-16.el6.x86_64
---> Package glibc-devel.x86_64 0:2.12-1.107.el6 will be installed
--> Processing Dependency: glibc-headers = 2.12-1.107.el6 for package: glibc-devel-2.12-1.107.el6.x86_64
--> Processing Dependency: glibc-headers for package: glibc-devel-2.12-1.107.el6.x86_64
---> Package libgfortran.x86_64 0:4.4.7-3.el6 will be installed
---> Package libgomp.x86_64 0:4.4.7-3.el6 will be installed
---> Package libstdc++-devel.x86_64 0:4.4.7-3.el6 will be installed
---> Package mpfr.x86_64 0:2.4.1-6.el6 will be installed
---> Package neon.x86_64 0:0.29.3-2.el6 will be installed
--> Processing Dependency: libpakchois.so.0()(64bit) for package: neon-0.29.3-2.el6.x86_64
---> Package perl-Error.noarch 1:0.17015-4.el6 will be installed
---> Package perl-Git.noarch 0:1.7.1-3.el6_4.1 will be installed
---> Package perl-URI.noarch 0:1.40-2.el6 will be installed
---> Package perl-XML-Parser.x86_64 0:2.36-7.el6 will be installed
--> Processing Dependency: perl(LWP) for package: perl-XML-Parser-2.36-7.el6.x86_64
---> Package systemtap-client.x86_64 0:1.8-7.el6 will be installed
---> Package systemtap-devel.x86_64 0:1.8-7.el6 will be installed
--> Processing Dependency: kernel-devel for package: systemtap-devel-1.8-7.el6.x86_64
--> Running transaction check
---> Package gettext-libs.x86_64 0:0.17-16.el6 will be installed
---> Package glibc-headers.x86_64 0:2.12-1.107.el6 will be installed
--> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers-2.12-1.107.el6.x86_64
--> Processing Dependency: kernel-headers for package: glibc-headers-2.12-1.107.el6.x86_64
---> Package kernel-devel.x86_64 0:2.6.32-358.6.2.el6 will be installed
---> Package libgcj.x86_64 0:4.4.7-3.el6 will be installed
--> Processing Dependency: libart_lgpl >= 2.1.0 for package: libgcj-4.4.7-3.el6.x86_64
--> Processing Dependency: libXtst.so.6()(64bit) for package: libgcj-4.4.7-3.el6.x86_64
--> Processing Dependency: libSM.so.6()(64bit) for package: libgcj-4.4.7-3.el6.x86_64
--> Processing Dependency: libICE.so.6()(64bit) for package: libgcj-4.4.7-3.el6.x86_64
---> Package pakchois.x86_64 0:0.4-3.2.el6 will be installed
---> Package perl-libwww-perl.noarch 0:5.833-2.el6 will be installed
--> Processing Dependency: perl-HTML-Parser >= 3.33 for package: perl-libwww-perl-5.833-2.el6.noarch
--> Processing Dependency: perl(HTML::Entities) for package: perl-libwww-perl-5.833-2.el6.noarch
--> Processing Dependency: perl(Compress::Zlib) for package: perl-libwww-perl-5.833-2.el6.noarch
--> Processing Dependency: mailcap for package: perl-libwww-perl-5.833-2.el6.noarch
---> Package ppl.x86_64 0:0.10.2-11.el6 will be installed
--> Running transaction check
---> Package kernel-headers.x86_64 0:2.6.32-358.6.2.el6 will be installed
---> Package libICE.x86_64 0:1.0.6-1.el6 will be installed
---> Package libSM.x86_64 0:1.2.1-2.el6 will be installed
---> Package libXtst.x86_64 0:1.2.1-2.el6 will be installed
---> Package libart_lgpl.x86_64 0:2.3.20-5.1.el6 will be installed
---> Package mailcap.noarch 0:2.1.31-2.el6 will be installed
---> Package perl-Compress-Zlib.x86_64 0:2.020-131.el6_4 will be installed
--> Processing Dependency: perl(IO::Uncompress::Gunzip) >= 2.020 for package: perl-Compress-Zlib-2.020-131.el6_4.x86_64
--> Processing Dependency: perl(IO::Compress::Gzip::Constants) >= 2.020 for package: perl-Compress-Zlib-2.020-131.el6_4.x86_64
--> Processing Dependency: perl(IO::Compress::Gzip) >= 2.020 for package: perl-Compress-Zlib-2.020-131.el6_4.x86_64
--> Processing Dependency: perl(IO::Compress::Base::Common) >= 2.020 for package: perl-Compress-Zlib-2.020-131.el6_4.x86_64
--> Processing Dependency: perl(Compress::Raw::Zlib) >= 2.020 for package: perl-Compress-Zlib-2.020-131.el6_4.x86_64
---> Package perl-HTML-Parser.x86_64 0:3.64-2.el6 will be installed
--> Processing Dependency: perl(HTML::Tagset) >= 3.03 for package: perl-HTML-Parser-3.64-2.el6.x86_64
--> Processing Dependency: perl(HTML::Tagset) for package: perl-HTML-Parser-3.64-2.el6.x86_64
--> Running transaction check
---> Package perl-Compress-Raw-Zlib.x86_64 1:2.020-131.el6_4 will be installed
---> Package perl-HTML-Tagset.noarch 0:3.20-4.el6 will be installed
---> Package perl-IO-Compress-Base.x86_64 0:2.020-131.el6_4 will be installed
---> Package perl-IO-Compress-Zlib.x86_64 0:2.020-131.el6_4 will be installed
--> Finished Dependency Resolution
 
Dependencies Resolved
 
================================================================================
 Package                    Arch       Version                Repository   Size
================================================================================
Installing:
 autoconf                   noarch     2.63-5.1.el6           base        781 k
 automake                   noarch     1.11.1-4.el6           base        550 k
 bison                      x86_64     2.4.1-5.el6            base        637 k
 byacc                      x86_64     1.9.20070509-7.el6     base         48 k
 cscope                     x86_64     15.6-6.el6             base        136 k
 ctags                      x86_64     5.8-2.el6              base        147 k
 cvs                        x86_64     1.11.23-15.el6         base        711 k
 diffstat                   x86_64     1.51-2.el6             base         29 k
 doxygen                    x86_64     1:1.6.1-6.el6          base        2.4 M
 flex                       x86_64     2.5.35-8.el6           base        286 k
 gcc                        x86_64     4.4.7-3.el6            base         10 M
 gcc-c++                    x86_64     4.4.7-3.el6            base        4.7 M
 gcc-gfortran               x86_64     4.4.7-3.el6            base        4.7 M
 gettext                    x86_64     0.17-16.el6            base        1.8 M
 git                        x86_64     1.7.1-3.el6_4.1        updates     4.6 M
 indent                     x86_64     2.2.10-7.el6           base        115 k
 intltool                   noarch     0.41.0-1.1.el6         base         58 k
 libtool                    x86_64     2.2.6-15.5.el6         base        564 k
 make                       x86_64     1:3.81-20.el6          base        389 k
 patch                      x86_64     2.6-6.el6              base         90 k
 patchutils                 x86_64     0.3.1-3.1.el6          base         95 k
 rcs                        x86_64     5.7-37.el6             base        173 k
 redhat-rpm-config          noarch     9.0.3-42.el6           base         59 k
 rpm-build                  x86_64     4.8.0-32.el6           base        126 k
 subversion                 x86_64     1.6.11-9.el6_4         updates     2.3 M
 swig                       x86_64     1.3.40-6.el6           base        1.1 M
 systemtap                  x86_64     1.8-7.el6              base         26 k
Installing for dependencies:
 apr                        x86_64     1.3.9-5.el6_2          base        123 k
 apr-util                   x86_64     1.3.9-3.el6_0.1        base         87 k
 cloog-ppl                  x86_64     0.15.7-1.2.el6         base         93 k
 cpp                        x86_64     4.4.7-3.el6            base        3.7 M
 gdb                        x86_64     7.2-60.el6_4.1         updates     2.3 M
 gettext-devel              x86_64     0.17-16.el6            base        155 k
 gettext-libs               x86_64     0.17-16.el6            base        112 k
 glibc-devel                x86_64     2.12-1.107.el6         base        974 k
 glibc-headers              x86_64     2.12-1.107.el6         base        604 k
 kernel-devel               x86_64     2.6.32-358.6.2.el6     updates     8.2 M
 kernel-headers             x86_64     2.6.32-358.6.2.el6     updates     2.3 M
 libICE                     x86_64     1.0.6-1.el6            base         53 k
 libSM                      x86_64     1.2.1-2.el6            base         37 k
 libXtst                    x86_64     1.2.1-2.el6            base         29 k
 libart_lgpl                x86_64     2.3.20-5.1.el6         base         65 k
 libgcj                     x86_64     4.4.7-3.el6            base         19 M
 libgfortran                x86_64     4.4.7-3.el6            base        265 k
 libgomp                    x86_64     4.4.7-3.el6            base        118 k
 libstdc++-devel            x86_64     4.4.7-3.el6            base        1.6 M
 mailcap                    noarch     2.1.31-2.el6           base         27 k
 mpfr                       x86_64     2.4.1-6.el6            base        157 k
 neon                       x86_64     0.29.3-2.el6           base        118 k
 pakchois                   x86_64     0.4-3.2.el6            base         21 k
 perl-Compress-Raw-Zlib     x86_64     1:2.020-131.el6_4      updates      68 k
 perl-Compress-Zlib         x86_64     2.020-131.el6_4        updates      44 k
 perl-Error                 noarch     1:0.17015-4.el6        base         29 k
 perl-Git                   noarch     1.7.1-3.el6_4.1        updates      28 k
 perl-HTML-Parser           x86_64     3.64-2.el6             base        109 k
 perl-HTML-Tagset           noarch     3.20-4.el6             base         17 k
 perl-IO-Compress-Base      x86_64     2.020-131.el6_4        updates      68 k
 perl-IO-Compress-Zlib      x86_64     2.020-131.el6_4        updates     134 k
 perl-URI                   noarch     1.40-2.el6             base        117 k
 perl-XML-Parser            x86_64     2.36-7.el6             base        224 k
 perl-libwww-perl           noarch     5.833-2.el6            base        387 k
 ppl                        x86_64     0.10.2-11.el6          base        1.3 M
 systemtap-client           x86_64     1.8-7.el6              base        3.1 M
 systemtap-devel            x86_64     1.8-7.el6              base        1.2 M
 
Transaction Summary
================================================================================
Install      64 Package(s)
 
Total download size: 83 M
Installed size: 242 M
Is this ok [y/N]: y
Downloading Packages:
(1/64): apr-1.3.9-5.el6_2.x86_64.rpm                     | 123 kB     00:00     
(2/64): apr-util-1.3.9-3.el6_0.1.x86_64.rpm              |  87 kB     00:00     
(3/64): autoconf-2.63-5.1.el6.noarch.rpm                 | 781 kB     00:00     
(4/64): automake-1.11.1-4.el6.noarch.rpm                 | 550 kB     00:00     
(5/64): bison-2.4.1-5.el6.x86_64.rpm                     | 637 kB     00:00     
(6/64): byacc-1.9.20070509-7.el6.x86_64.rpm              |  48 kB     00:00     
(7/64): cloog-ppl-0.15.7-1.2.el6.x86_64.rpm              |  93 kB     00:00  
....
..
...
  libstdc++-devel.x86_64 0:4.4.7-3.el6                                          
  mailcap.noarch 0:2.1.31-2.el6                                                 
  mpfr.x86_64 0:2.4.1-6.el6                                                     
  neon.x86_64 0:0.29.3-2.el6                                                    
  pakchois.x86_64 0:0.4-3.2.el6                                                 
  perl-Compress-Raw-Zlib.x86_64 1:2.020-131.el6_4                               
  perl-Compress-Zlib.x86_64 0:2.020-131.el6_4                                   
  perl-Error.noarch 1:0.17015-4.el6                                             
  perl-Git.noarch 0:1.7.1-3.el6_4.1                                             
  perl-HTML-Parser.x86_64 0:3.64-2.el6                                          
  perl-HTML-Tagset.noarch 0:3.20-4.el6                                          
  perl-IO-Compress-Base.x86_64 0:2.020-131.el6_4                                
  perl-IO-Compress-Zlib.x86_64 0:2.020-131.el6_4                                
  perl-URI.noarch 0:1.40-2.el6                                                  
  perl-XML-Parser.x86_64 0:2.36-7.el6                                           
  perl-libwww-perl.noarch 0:5.833-2.el6                                         
  ppl.x86_64 0:0.10.2-11.el6                                                    
  systemtap-client.x86_64 0:1.8-7.el6                                           
  systemtap-devel.x86_64 0:1.8-7.el6                                            
 
Complete!

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 ##
cd 
##  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 # yum -y install fedora-rpmdevtools
OR
$ sudo yum -y install fedora-rpmdevtools
Login as a non-root user, and type the following command create rpmbuild directory:
$ fedora-buildrpmtree

References:

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 3 comments so far... add one


CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
3 comments… add one

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum