#!/bin/bash
# Rebuild Debian Stable Nginx Package (and slip in a new version) and
# just maybe a slightly different build...

# Please don't use this. If you run this you are on your own. Seriously.

NEWVERSION=0.6.29
OLDVERSION=0.4.13
TOP=/home/dwilson/rebuild

mkdir -p $TOP ; cd $TOP

# grab the prep packages # shouldn't repeat but bah.
sudo apt-get install build-essential devscripts fakeroot
sudo apt-get build-dep nginx

mkdir -p nginx-debian ; cd nginx-debian
apt-get source nginx  # don't need root for this

cd $TOP
mkdir -p nginx-new ; cd nginx-new

# get the nginx source
wget http://sysoev.ru/nginx/nginx-${NEWVERSION}.tar.gz && tar -zxvf *.tar.gz

# grab the debian magic packaging stuff
cd $TOP
cp -a nginx-debian/nginx-${OLDVERSION}/debian/ nginx-new/nginx-${NEWVERSION}/

cd nginx-new/nginx-${NEWVERSION}/
mv ../nginx-${NEWVERSION}.tar.gz ../nginx_${NEWVERSION}.orig.tar.gz

DEBFULLNAME="Dean Wilson"
DEBEMAIL=dwilson@example.com
dch --fromdirname "NMU Rebuild of package and insertion of newer source code"

debuild -us -uc

############### Add SSL Support

# apt-get install libssl-dev
#
#Change config line -  vi rebuild/nginx-new/nginx-0.6.29/debian/rules
# - add ssl support (--with-http_ssl_module)
# - debuild -us -uc
