Last active
December 11, 2015 13:59
-
-
Save kbinani/4611610 to your computer and use it in GitHub Desktop.
build httpd rpm
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/bash | |
function build_httpd_rpm { ( | |
local base_version=$1 | |
local buildroot=$(rpmbuild --eval=%_topdir 2>/dev/null | tr -d '\n') | |
mkdir -p $buildroot | |
local major_version=$(echo $base_version | cut -f1 -d'.') | |
local minor_version=$(echo $base_version | cut -f2 -d'.') | |
local release_version=$( | |
curl -L http://archive.apache.org/dist/httpd 2>/dev/null \ | |
| grep "httpd-$major_version\.$minor_version" \ | |
| sed "s:^.*<a href=\"\(httpd-$major_version\.$minor_version\.[0-9]*\.tar\.gz\)\".*$:\1:g" \ | |
| grep "^httpd-$major_version\.$minor_version\.[0-9]*\.tar\.gz$" \ | |
| sed 's:^httpd-\([0-9.]*\)\.tar\.gz$:\1:g' \ | |
| cut -f3 -d'.' \ | |
| sort -nr \ | |
| head -1 \ | |
| tr -d '\n') | |
local version="$base_version.$release_version" | |
mkdir -p /tmp/httpd | |
cd /tmp/httpd | |
[ -f httpd-$version.tar.gz ] || { | |
wget http://archive.apache.org/dist/httpd/httpd-$version.tar.gz -O httpd-$version.tar.gz || { | |
echo "ERROR: cannot wget tar archive." | |
return 1 | |
} | |
} | |
tar zxf httpd-$version.tar.gz | |
for dir in BUILD SRPMS SPECS SOURCES RPMS; do | |
[ -d $buildroot/$dir ] || { | |
mkdir -p $buildroot/$dir | |
} | |
done | |
cat httpd-$version/httpd.spec \ | |
| sed 's/Prereq: openssl, dev, \/bin\/cat/Prereq: openssl, \/bin\/cat/g' \ | |
> $buildroot/SPECS/httpd.spec | |
cp httpd-$version.tar.gz $buildroot/SOURCES/ | |
which rpmbuild >/dev/null 2>&1 || { | |
yum install -y rpm-build | |
} | |
yum install -y gcc apr-devel apr-util-devel openldap-devel db4-devel expat-devel pcre-devel openssl-devel distcache-devel | |
rpmbuild -bb $buildroot/SPECS/httpd.spec | |
) } | |
if [ -z "$1" ]; then | |
echo "ERROR: missing argument." | |
echo "Usage: bash $0 version" | |
echo " ex) \$ bash $0 2.2" | |
exit 1 | |
else | |
build_httpd_rpm "$1" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment