How to build binary rpm package from srpms in CentOS or RHEL ?

In this article we will look how to create RPM packages in redhat or centos operating environment using the source RPM package i.e. from .src.rpm package.

For this purpose, you can download any src.rpm package and build the binary .rpm package.

1. Download any .src.rpm package.
For example:- I have download the calculator i.e. bc command src rpm.

[root@nglinux ~]# mkdir rpm_test; cd rpm_test/

### Download some .src.rpm package.
[root@nglinux rpm_test]# wget http://ftp.redhat.com/pub/redhat/linux/enterprise/6Client/en/os/SRPMS/bc-1.06.95-1.el6.src.rpm --no-check-certificate

### Package is now downloaded
[root@nglinux rpm_test]# ls
bc-1.06.95-1.el6.src.rpm  vim-7.4.326-11.1.src.rpm
[root@nglinux rpm_test]# 

2. Install rpmbuild utility to build rpm binaries.

[root@nglinux ~]# yum install rpm-build
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Repository remi is listed more than once in the configuration
Dependencies Resolved
===============================================================================================================================================================================================
 Package                                           Arch                                   Version                                              Repository                                 Size
===============================================================================================================================================================================================
Installing:
 rpm-build                                         i686                                   4.8.0-55.el6                                         C6.8-base                                 132 k
Installing for dependencies:
 gdb                                               i686                                   7.2-92.el6                                           base                                      2.3 M
 redhat-rpm-config                                 noarch                                 9.0.3-51.el6.centos                                  C6.8-base                                  60 k

Transaction Summary
===============================================================================================================================================================================================
Install       3 Package(s)

Total download size: 2.5 M
Installed size: 5.6 M
Is this ok [y/N]: y
Downloading Packages:

Running Transaction
  Installing : redhat-rpm-config-9.0.3-51.el6.centos.noarch                                                                                                                                1/3 
  Installing : gdb-7.2-92.el6.i686                                                                                                                                                         2/3 
  Installing : rpm-build-4.8.0-55.el6.i686                                                                                                                                                 3/3 
  Verifying  : redhat-rpm-config-9.0.3-51.el6.centos.noarch                                                                                                                                1/3 
  Verifying  : rpm-build-4.8.0-55.el6.i686                                                                                                                                                 2/3 
  Verifying  : gdb-7.2-92.el6.i686      

Complete!
[root@nglinux ~]# 

3. Set RPM build macros.

[root@nglinux ~]# cat .rpmmacros 
%HOME       %{expand:%%(cd; pwd)}
%_topdir    %{HOME}/rpminstall
[root@nglinux ~]# 

### Creating directory that contains rpm builds or sources.
[root@nglinux ~]# mkdir rpminstall

4. Install the source rpm

[root@nglinux rpm_test]# rpm -ivh bc-1.06.95-1.el6.src.rpm 
   1:bc                     warning: user mockbuild does not exist - using root
warning: group mockbuild does not exist - using root
warning: user mockbuild does not exist - using root
warning: group mockbuild does not exist - using root
warning: user mockbuild does not exist - using root
warning: group mockbuild does not exist - using root
warning: user mockbuild does not exist - using root
warning: group mockbuild does not exist - using root
########################################### [100%]


This will create below six dirs
[root@nglinux rpm_test]# ls -l ../rpminstall/
total 24
drwxr-xr-x. 3 root root 4096 Feb  2 09:47 BUILD
drwxr-xr-x. 2 root root 4096 Feb  2 09:48 BUILDROOT
drwxr-xr-x. 3 root root 4096 Feb  2 09:48 RPMS
drwxr-xr-x. 2 root root 4096 Feb  2 09:26 SOURCES
drwxr-xr-x. 2 root root 4096 Feb  2 23:13 SPECS
drwxr-xr-x. 2 root root 4096 Jan 30 04:29 SRPMS
[root@nglinux rpm_test]# 

5. Checking the SPEC file.

[root@nglinux rpm_test]# cd ../rpminstall/SPECS/
[root@nglinux SPECS]# ls
bc.spec  
[root@nglinux SPECS]# 

6. Execute the preparation stage from the spec file to verify if everything is fine with package dependencies.

[root@nglinux SPECS]# rpmbuild -bp bc.spec 
error: Failed build dependencies:
	readline-devel is needed by bc-1.06.95-1.el6.i686
	flex is needed by bc-1.06.95-1.el6.i686
[root@nglinux SPECS]#

7. Resolve issues faced during preparation stage.

[root@nglinux SPECS]# yum install readline-devel flex
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Repository remi is listed more than once in the configuration
Loading mirror speeds from cached hostfile
 * base: mirror.vbctv.in

8. Now compile the package.

[root@nglinux SPECS]# rpmbuild -bp bc.spec 
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.Lq2K7r
+ umask 022
+ cd /root/rpminstall/BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ cd /root/rpminstall/BUILD
+ rm -rf bc-1.06.95
+ /bin/tar -xf -
+ /usr/bin/bzip2 -dc /root/rpminstall/SOURCES/bc-1.06.95.tar.bz2
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd bc-1.06.95
+ /bin/chmod -Rf a+rX,u+w,g-w,o-w .
+ echo 'Patch #1 (bc-1.06-dc_ibase.patch):'
Patch #1 (bc-1.06-dc_ibase.patch):
+ /usr/bin/patch -p1 -b --suffix .dc_ibase --fuzz=0
+ /bin/cat /root/rpminstall/SOURCES/bc-1.06-dc_ibase.patch
patching file dc/numeric.c
Hunk #1 succeeded at 308 (offset 23 lines).
Hunk #2 succeeded at 327 (offset 23 lines).
Hunk #3 succeeded at 337 (offset 23 lines).
Hunk #4 succeeded at 354 (offset 23 lines).
+ echo 'Patch #2 (bc-1.06.95-memleak.patch):'
Patch #2 (bc-1.06.95-memleak.patch):
+ /usr/bin/patch -p1 -b --suffix .memleak --fuzz=0
+ /bin/cat /root/rpminstall/SOURCES/bc-1.06.95-memleak.patch
patching file bc/bc.y
patching file bc/util.c
+ exit 0
[root@nglinux SPECS]# 

9. Build the binary RPM package.

[root@nglinux SPECS]# rpmbuild -bb bc.spec 
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.wi8PHX
+ umask 022
+ cd /root/rpminstall/BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ cd /root/rpminstall/BUILD
+ rm -rf bc-1.06.95
+ /bin/tar -xf -
+ /usr/bin/bzip2 -dc /root/rpminstall/SOURCES/bc-1.06.95.tar.bz2
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd bc-1.06.95
+ /bin/chmod -Rf a+rX,u+w,g-w,o-w .
+ echo 'Patch #1 (bc-1.06-dc_ibase.patch):'
Patch #1 (bc-1.06-dc_ibase.patch):
+ /usr/bin/patch -p1 -b --suffix .dc_ibase --fuzz=0
+ /bin/cat /root/rpminstall/SOURCES/bc-1.06-dc_ibase.patch
patching file dc/numeric.c
Hunk #1 succeeded at 308 (offset 23 lines).
Hunk #2 succeeded at 327 (offset 23 lines).
Hunk #3 succeeded at 337 (offset 23 lines).
Hunk #4 succeeded at 354 (offset 23 lines).
+ echo 'Patch #2 (bc-1.06.95-memleak.patch):'
Patch #2 (bc-1.06.95-memleak.patch):
+ /bin/cat /root/rpminstall/SOURCES/bc-1.06.95-memleak.patch
+ /usr/bin/patch -p1 -b --suffix .memleak --fuzz=0
patching file bc/bc.y
patching file bc/util.c
+ exit 0
Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.SzNh9m
+ umask 022
+ cd /root/rpminstall/BUILD
+ cd bc-1.06.95
+ LANG=C
+ export LANG
+ unset DISPLAY
+ CFLAGS='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables'
+ export CFLAGS
+ CXXFLAGS='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables'
+ export CXXFLAGS
+ FFLAGS='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -I/usr/lib/gfortran/modules'
+ export FFLAGS
+ ./configure --build=i686-redhat-linux-gnu --host=i686-redhat-linux-gnu --target=i686-redhat-linux-gnu --program-prefix= --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/var/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-readline
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for i686-redhat-linux-gnu-gcc... no
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking how to run the C preprocessor... gcc -E
checking for egrep... grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking for flex... flex
checking for yywrap in -lfl... no
checking for yywrap in -ll... no
checking lex output file root... lex.yy
checking whether yytext is a pointer... no
checking for bison... bison -y
checking for a BSD-compatible install... /usr/bin/install -c
checking for i686-redhat-linux-gnu-ranlib... no
checking for ranlib... ranlib
checking whether make sets $(MAKE)... (cached) yes
checking stdarg.h usability... yes
checking stdarg.h presence... yes
checking for stdarg.h... yes
checking stddef.h usability... yes
checking stddef.h presence... yes
checking for stddef.h... yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking errno.h usability... yes
checking errno.h presence... yes
checking for errno.h... yes
checking limits.h usability... yes
checking limits.h presence... yes
checking for limits.h... yes
checking for unistd.h... (cached) yes
checking lib.h usability... no
checking lib.h presence... no
checking for lib.h... no
checking for an ANSI C-conforming const... yes
checking for size_t... yes
checking for ptrdiff_t... yes
checking for vprintf... yes
checking for _doprnt... no
checking for isgraph... yes
checking for setvbuf... yes
checking for fstat... yes
checking for strtol... yes
checking for tparm in -lncurses... yes
checking for readline in -lreadline... yes
checking readline/readline.h usability... yes
checking readline/readline.h presence... yes
checking for readline/readline.h... yes
Using the readline library.
Adding GCC specific compile flags.
configure: creating ./config.status
config.status: creating Makefile
config.status: creating bc/Makefile
config.status: creating dc/Makefile
config.status: creating doc/Makefile
config.status: creating doc/texi-ver.incl
config.status: creating lib/Makefile
config.status: creating config.h
config.status: executing depfiles commands
+ make
make  all-recursive
make[1]: Entering directory `/root/rpminstall/BUILD/bc-1.06.95'
Making all in lib
make[2]: Entering directory `/root/rpminstall/BUILD/bc-1.06.95/lib'
if gcc -DHAVE_CONFIG_H  -I. -I. -I.. -I. -I.. -I./../h   -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char -MT getopt.o -MD -MP -MF ".deps/getopt.Tpo" -c -o getopt.o getopt.c; \
	then mv -f ".deps/getopt.Tpo" ".deps/getopt.Po"; else rm -f ".deps/getopt.Tpo"; exit 1; fi
if gcc -DHAVE_CONFIG_H  -I. -I. -I.. -I. -I.. -I./../h   -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char -MT getopt1.o -MD -MP -MF ".deps/getopt1.Tpo" -c -o getopt1.o getopt1.c; \
	then mv -f ".deps/getopt1.Tpo" ".deps/getopt1.Po"; else rm -f ".deps/getopt1.Tpo"; exit 1; fi
if gcc -DHAVE_CONFIG_H  -I. -I. -I.. -I. -I.. -I./../h   -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char -MT vfprintf.o -MD -MP -MF ".deps/vfprintf.Tpo" -c -o vfprintf.o vfprintf.c; \
	then mv -f ".deps/vfprintf.Tpo" ".deps/vfprintf.Po"; else rm -f ".deps/vfprintf.Tpo"; exit 1; fi
if gcc -DHAVE_CONFIG_H  -I. -I. -I.. -I. -I.. -I./../h   -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char -MT number.o -MD -MP -MF ".deps/number.Tpo" -c -o number.o number.c; \
	then mv -f ".deps/number.Tpo" ".deps/number.Po"; else rm -f ".deps/number.Tpo"; exit 1; fi
rm -f libbc.a
ar cru libbc.a getopt.o getopt1.o vfprintf.o number.o 
ranlib libbc.a
make[2]: Leaving directory `/root/rpminstall/BUILD/bc-1.06.95/lib'
Making all in bc
make[2]: Entering directory `/root/rpminstall/BUILD/bc-1.06.95/bc'
if gcc -DHAVE_CONFIG_H -I. -I. -I.. -I. -I./../h   -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char -MT main.o -MD -MP -MF ".deps/main.Tpo" -c -o main.o main.c; \
	then mv -f ".deps/main.Tpo" ".deps/main.Po"; else rm -f ".deps/main.Tpo"; exit 1; fi
main.c: In function 'use_quit':
main.c:360: warning: ignoring return value of 'write', declared with attribute warn_unused_result
bison -y  -d bc.y
conflicts: 3 shift/reduce
if test -f y.tab.h; then \
	  to=`echo "bc_H" | sed \
                -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \
                -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'`; \
	  sed -e "/^#/!b" -e "s/Y_TAB_H/$to/g" -e "s|y\.tab\.h|bc.h|" \
            y.tab.h >bc.ht; \
	  rm -f y.tab.h; \
	  if cmp -s bc.ht bc.h; then \
	    rm -f bc.ht ;\
	  else \
	    mv bc.ht bc.h; \
	  fi; \
	fi
if test -f y.output; then \
	  mv y.output bc.output; \
	fi
sed '/^#/ s|y\.tab\.c|bc.c|' y.tab.c >bc.ct && mv bc.ct bc.c
rm -f y.tab.c
if gcc -DHAVE_CONFIG_H -I. -I. -I.. -I. -I./../h   -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char -MT bc.o -MD -MP -MF ".deps/bc.Tpo" -c -o bc.o bc.c; \
	then mv -f ".deps/bc.Tpo" ".deps/bc.Po"; else rm -f ".deps/bc.Tpo"; exit 1; fi
if gcc -DHAVE_CONFIG_H -I. -I. -I.. -I. -I./../h   -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char -MT scan.o -MD -MP -MF ".deps/scan.Tpo" -c -o scan.o scan.c; \
	then mv -f ".deps/scan.Tpo" ".deps/scan.Po"; else rm -f ".deps/scan.Tpo"; exit 1; fi
scan.c: In function 'yylex':
scan.l:366: warning: ignoring return value of 'fwrite', declared with attribute warn_unused_result
scan.l: At top level:
scan.c:1800: warning: 'yyunput' defined but not used
if gcc -DHAVE_CONFIG_H -I. -I. -I.. -I. -I./../h   -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char -MT execute.o -MD -MP -MF ".deps/execute.Tpo" -c -o execute.o execute.c; \
	then mv -f ".deps/execute.Tpo" ".deps/execute.Po"; else rm -f ".deps/execute.Tpo"; exit 1; fi
if gcc -DHAVE_CONFIG_H -I. -I. -I.. -I. -I./../h   -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char -MT load.o -MD -MP -MF ".deps/load.Tpo" -c -o load.o load.c; \
	then mv -f ".deps/load.Tpo" ".deps/load.Po"; else rm -f ".deps/load.Tpo"; exit 1; fi
if gcc -DHAVE_CONFIG_H -I. -I. -I.. -I. -I./../h   -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char -MT storage.o -MD -MP -MF ".deps/storage.Tpo" -c -o storage.o storage.c; \
	then mv -f ".deps/storage.Tpo" ".deps/storage.Po"; else rm -f ".deps/storage.Tpo"; exit 1; fi
if gcc -DHAVE_CONFIG_H -I. -I. -I.. -I. -I./../h   -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char -MT util.o -MD -MP -MF ".deps/util.Tpo" -c -o util.o util.c; \
	then mv -f ".deps/util.Tpo" ".deps/util.Po"; else rm -f ".deps/util.Tpo"; exit 1; fi
if gcc -DHAVE_CONFIG_H -I. -I. -I.. -I. -I./../h   -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char -MT global.o -MD -MP -MF ".deps/global.Tpo" -c -o global.o global.c; \
	then mv -f ".deps/global.Tpo" ".deps/global.Po"; else rm -f ".deps/global.Tpo"; exit 1; fi
if gcc -DHAVE_CONFIG_H -I. -I. -I.. -I. -I./../h   -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char -MT warranty.o -MD -MP -MF ".deps/warranty.Tpo" -c -o warranty.o warranty.c; \
	then mv -f ".deps/warranty.Tpo" ".deps/warranty.Po"; else rm -f ".deps/warranty.Tpo"; exit 1; fi
gcc -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char   -o bc  main.o bc.o scan.o execute.o load.o storage.o util.o global.o warranty.o ../lib/libbc.a  -lreadline -lncurses 
make[2]: Leaving directory `/root/rpminstall/BUILD/bc-1.06.95/bc'
Making all in dc
make[2]: Entering directory `/root/rpminstall/BUILD/bc-1.06.95/dc'
if gcc -DHAVE_CONFIG_H -I. -I. -I.. -I./.. -I./../h   -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char -MT dc.o -MD -MP -MF ".deps/dc.Tpo" -c -o dc.o dc.c; \
	then mv -f ".deps/dc.Tpo" ".deps/dc.Po"; else rm -f ".deps/dc.Tpo"; exit 1; fi
if gcc -DHAVE_CONFIG_H -I. -I. -I.. -I./.. -I./../h   -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char -MT misc.o -MD -MP -MF ".deps/misc.Tpo" -c -o misc.o misc.c; \
	then mv -f ".deps/misc.Tpo" ".deps/misc.Po"; else rm -f ".deps/misc.Tpo"; exit 1; fi
misc.c: In function 'dc_system':
misc.c:142: warning: ignoring return value of 'system', declared with attribute warn_unused_result
misc.c:146: warning: ignoring return value of 'system', declared with attribute warn_unused_result
if gcc -DHAVE_CONFIG_H -I. -I. -I.. -I./.. -I./../h   -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char -MT eval.o -MD -MP -MF ".deps/eval.Tpo" -c -o eval.o eval.c; \
	then mv -f ".deps/eval.Tpo" ".deps/eval.Po"; else rm -f ".deps/eval.Tpo"; exit 1; fi
if gcc -DHAVE_CONFIG_H -I. -I. -I.. -I./.. -I./../h   -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char -MT stack.o -MD -MP -MF ".deps/stack.Tpo" -c -o stack.o stack.c; \
	then mv -f ".deps/stack.Tpo" ".deps/stack.Po"; else rm -f ".deps/stack.Tpo"; exit 1; fi
if gcc -DHAVE_CONFIG_H -I. -I. -I.. -I./.. -I./../h   -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char -MT array.o -MD -MP -MF ".deps/array.Tpo" -c -o array.o array.c; \
	then mv -f ".deps/array.Tpo" ".deps/array.Po"; else rm -f ".deps/array.Tpo"; exit 1; fi
if gcc -DHAVE_CONFIG_H -I. -I. -I.. -I./.. -I./../h   -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char -MT numeric.o -MD -MP -MF ".deps/numeric.Tpo" -c -o numeric.o numeric.c; \
	then mv -f ".deps/numeric.Tpo" ".deps/numeric.Po"; else rm -f ".deps/numeric.Tpo"; exit 1; fi
if gcc -DHAVE_CONFIG_H -I. -I. -I.. -I./.. -I./../h   -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char -MT string.o -MD -MP -MF ".deps/string.Tpo" -c -o string.o string.c; \
	then mv -f ".deps/string.Tpo" ".deps/string.Po"; else rm -f ".deps/string.Tpo"; exit 1; fi
string.c: In function 'dc_out_str':
string.c:101: warning: ignoring return value of 'fwrite', declared with attribute warn_unused_result
gcc -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables -Wall -funsigned-char   -o dc  dc.o misc.o eval.o stack.o array.o numeric.o string.o ../lib/libbc.a 
make[2]: Leaving directory `/root/rpminstall/BUILD/bc-1.06.95/dc'
Making all in doc
make[2]: Entering directory `/root/rpminstall/BUILD/bc-1.06.95/doc'
restore=: && backupdir=".am$$" && \
	am__cwd=`pwd` && cd . && \
	rm -rf $backupdir && mkdir $backupdir && \
	if (makeinfo --no-split --version) >/dev/null 2>&1; then \
	  for f in bc.info bc.info-[0-9] bc.info-[0-9][0-9] bc.i[0-9] bc.i[0-9][0-9]; do \
	    if test -f $f; then mv $f $backupdir; restore=mv; else :; fi; \
	  done; \
	else :; fi && \
	cd "$am__cwd"; \
	if makeinfo --no-split   -I . \
	 -o bc.info bc.texi; \
	then \
	  rc=0; \
	  cd .; \
	else \
	  rc=$?; \
	  cd . && \
	  $restore $backupdir/* `echo "./bc.info" | sed 's|[^/]*$||'`; \
	fi; \
	rm -rf $backupdir; exit $rc
bc.texi:523: warning: unlikely character ( in @var.
bc.texi:523: warning: unlikely character ) in @var.
bc.texi:523: warning: unlikely character [ in @var.
bc.texi:523: warning: unlikely character ] in @var.
bc.texi:530: warning: unlikely character ( in @var.
bc.texi:530: warning: unlikely character ) in @var.
bc.texi:536: warning: unlikely character ( in @var.
bc.texi:536: warning: unlikely character [ in @var.
bc.texi:536: warning: unlikely character ] in @var.
bc.texi:536: warning: unlikely character [ in @var.
bc.texi:536: warning: unlikely character ] in @var.
bc.texi:536: warning: unlikely character [ in @var.
bc.texi:536: warning: unlikely character ] in @var.
bc.texi:536: warning: unlikely character ) in @var.
bc.texi:575: warning: unlikely character ( in @var.
bc.texi:575: warning: unlikely character ) in @var.
bc.texi:735: warning: unlikely character , in @var.
bc.texi:897: warning: unlikely character , in @var.
bc.texi:904: warning: unlikely character , in @var.
bc.texi:904: warning: unlikely character , in @var.
bc.texi:927: warning: unlikely character , in @var.
bc.texi:927: warning: unlikely character , in @var.
bc.texi:927: warning: unlikely character , in @var.
bc.texi:927: warning: unlikely character , in @var.
bc.texi:927: warning: unlikely character , in @var.
restore=: && backupdir=".am$$" && \
	am__cwd=`pwd` && cd . && \
	rm -rf $backupdir && mkdir $backupdir && \
	if (makeinfo --no-split --version) >/dev/null 2>&1; then \
	  for f in dc.info dc.info-[0-9] dc.info-[0-9][0-9] dc.i[0-9] dc.i[0-9][0-9]; do \
	    if test -f $f; then mv $f $backupdir; restore=mv; else :; fi; \
	  done; \
	else :; fi && \
	cd "$am__cwd"; \
	if makeinfo --no-split   -I . \
	 -o dc.info dc.texi; \
	then \
	  rc=0; \
	  cd .; \
	else \
	  rc=$?; \
	  cd . && \
	  $restore $backupdir/* `echo "./dc.info" | sed 's|[^/]*$||'`; \
	fi; \
	rm -rf $backupdir; exit $rc
make[2]: Leaving directory `/root/rpminstall/BUILD/bc-1.06.95/doc'
make[2]: Entering directory `/root/rpminstall/BUILD/bc-1.06.95'
make[2]: Leaving directory `/root/rpminstall/BUILD/bc-1.06.95'
make[1]: Leaving directory `/root/rpminstall/BUILD/bc-1.06.95'
+ exit 0
Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.y4rrrD
+ umask 022
+ cd /root/rpminstall/BUILD
+ '[' /root/rpminstall/BUILDROOT/bc-1.06.95-1.el6.i386 '!=' / ']'
+ rm -rf /root/rpminstall/BUILDROOT/bc-1.06.95-1.el6.i386
++ dirname /root/rpminstall/BUILDROOT/bc-1.06.95-1.el6.i386
+ mkdir -p /root/rpminstall/BUILDROOT
+ mkdir /root/rpminstall/BUILDROOT/bc-1.06.95-1.el6.i386
+ cd bc-1.06.95
+ LANG=C
+ export LANG
+ unset DISPLAY
+ rm -rf /root/rpminstall/BUILDROOT/bc-1.06.95-1.el6.i386
+ make install DESTDIR=/root/rpminstall/BUILDROOT/bc-1.06.95-1.el6.i386
Making install in lib
make[1]: Entering directory `/root/rpminstall/BUILD/bc-1.06.95/lib'
make[2]: Entering directory `/root/rpminstall/BUILD/bc-1.06.95/lib'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/root/rpminstall/BUILD/bc-1.06.95/lib'
make[1]: Leaving directory `/root/rpminstall/BUILD/bc-1.06.95/lib'
Making install in bc
make[1]: Entering directory `/root/rpminstall/BUILD/bc-1.06.95/bc'
make[2]: Entering directory `/root/rpminstall/BUILD/bc-1.06.95/bc'
test -z "/usr/bin" || mkdir -p -- "/root/rpminstall/BUILDROOT/bc-1.06.95-1.el6.i386/usr/bin"
  /usr/bin/install -c 'bc' '/root/rpminstall/BUILDROOT/bc-1.06.95-1.el6.i386/usr/bin/bc'
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/root/rpminstall/BUILD/bc-1.06.95/bc'
make[1]: Leaving directory `/root/rpminstall/BUILD/bc-1.06.95/bc'
Making install in dc
make[1]: Entering directory `/root/rpminstall/BUILD/bc-1.06.95/dc'
make[2]: Entering directory `/root/rpminstall/BUILD/bc-1.06.95/dc'
test -z "/usr/bin" || mkdir -p -- "/root/rpminstall/BUILDROOT/bc-1.06.95-1.el6.i386/usr/bin"
  /usr/bin/install -c 'dc' '/root/rpminstall/BUILDROOT/bc-1.06.95-1.el6.i386/usr/bin/dc'
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/root/rpminstall/BUILD/bc-1.06.95/dc'
make[1]: Leaving directory `/root/rpminstall/BUILD/bc-1.06.95/dc'
Making install in doc
make[1]: Entering directory `/root/rpminstall/BUILD/bc-1.06.95/doc'
make[2]: Entering directory `/root/rpminstall/BUILD/bc-1.06.95/doc'
make[2]: Nothing to be done for `install-exec-am'.
test -z "/usr/share/info" || mkdir -p -- "/root/rpminstall/BUILDROOT/bc-1.06.95-1.el6.i386/usr/share/info"
 /usr/bin/install -c -m 644 './bc.info' '/root/rpminstall/BUILDROOT/bc-1.06.95-1.el6.i386/usr/share/info/bc.info'
 /usr/bin/install -c -m 644 './dc.info' '/root/rpminstall/BUILDROOT/bc-1.06.95-1.el6.i386/usr/share/info/dc.info'
 install-info --info-dir='/root/rpminstall/BUILDROOT/bc-1.06.95-1.el6.i386/usr/share/info' '/root/rpminstall/BUILDROOT/bc-1.06.95-1.el6.i386/usr/share/info/bc.info'
 install-info --info-dir='/root/rpminstall/BUILDROOT/bc-1.06.95-1.el6.i386/usr/share/info' '/root/rpminstall/BUILDROOT/bc-1.06.95-1.el6.i386/usr/share/info/dc.info'
test -z "/usr/share/man/man1" || mkdir -p -- "/root/rpminstall/BUILDROOT/bc-1.06.95-1.el6.i386/usr/share/man/man1"
 /usr/bin/install -c -m 644 './bc.1' '/root/rpminstall/BUILDROOT/bc-1.06.95-1.el6.i386/usr/share/man/man1/bc.1'
 /usr/bin/install -c -m 644 './dc.1' '/root/rpminstall/BUILDROOT/bc-1.06.95-1.el6.i386/usr/share/man/man1/dc.1'
make[2]: Leaving directory `/root/rpminstall/BUILD/bc-1.06.95/doc'
make[1]: Leaving directory `/root/rpminstall/BUILD/bc-1.06.95/doc'
make[1]: Entering directory `/root/rpminstall/BUILD/bc-1.06.95'
make[2]: Entering directory `/root/rpminstall/BUILD/bc-1.06.95'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/root/rpminstall/BUILD/bc-1.06.95'
make[1]: Leaving directory `/root/rpminstall/BUILD/bc-1.06.95'
+ rm -f /root/rpminstall/BUILDROOT/bc-1.06.95-1.el6.i386//usr/share/info/dir
+ /usr/lib/rpm/find-debuginfo.sh --strict-build-id /root/rpminstall/BUILD/bc-1.06.95
extracting debug info from /root/rpminstall/BUILDROOT/bc-1.06.95-1.el6.i386/usr/bin/bc
extracting debug info from /root/rpminstall/BUILDROOT/bc-1.06.95-1.el6.i386/usr/bin/dc
782 blocks
+ /usr/lib/rpm/check-buildroot
+ /usr/lib/rpm/redhat/brp-compress
+ /usr/lib/rpm/redhat/brp-strip-static-archive /usr/bin/strip
+ /usr/lib/rpm/redhat/brp-strip-comment-note /usr/bin/strip /usr/bin/objdump
+ /usr/lib/rpm/brp-python-bytecompile /usr/bin/python
+ /usr/lib/rpm/redhat/brp-python-hardlink
+ /usr/lib/rpm/redhat/brp-java-repack-jars
Processing files: bc-1.06.95-1.el6.i686
Executing(%doc): /bin/sh -e /var/tmp/rpm-tmp.eKn77Z
+ umask 022
+ cd /root/rpminstall/BUILD
+ cd bc-1.06.95
+ DOCDIR=/root/rpminstall/BUILDROOT/bc-1.06.95-1.el6.i386/usr/share/doc/bc-1.06.95
+ export DOCDIR
+ rm -rf /root/rpminstall/BUILDROOT/bc-1.06.95-1.el6.i386/usr/share/doc/bc-1.06.95
+ /bin/mkdir -p /root/rpminstall/BUILDROOT/bc-1.06.95-1.el6.i386/usr/share/doc/bc-1.06.95
+ cp -pr COPYING COPYING.LIB FAQ AUTHORS NEWS README Examples/ /root/rpminstall/BUILDROOT/bc-1.06.95-1.el6.i386/usr/share/doc/bc-1.06.95
+ exit 0
Requires(interp): /bin/sh /bin/sh
Requires(rpmlib): rpmlib(CompressedFileNames) <= 3.0.4-1 rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1
Requires(post): /bin/sh /sbin/install-info
Requires(preun): /bin/sh /sbin/install-info
Requires: libc.so.6 libc.so.6(GLIBC_2.0) libc.so.6(GLIBC_2.1) libc.so.6(GLIBC_2.3) libc.so.6(GLIBC_2.3.4) libc.so.6(GLIBC_2.4) libncurses.so.5 libreadline.so.6 rtld(GNU_HASH)
Processing files: bc-debuginfo-1.06.95-1.el6.i686
Checking for unpackaged file(s): /usr/lib/rpm/check-files /root/rpminstall/BUILDROOT/bc-1.06.95-1.el6.i386
Wrote: /root/rpminstall/RPMS/i686/bc-1.06.95-1.el6.i686.rpm
Wrote: /root/rpminstall/RPMS/i686/bc-debuginfo-1.06.95-1.el6.i686.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.LlP2L9
+ umask 022
+ cd /root/rpminstall/BUILD
+ cd bc-1.06.95
+ rm -rf /root/rpminstall/BUILDROOT/bc-1.06.95-1.el6.i386
+ exit 0
[root@nglinux SPECS]# 

10. Verify if the packages are created successfully.

[root@nglinux SPECS]# ls -l ../RPMS/i686/
total 268
-rw-r--r--. 1 root root 107148 Feb  2 09:48 bc-1.06.95-1.el6.i686.rpm
-rw-r--r--. 1 root root 161572 Feb  2 09:48 bc-debuginfo-1.06.95-1.el6.i686.rpm
[root@nglinux SPECS]# 

We used to perform below steps ideally to build the RPM package.
1. Executing the %prep section.

[root@nglinux SPECS]# rpmbuild -bp bc.spec 
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.JQ0ktq
+ umask 022
+ cd /root/rpminstall/BUILD
+ LANG=C

2. Executing the %build section.(i.e. make command)

[root@nglinux SPECS]# rpmbuild -bc bc.spec 
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.oPzRtU
+ umask 022
+ cd /root/rpminstall/BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ cd /root/rpminstall/BUILD

3. Executing %install section (equivalent to make install).

[root@nglinux SPECS]# rpmbuild -bi bc.spec 
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.eYD72q
+ umask 022
+ cd /root/rpminstall/BUILD
+ LANG=C

4. Executing the binary build process.

[root@nglinux SPECS]# rpmbuild -bb bc.spec 
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.FPAn3y
+ umask 022
+ cd /root/rpminstall/BUILD

However as we have seen above, the build command also executes all stages of pre build, compile, and make install. Hence for some packages we can skip above steps and directly build the package i.e. only last 4th step would be enough.

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments