Skip to content

Instantly share code, notes, and snippets.

Last active October 11, 2019 15:46
Show Gist options
  • Save josegonzalez/4126937 to your computer and use it in GitHub Desktop.
Save josegonzalez/4126937 to your computer and use it in GitHub Desktop.
Make an nginx release for ubuntu
# Builds a custom nginx
# RELEASE_TAGS="+your+tags+here"
# RELEASE_MESSAGE="Some message"
echo "[CMD] verifying dependencies"
DEPS="debhelper libgd2-xpm-dev libgeoip-dev liblua5.1-0-dev libmhash-dev libpam0g-dev libperl-dev libxslt1-dev po-debconf dh-systemd libpcre3-dev libssl-dev"
for i in $DEPS ; do
dpkg-query -W -f='${Package}\n' | grep ^$i$ > /dev/null
if [ $? != 0 ] ; then
missing="$missing $i"
if [ ! -z "$missing" ]; then
echo "Missing dependencies, install the following:"
echo "apt-get install$missing"
echo "[CMD] make a source directory and cd into it"
mkdir src
cd src
echo "[CMD] install debhelper"
apt-get install -y debhelper
echo "[CMD] get the source from debian/ubuntu"
apt-get source nginx
echo "[CMD] get the nginx version"
nginx_version=`ls -lahF .|grep nginx|grep '^d[rwx-]\{9\} '| grep '\/$'|rev|cut -d' ' -f1 | rev|sed 's/nginx-//'|sed 's/\///'`
echo "[CMD] retrieve all the nginx modules you want"
cd "nginx-${nginx_version}/debian/modules"
echo "[CMD] clone all the nginx modules from github"
git clone -q git://
git clone -q git://
cd ..
echo "[CMD] ensure the proper dependencies are in place"
cat control | sed 's/libgd2-noxpm-dev/libgd2-xpm-dev/' >> tmp ; rm control ; mv tmp control
echo "[CMD] remove unneeded and broken modules"
cat rules |sed '/with-http_image_filter_module/ d' >> tmp ; rm rules ; mv tmp rules
echo "[CMD] split up the rules file so we can rewrite it"
awk '/\$\(CONFIGURE_OPTS\)/{n++}{filename = "rule-" n ; print > filename }' rules
echo "[CMD] adding modules to the nginx-full package"
echo -e "\t --add-module=\$(MODULESDIR)/headers-more-nginx-module \\" >> rule-
echo -e "\t --add-module=\$(MODULESDIR)/nginx-development-kit \\" >> rule-
echo -e "\t --add-module=\$(MODULESDIR)/nginx-lua \\" >> rule-
echo -e "\t --add-module=\$(MODULESDIR)/nginx-statsd \\" >> rule-
echo -e "\t --add-module=\$(MODULESDIR)/ngx_coolkit \\" >> rule-
echo "[CMD] combine all the rule files"
ls | grep rule- | while read file; do cat $file >> tmp; done; rm rules ; mv tmp rules
echo "[CMD] get the current nginx minor nginx_version"
minor_version=$(head -n 1 changelog | awk -F'[()]' '{print $2}' | awk -F'[-+~]' '{print $2}');
minor_version=$(($minor_version + 1));
echo "[CMD] get the current ubuntu release"
ubuntu_release=$(head -n 1 changelog | sed -r 's/(.*) ([[:alpha:]]*)\;.*/\2/')
echo "[CMD] get the current time for this release"
release_time=$(LC_TIME=en_US.UTF-8 date +"%a, %d %b %Y %I:%M:%S %z")
echo "[CMD] update the changelog"
echo "nginx (${nginx_version}-${minor_version}${RELEASE_TAGS}) ${ubuntu_release}; urgency=low
* New release: ${RELEASE_MESSAGE}
"|cat - changelog > tmp && mv tmp changelog
echo "[CMD] Create a build"
cd ..
echo "[CMD] DONE!"
Copy link

hajdbo commented May 6, 2013

I added package dependency checks and made sure the LC_DATE is set to english, otherwise the changelog format is broken.

Copy link

@hajdbo just pulled in your changes :)

Copy link

Just pulled in changes from @fromonesrc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment