Building Nginx SRPMS

Companion to my earlier post, this actually has commands

Install mock, RPM dev tools & gcc, and nginx build dependencies (technically not needed, mock will download everything in its own chroot – investigating removing these):

yum install mock rpmdevtools gcc openssl-devel zlib-devel pcre-devel

Create the mock build user, and add it to the mock group to allow it to run mock (the group was created when installing mock)

useradd mockbuild && usermod mockbuild -aG mock

Get an existing source RPM that we can extract*


Make a directory and unpack the source RPM

Extract files to current directory (for nginx, this creates the SOURCES and SPECS directory, likely similar for other source RPMs as well):

rpm --define "_topdir $(pwd)" -ivh nginx.src.rpm

Get the latest nginx code from the download page
Edit the spec file (or use a pre-edited file)

vim SPECS/nginx.spec

Bump the spec version

rpmdev-bumpspec -u "Name <email@domain>" -c "Explanation" SPECS/nginx.spec

Build the source RPM

rpmbuild -bs SPECS/nginx.spec
/usr/bin/mock -r fedora-20-i386 --spec=SPECS/nginx.spec --sources=SOURCES/ --buildsrpm --resultdir=.

Build the actual RPM to make sure the spec works

/usr/bin/mock -r fedora-20-i386 --rebuild nginx-1.7.10-1.el6.ngx.src.rpm --resultdir=.

*: The alternate to downloading the SRPM was to clone the git repo. In this case cloning the entire repo is overkill, since we only want files, not history. Additionally we want the sysvconfig files/config to stick around, and they’ve been removed for Fedora 22 & CentOS 7. Eventually I’ll have to reconcile differences in the files in git master vs the files in el6 SRPMS, and at that point I’ll move to using a proper git repo.


  1. No comments yet.
(will not be published)