d49d75f5073294d798aa500728116309398bb535Andreas Gustafsson#!/bin/sh
d49d75f5073294d798aa500728116309398bb535Andreas Gustafsson#
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# Copyright (C) 2000-2004, 2007-2010, 2012-2016 Internet Systems Consortium, Inc. ("ISC")
bf8267aa453e5d2a735ed732a043b77a0b355b20Mark Andrews#
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# This Source Code Form is subject to the terms of the Mozilla Public
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# License, v. 2.0. If a copy of the MPL was not distributed with this
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# file, You can obtain one at http://mozilla.org/MPL/2.0/.
d49d75f5073294d798aa500728116309398bb535Andreas Gustafsson
ea94d370123a5892f6c47a97f21d1b28d44bb168Tinderbox User# $Id$
d49d75f5073294d798aa500728116309398bb535Andreas Gustafsson
d49d75f5073294d798aa500728116309398bb535Andreas Gustafsson# Make a release kit
d49d75f5073294d798aa500728116309398bb535Andreas Gustafsson#
eefe56c8b367d1e54361b0c55f9db9d9468a0d6aAndreas Gustafsson# Usage: sh kit.sh tag tmpdir
d49d75f5073294d798aa500728116309398bb535Andreas Gustafsson#
c4213ed935163b25bde9273a7c1a79a6296a0662Andreas Gustafsson# (e.g., sh kit.sh v9_0_0b5 /tmp/bindkit
c4213ed935163b25bde9273a7c1a79a6296a0662Andreas Gustafsson#
c4213ed935163b25bde9273a7c1a79a6296a0662Andreas Gustafsson# To build a snapshot release, use the pseudo-tag "snapshot".
c4213ed935163b25bde9273a7c1a79a6296a0662Andreas Gustafsson#
c4213ed935163b25bde9273a7c1a79a6296a0662Andreas Gustafsson# (e.g., sh kit.sh snapshot /tmp/bindkit
d49d75f5073294d798aa500728116309398bb535Andreas Gustafsson#
d49d75f5073294d798aa500728116309398bb535Andreas Gustafsson
11d37bfa8d5650edf5c36e618fa673a84180f5c9Mark Andrewsremote=--remote=repo.isc.org:/proj/git/prod/bind9.git
38bcbbf947f0611bcae2e127d004dab761770c64Mark Andrews
683e751c957d8b209cc393ff603bea937f5565b0Mark Andrewscase "${1:-}" in
683e751c957d8b209cc393ff603bea937f5565b0Mark Andrews--remote=*)
683e751c957d8b209cc393ff603bea937f5565b0Mark Andrews remote="${1}"
683e751c957d8b209cc393ff603bea937f5565b0Mark Andrews shift
683e751c957d8b209cc393ff603bea937f5565b0Mark Andrews ;;
683e751c957d8b209cc393ff603bea937f5565b0Mark Andrewsesac
683e751c957d8b209cc393ff603bea937f5565b0Mark Andrews
978c8d59cf84b7c8bd22b20a3cb3c2934bb670f5Mark Andrewsrepo=`expr "X${remote}X" : '^X--remote=\(.*\)X$'`
683e751c957d8b209cc393ff603bea937f5565b0Mark Andrews
d49d75f5073294d798aa500728116309398bb535Andreas Gustafssoncase $# in
38bcbbf947f0611bcae2e127d004dab761770c64Mark Andrews 3)
a60f32928e486c147fa66d74ba02eda74a5d1d42Mark Andrews case "$1" in
a60f32928e486c147fa66d74ba02eda74a5d1d42Mark Andrews snapshot) ;;
38bcbbf947f0611bcae2e127d004dab761770c64Mark Andrews *) echo "usage: sh kit.sh [snapshot] gittag tmpdir" >&2
a60f32928e486c147fa66d74ba02eda74a5d1d42Mark Andrews exit 1
a60f32928e486c147fa66d74ba02eda74a5d1d42Mark Andrews ;;
a60f32928e486c147fa66d74ba02eda74a5d1d42Mark Andrews esac
a60f32928e486c147fa66d74ba02eda74a5d1d42Mark Andrews snapshot=true;
38bcbbf947f0611bcae2e127d004dab761770c64Mark Andrews releasetag=$2
a60f32928e486c147fa66d74ba02eda74a5d1d42Mark Andrews tag=$2
a60f32928e486c147fa66d74ba02eda74a5d1d42Mark Andrews tmpdir=$3
38bcbbf947f0611bcae2e127d004dab761770c64Mark Andrews ;;
38bcbbf947f0611bcae2e127d004dab761770c64Mark Andrews 2)
38bcbbf947f0611bcae2e127d004dab761770c64Mark Andrews tag=$1
38bcbbf947f0611bcae2e127d004dab761770c64Mark Andrews tmpdir=$2
a60f32928e486c147fa66d74ba02eda74a5d1d42Mark Andrews case $tag in
a26e1cacef2047b1048febd5e8d756060b4bddb1Evan Hunt snapshot) tag=master; snapshot=true ; releasetag="" ;;
a60f32928e486c147fa66d74ba02eda74a5d1d42Mark Andrews *) snapshot=false ;;
a60f32928e486c147fa66d74ba02eda74a5d1d42Mark Andrews esac
a60f32928e486c147fa66d74ba02eda74a5d1d42Mark Andrews ;;
38bcbbf947f0611bcae2e127d004dab761770c64Mark Andrews *) echo "usage: sh kit.sh [snapshot] gittag tmpdir" >&2
d49d75f5073294d798aa500728116309398bb535Andreas Gustafsson exit 1
d49d75f5073294d798aa500728116309398bb535Andreas Gustafsson ;;
d49d75f5073294d798aa500728116309398bb535Andreas Gustafssonesac
d49d75f5073294d798aa500728116309398bb535Andreas Gustafsson
a26e1cacef2047b1048febd5e8d756060b4bddb1Evan Hunt# create tmpdir
d49d75f5073294d798aa500728116309398bb535Andreas Gustafssontest -d $tmpdir ||
d49d75f5073294d798aa500728116309398bb535Andreas Gustafssonmkdir $tmpdir || {
d49d75f5073294d798aa500728116309398bb535Andreas Gustafsson echo "$0: could not create directory $tmpdir" >&2
d49d75f5073294d798aa500728116309398bb535Andreas Gustafsson exit 1
d49d75f5073294d798aa500728116309398bb535Andreas Gustafsson}
d49d75f5073294d798aa500728116309398bb535Andreas Gustafsson
38bcbbf947f0611bcae2e127d004dab761770c64Mark Andrewscd $tmpdir || {
38bcbbf947f0611bcae2e127d004dab761770c64Mark Andrews echo "$0: cd $tmpdir failed"
38bcbbf947f0611bcae2e127d004dab761770c64Mark Andrews exit 1
38bcbbf947f0611bcae2e127d004dab761770c64Mark Andrews}
38bcbbf947f0611bcae2e127d004dab761770c64Mark Andrews
ad7312bf186989f16d3b168b73c88bbee3d19ba0Mark Andrewshash=`git ls-remote $repo refs/heads/$tag | awk '{print $1}'`
ad7312bf186989f16d3b168b73c88bbee3d19ba0Mark Andrewsif [ -z "$hash" ]; then
ad7312bf186989f16d3b168b73c88bbee3d19ba0Mark Andrews hash=`git ls-remote $repo refs/tags/$tag | awk '{print $1}'`
3a88873c5bd11ce50d2c0f8e2d74a933b58d16c4Mark Andrewsfi
ad7312bf186989f16d3b168b73c88bbee3d19ba0Mark Andrewsif [ -z "$hash" ]; then
3a88873c5bd11ce50d2c0f8e2d74a933b58d16c4Mark Andrews echo "Unable to determine hash for $tag, aborting."
3a88873c5bd11ce50d2c0f8e2d74a933b58d16c4Mark Andrews exit 1
3a88873c5bd11ce50d2c0f8e2d74a933b58d16c4Mark Andrewsfi
ad7312bf186989f16d3b168b73c88bbee3d19ba0Mark Andrewsshorthash=`echo $hash | cut -c1-7`
3a88873c5bd11ce50d2c0f8e2d74a933b58d16c4Mark Andrews
38bcbbf947f0611bcae2e127d004dab761770c64Mark Andrewsverdir=bind9-kit.$$
38bcbbf947f0611bcae2e127d004dab761770c64Mark Andrewsmkdir $verdir || {
38bcbbf947f0611bcae2e127d004dab761770c64Mark Andrews echo "$0: could not create directory $tmpdir/$verdir" >&2
38bcbbf947f0611bcae2e127d004dab761770c64Mark Andrews exit 1
38bcbbf947f0611bcae2e127d004dab761770c64Mark Andrews}
ad7312bf186989f16d3b168b73c88bbee3d19ba0Mark Andrewsgit archive --format=tar $remote $hash version | ( cd $verdir ;tar xf - )
38bcbbf947f0611bcae2e127d004dab761770c64Mark Andrewstest -f $verdir/version || {
38bcbbf947f0611bcae2e127d004dab761770c64Mark Andrews echo "$0: could not get 'version' file" >&2
38bcbbf947f0611bcae2e127d004dab761770c64Mark Andrews exit 1
38bcbbf947f0611bcae2e127d004dab761770c64Mark Andrews}
38bcbbf947f0611bcae2e127d004dab761770c64Mark Andrews. $verdir/version
d49d75f5073294d798aa500728116309398bb535Andreas Gustafsson
38bcbbf947f0611bcae2e127d004dab761770c64Mark Andrewsrm $verdir/version
38bcbbf947f0611bcae2e127d004dab761770c64Mark Andrewsrmdir $verdir
d49d75f5073294d798aa500728116309398bb535Andreas Gustafsson
c4213ed935163b25bde9273a7c1a79a6296a0662Andreas Gustafssonif $snapshot
c4213ed935163b25bde9273a7c1a79a6296a0662Andreas Gustafssonthen
c4213ed935163b25bde9273a7c1a79a6296a0662Andreas Gustafsson RELEASETYPE=s
aa5cb9ad9121de5b1ec90645038723df9e657720Mark Andrews RELEASEVER=${shorthash}
c4213ed935163b25bde9273a7c1a79a6296a0662Andreas Gustafssonfi
c4213ed935163b25bde9273a7c1a79a6296a0662Andreas Gustafsson
fd63f3110fe9a20d6188bc30ebf4b44595bac8eeMark Andrewsversion=${MAJORVER}.${MINORVER}${PATCHVER:+.}${PATCHVER}${RELEASETYPE}${RELEASEVER}${EXTENSIONS}
c4213ed935163b25bde9273a7c1a79a6296a0662Andreas Gustafsson
c4213ed935163b25bde9273a7c1a79a6296a0662Andreas Gustafssonecho "building release kit for BIND version $version, hold on..."
c4213ed935163b25bde9273a7c1a79a6296a0662Andreas Gustafsson
c4213ed935163b25bde9273a7c1a79a6296a0662Andreas Gustafssontopdir=bind-$version
d49d75f5073294d798aa500728116309398bb535Andreas Gustafsson
38bcbbf947f0611bcae2e127d004dab761770c64Mark Andrewstest ! -d $topdir || {
a26e1cacef2047b1048febd5e8d756060b4bddb1Evan Hunt echo "$0: directory $tmpdir/$topdir already exists" >&2
d49d75f5073294d798aa500728116309398bb535Andreas Gustafsson exit 1
d49d75f5073294d798aa500728116309398bb535Andreas Gustafsson}
d49d75f5073294d798aa500728116309398bb535Andreas Gustafsson
38bcbbf947f0611bcae2e127d004dab761770c64Mark Andrewsmkdir $topdir || exit 1
a26e1cacef2047b1048febd5e8d756060b4bddb1Evan Hunt
ad7312bf186989f16d3b168b73c88bbee3d19ba0Mark Andrewsgit archive --format=tar $remote $hash | ( cd $topdir; tar xf -)
d49d75f5073294d798aa500728116309398bb535Andreas Gustafsson
38bcbbf947f0611bcae2e127d004dab761770c64Mark Andrewscd $topdir || exit 1
d49d75f5073294d798aa500728116309398bb535Andreas Gustafsson
c4213ed935163b25bde9273a7c1a79a6296a0662Andreas Gustafssonif $snapshot
c4213ed935163b25bde9273a7c1a79a6296a0662Andreas Gustafssonthen
c4213ed935163b25bde9273a7c1a79a6296a0662Andreas Gustafsson cat <<EOF >version
c4213ed935163b25bde9273a7c1a79a6296a0662Andreas GustafssonMAJORVER=$MAJORVER
c4213ed935163b25bde9273a7c1a79a6296a0662Andreas GustafssonMINORVER=$MINORVER
c4213ed935163b25bde9273a7c1a79a6296a0662Andreas GustafssonPATCHVER=$PATCHVER
c4213ed935163b25bde9273a7c1a79a6296a0662Andreas GustafssonRELEASETYPE=$RELEASETYPE
c4213ed935163b25bde9273a7c1a79a6296a0662Andreas GustafssonRELEASEVER=$RELEASEVER
fd63f3110fe9a20d6188bc30ebf4b44595bac8eeMark AndrewsEXTENSIONS=$EXTENSIONS
c4213ed935163b25bde9273a7c1a79a6296a0662Andreas GustafssonEOF
c4213ed935163b25bde9273a7c1a79a6296a0662Andreas Gustafssonfi
c4213ed935163b25bde9273a7c1a79a6296a0662Andreas Gustafsson
d49d75f5073294d798aa500728116309398bb535Andreas Gustafsson# Omit some files and directories from the kit.
6e8a02d5d3a845ca1768e92c88bdc0a4da47f95bAndreas Gustafsson#
6e8a02d5d3a845ca1768e92c88bdc0a4da47f95bAndreas Gustafsson# Some of these directories (doc/html, doc/man...) no longer
6e8a02d5d3a845ca1768e92c88bdc0a4da47f95bAndreas Gustafsson# contain any files and should therefore be absent in the
6e8a02d5d3a845ca1768e92c88bdc0a4da47f95bAndreas Gustafsson# checked-out tree, but they did exist at some point and
6e8a02d5d3a845ca1768e92c88bdc0a4da47f95bAndreas Gustafsson# we still delete them from releases just in case something
6e8a02d5d3a845ca1768e92c88bdc0a4da47f95bAndreas Gustafsson# gets accidentally resurrected.
52f16aeb304bc13f6957e3ecf24c8c5b69991558Andreas Gustafsson
7d97663b2ca5b7b057276fc9d239025da80e4756Mark Andrewsrm -rf TODO EXCLUDED conftools doc/design doc/dev doc/draft doc/expired \
6306dd073e0eba562491222821c4d3b39f440718Evan Hunt doc/html doc/rfc doc/todo doc/private bin/lwresd doc/man doc/markdown \
3aab1703a5594e64b75d629427f1f1dd717cf5abScott Mann lib/lwres/man/resolver.5 contrib/zkt/doc/rfc5011.txt \
534253444e569bf039fb6e5fc31a5e8c2e8305c0Mark Andrews bin/tests/system/relay lib/cfg
52f16aeb304bc13f6957e3ecf24c8c5b69991558Andreas Gustafsson
1d761cb453c76353deb8423c78e98d00c5f86ffaEvan Hunt# Remove everything but mksymtbl.pl and bindkeys.pl from util
1d761cb453c76353deb8423c78e98d00c5f86ffaEvan Huntfind util -name bindkeys.pl -o -name mksymtbl.pl -prune -o -type f -print | xargs rm -f
05398561e0221fe1fef1457627a50c60bddbb022Mark Andrewsfind util -depth -type d -print | xargs rmdir 2>/dev/null
8a86c12ec245eb3838f48ffbc5a01fb9b7666a60Evan Hunt
a26e1cacef2047b1048febd5e8d756060b4bddb1Evan Hunt# Remove all .gitignore files
a26e1cacef2047b1048febd5e8d756060b4bddb1Evan Huntfind . -name .gitignore -print | xargs rm
d49d75f5073294d798aa500728116309398bb535Andreas Gustafsson
92e80317ea556ab5b9f90260b3799b35493daeddEvan Hunt# Remove branchsync.dat, if present
92e80317ea556ab5b9f90260b3799b35493daeddEvan Huntrm -f branchsync.dat
92e80317ea556ab5b9f90260b3799b35493daeddEvan Hunt
bcf966e6146943ebcac1603a52468f5292612b18Evan Hunt# populate srcid file
bcf966e6146943ebcac1603a52468f5292612b18Evan Huntecho "SRCID=$shorthash" > srcid
bcf966e6146943ebcac1603a52468f5292612b18Evan Hunt
2e286ac71f3621c11a3409f35a859488026b5fb5Mark Andrews# The following files should be executable.
61d7ab455fe6c2c1be112e7f48a768b9db1f65bbMark Andrewschmod +x configure install-sh mkinstalldirs bin/tests/system/ifconfig.sh
61d7ab455fe6c2c1be112e7f48a768b9db1f65bbMark Andrews# Fix up releases with libbind.
61d7ab455fe6c2c1be112e7f48a768b9db1f65bbMark Andrewsif test -f lib/bind/configure
61d7ab455fe6c2c1be112e7f48a768b9db1f65bbMark Andrewsthen
61d7ab455fe6c2c1be112e7f48a768b9db1f65bbMark Andrews chmod +x lib/bind/configure lib/bind/mkinstalldirs
61d7ab455fe6c2c1be112e7f48a768b9db1f65bbMark Andrewsfi
2e286ac71f3621c11a3409f35a859488026b5fb5Mark Andrews
c85ffa76df4b94e0c44b2924f7a7f2e875a1ea86Mark Andrews# Fix files which should be using DOS style newlines
c85ffa76df4b94e0c44b2924f7a7f2e875a1ea86Mark Andrewswindirs=`find lib bin -type d -name win32`
c85ffa76df4b94e0c44b2924f7a7f2e875a1ea86Mark Andrewswindirs="$windirs win32utils"
c85ffa76df4b94e0c44b2924f7a7f2e875a1ea86Mark Andrewswinnames="-name *.mak -or -name *.dsp -or -name *.dsw -or -name *.txt -or -name *.bat"
c85ffa76df4b94e0c44b2924f7a7f2e875a1ea86Mark Andrewsfor f in `find $windirs -type f \( $winnames \) -print`
c85ffa76df4b94e0c44b2924f7a7f2e875a1ea86Mark Andrewsdo
c85ffa76df4b94e0c44b2924f7a7f2e875a1ea86Mark Andrews awk '{sub("\r$", "", $0); printf("%s\r\n", $0);}' < $f > tmp
c85ffa76df4b94e0c44b2924f7a7f2e875a1ea86Mark Andrews touch -r $f tmp
c85ffa76df4b94e0c44b2924f7a7f2e875a1ea86Mark Andrews mv tmp $f
c85ffa76df4b94e0c44b2924f7a7f2e875a1ea86Mark Andrewsdone
c85ffa76df4b94e0c44b2924f7a7f2e875a1ea86Mark Andrews
4347f7ac1286aaa114935823c3cd59151de0166bMark Andrews# check that documentation has been updated properly; issue a warning
4347f7ac1286aaa114935823c3cd59151de0166bMark Andrews# if it hasn't
3d2ce18535b3d2d828bd40aec7f4686519f305feMark Andrewsok=
3d2ce18535b3d2d828bd40aec7f4686519f305feMark Andrewsfor f in doc/arm/*.html
3d2ce18535b3d2d828bd40aec7f4686519f305feMark Andrewsdo
3d2ce18535b3d2d828bd40aec7f4686519f305feMark Andrews if test "$f" -nt doc/arm/Bv9ARM-book.xml
3d2ce18535b3d2d828bd40aec7f4686519f305feMark Andrews then
3d2ce18535b3d2d828bd40aec7f4686519f305feMark Andrews ok=ok
3d2ce18535b3d2d828bd40aec7f4686519f305feMark Andrews fi
3d2ce18535b3d2d828bd40aec7f4686519f305feMark Andrewsdone
3d2ce18535b3d2d828bd40aec7f4686519f305feMark Andrews
3d2ce18535b3d2d828bd40aec7f4686519f305feMark Andrewsif test "$ok" != ok
4347f7ac1286aaa114935823c3cd59151de0166bMark Andrewsthen
4347f7ac1286aaa114935823c3cd59151de0166bMark Andrews echo "WARNING: ARM source is newer than the html version."
4347f7ac1286aaa114935823c3cd59151de0166bMark Andrewsfi
4347f7ac1286aaa114935823c3cd59151de0166bMark Andrews
4347f7ac1286aaa114935823c3cd59151de0166bMark Andrewsif test doc/arm/Bv9ARM-book.xml -nt doc/arm/Bv9ARM.pdf
4347f7ac1286aaa114935823c3cd59151de0166bMark Andrewsthen
4347f7ac1286aaa114935823c3cd59151de0166bMark Andrews echo "WARNING: ARM source is newer than the PDF version."
4347f7ac1286aaa114935823c3cd59151de0166bMark Andrewsfi
4347f7ac1286aaa114935823c3cd59151de0166bMark Andrews
4347f7ac1286aaa114935823c3cd59151de0166bMark Andrewsfor f in `find . -name "*.docbook" -print`
4347f7ac1286aaa114935823c3cd59151de0166bMark Andrewsdo
4347f7ac1286aaa114935823c3cd59151de0166bMark Andrews docbookfile=$f
4347f7ac1286aaa114935823c3cd59151de0166bMark Andrews htmlfile=${f%.docbook}.html
4347f7ac1286aaa114935823c3cd59151de0166bMark Andrews if test $docbookfile -nt $htmlfile
4347f7ac1286aaa114935823c3cd59151de0166bMark Andrews then
4347f7ac1286aaa114935823c3cd59151de0166bMark Andrews echo "WARNING: $docbookfile is newer than the html version."
4347f7ac1286aaa114935823c3cd59151de0166bMark Andrews fi
4347f7ac1286aaa114935823c3cd59151de0166bMark Andrewsdone
4347f7ac1286aaa114935823c3cd59151de0166bMark Andrews
4347f7ac1286aaa114935823c3cd59151de0166bMark Andrews# build the tarball
d49d75f5073294d798aa500728116309398bb535Andreas Gustafssoncd .. || exit 1
d49d75f5073294d798aa500728116309398bb535Andreas Gustafsson
d49d75f5073294d798aa500728116309398bb535Andreas Gustafssonkit=$topdir.tar.gz
1090574e9153ad41c403f812d9b6cef0334e828eMark Andrewstar -c -f - $topdir | gzip > $kit
d49d75f5073294d798aa500728116309398bb535Andreas Gustafssonecho "done, kit is in `pwd`/$kit"