#!/bin/sh -e
# The revision number; in the case of having multiple snapshots a day,
# the revision number can be incremented so as to minimize confusion
# This is only done when more than one snapshop is uploaded to the
# maradns.org server in a given day. Here at the top to be easy to change.
REVISION=1
# This script updates Deadwood 3.0
# To run this script, make sure that this script is in the directory
# containing the tarball for the version of Deadwood you wish to update, and
# all of the patches are in a directory entitled 'patches'.
CURRENT=${0%%-*}
CURRENT=${CURRENT##*/}
NEXT=${0##*-}
# Make a clean CURRENT install, which we rename NEXT
rm -fr deadwood-$CURRENT 2> /dev/null
rm -fr deadwood-$NEXT 2> /dev/null
echo extracting tarball
tar xjf deadwood-$CURRENT.tar.bz2
if [ $? != 0 ] ; then
echo run this from the correct directory
exit 1
fi
rm -fr deadwood-$NEXT*
mv deadwood-$CURRENT deadwood-$NEXT
cd deadwood-$NEXT
# The patches
mkdir update/$NEXT
if [ "$1" != "new" ] ; then
cp ../patches/deadwood-$CURRENT* update/$NEXT
#cp ../patches/maradns* update/$NEXT
#echo
fi
# Regenerate Deadwood's random prime number (always done)
echo Making new random prime
cd src
rm -f *orig # While we're here, remove any pesky .orig files
cc -o foo RandomPrime.c
./foo > DwRandPrime.h
rm foo
cd ..
# This is one of the few places where we will need to change anything
# in this script from version to version
# BEGIN Release-specific fixes and changes go here
# Fix issue with RFC2535 DNA packets being dropped
patch -p2 < update/3.2.06/deadwood-3.2.05-RFC2535.patch
# Fix GCC 4.8.2 warnings
patch -p2 < update/3.2.06/deadwood-3.2.05-GCC482.patch
# Make sure Version.h is dynamically generated if not present
patch -p2 < update/3.2.06/deadwood-3.2.05-versionh.patch
# Preserve original ID sent by client when sending SERVER FAIL
patch -p2 < update/3.2.06/deadwood-3.2.05-ID-mismatch.patch
# Do not send "server fail" when processing glueless NS referral
patch -p2 < update/3.2.06/deadwood-3.2.05-Server-fail.patch
# Extra protection from NS tarpits
patch -p0 < update/3.2.06/deadwood-3.2.05-ns_tarpit.patch
# Log IPs that are blocked
#cp src/DwSys.c src/DwSys.c.foog
patch -p1 < update/3.2.06/deadwood-3.2.05-Log_blocked_IP.patch
# Update SQA tests (example.com moved etc.)
patch -p1 < update/3.2.06/deadwood-3.2.05-sqa.patch
# CHANGELOG update
patch -p1 < update/3.2.06/deadwood-3.2.05-CHANGELOG.patch
# We're getting .orig files when patching :(
rm -f src/*.orig
# END Release-specific fixes/changes
# This script with the "orig" argument can used if making a release
# that is making changes to an already-patched version of Deadwood
# Change "orig" to "work" if implementing new features
if [ "$1" = "orig" ] ; then
cd src
for a in *.c *.h ; do
cp $a $a.orig
done
cd ..
cp doc/Deadwood.ej doc/Deadwood.ej.orig
fi
# Convert tabs in code to spaces, since this is inconsistant in different
# programs; disable when in "work" mode since it messes up patches
if [ "$1" != "work" ] ; then
echo removing tabs from source files
for a in $( find . -type f -name \*.[ch] ) ; do
col -x < $a > foo
if [ $? == 0 ] ; then
mv foo $a
fi
done
fi
chmod 755 src/make.version.h
echo updating documentation
# Update the documentation
cd doc
make
# Go back to the deadwood dir
cd ..
# Go one level higher than the toplevel directory to copy this script
# over
cd ..
# Put this script in the "build" directory
cp $0 deadwood-$NEXT/update/$NEXT
# Version number always current
cd deadwood-$NEXT/src
./make.version.h > version.h
cd ../..
if [ "$1" = "new" ] ; then
tar xjf deadwood-$CURRENT.tar.bz2
echo OK, both deadwood-$CURRENT and deadwood-$NEXT made\; you
echo now can start making patches.
exit 0
fi
if [ "$1" != "go" ] && [ "$1" != "snap" ] && [ "$1" != "work" ] ; then
echo OK, deadwood-$NEXT built. Confirm this compiles and
echo perform basic regression before re-running this to make
echo the tarballs. Once you have tested this, rerun this
echo script as: \"$0 go\" or as \"$0 snap\"
echo to make a daily snapshot
exit 0
fi
if [ "$1" = "work" ] ; then
tar xjf deadwood-$CURRENT.tar.bz2
echo OK, both deadwood-$CURRENT and deadwood-$NEXT made\; you
echo now can make more patches as needed.
cd deadwood-$NEXT/src
echo '#define VERSION "'$NEXT'-pre"' > version.h
cd ../..
exit 0
fi
# Build the tarballs
echo making new tarballs
if [ "$1" = "snap" ] ; then
SNAP=S-$( date +%Y-%m-%d )-$REVISION
rm -fr deadwood-$SNAP
mv deadwood-$NEXT deadwood-$SNAP
cd deadwood-$SNAP/src
./make.version.h > version.h
cd ../..
# Alas, my ancient msys environment doesn't have xz
tar cjf deadwood-$SNAP.tar.bz2 deadwood-$SNAP
#tar cJf deadwood-$SNAP.tar.xz deadwood-$SNAP
exit 0
else
SNAP=$NEXT
cd deadwood-$NEXT/src
./make.version.h > version.h
cd ../..
tar cjf deadwood-$NEXT.tar.bz2 deadwood-$NEXT
tar cJf deadwood-$NEXT.tar.xz deadwood-$NEXT
fi
exit 0 # Done