Created
April 4, 2016 08:44
-
-
Save eru/84fafee9a695aa1e90b3054e02334977 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# set PKGCMD | |
PKGCMD="yum" | |
if type dnf >/dev/null 2>&1; then | |
PKGCMD="dnf" | |
fi | |
# check root user | |
if [ ${EUID:-${UID}} != 0 ]; then | |
PKGCMD="sudo ${PKGCMD}" | |
fi | |
# set spec path | |
SPECFILE="${HOME}/rpmbuild/SPECS/nginx.spec" | |
# install build requirements packages | |
${PKGCMD} install rpm-build GeoIP-devel gd-devel libxslt-devel openssl-devel pcre-devel perl-ExtUtils-Embed perl-devel zlib-devel gcc make which | |
# detect newest nginx version | |
NGINX_VERSION=(`curl http://nginx.org/packages/mainline/rhel/7/SRPMS/ | sed -nre 's/<a href="nginx-([0-9\.]+-1)\.el7\.ngx\.src\.rpm">.*/\1/p' | sort -t . -n -k 1,1 -k 2,2 -k 3,3 -r | head -n 1`) | |
# install source rpm package | |
rpm -ivh http://nginx.org/packages/mainline/rhel/7/SRPMS/nginx-${NGINX_VERSION}.el7.ngx.src.rpm | |
# patch spec file | |
sed -i -e 's/^\(%if 0%{?rhel} == 7\)$/\1 || 0%{?fedora} >= 18/g' ${SPECFILE} | |
# build packages | |
LC_ALL=C rpmbuild -bb ${SPECFILE} | |
# unset env | |
unset PKGCMD | |
unset SPECFILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment