kit.sh 5.32 KB
Newer Older
1
2
#!/bin/sh
#
Tinderbox User's avatar
Tinderbox User committed
3
# Copyright (C) 2004, 2007-2010, 2012, 2013  Internet Systems Consortium, Inc. ("ISC")
Mark Andrews's avatar
Mark Andrews committed
4
5
6
7
8
9
10
11
12
13
14
15
16
# Copyright (C) 2000-2003  Internet Software Consortium.
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
17

Tinderbox User's avatar
Tinderbox User committed
18
# $Id$
19
20
21

# Make a release kit
#
22
# Usage: sh kit.sh tag tmpdir
23
#
24
25
26
27
28
#    (e.g., sh kit.sh v9_0_0b5 /tmp/bindkit
#
# To build a snapshot release, use the pseudo-tag "snapshot".
#
#   (e.g., sh kit.sh snapshot /tmp/bindkit
29
30
#

31
32
remote=--remote=cvs.isc.org:/proj/git/prod/bind9.git

33
34
35
36
37
38
39
case "${1:-}" in
--remote=*)
	remote="${1}"
	shift
	;;
esac

Mark Andrews's avatar
Mark Andrews committed
40
repo=`expr "X${remote}X" : '^X--remote=\(.*\)X$'`
41

42
case $# in
43
    3)
44
45
	case "$1" in
	snapshot) ;;
46
	*) echo "usage: sh kit.sh [snapshot] gittag tmpdir" >&2
47
48
49
50
	   exit 1
	   ;;
	esac
	snapshot=true;
51
	releasetag=$2
52
53
	tag=$2
	tmpdir=$3
54
55
56
57
	;;
    2)
	tag=$1
	tmpdir=$2
58
	case $tag in
Evan Hunt's avatar
Evan Hunt committed
59
	    snapshot) tag=master; snapshot=true ; releasetag="" ;;
60
61
62
	    *) snapshot=false ;;
	esac
	;;
63
    *) echo "usage: sh kit.sh [snapshot] gittag tmpdir" >&2
64
65
66
67
       exit 1
       ;;
esac

Evan Hunt's avatar
Evan Hunt committed
68
# create tmpdir
69
70
71
72
73
74
test -d $tmpdir ||
mkdir $tmpdir || {
    echo "$0: could not create directory $tmpdir" >&2
    exit 1
}

75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
cd $tmpdir || {
	echo "$0: cd $tmpdir failed"
	exit 1
}

verdir=bind9-kit.$$
mkdir $verdir || {
    echo "$0: could not create directory $tmpdir/$verdir" >&2
    exit 1
}
git archive --format=tar $remote $tag version | ( cd $verdir ;tar xf - )
test -f $verdir/version || {
    echo "$0: could not get 'version' file" >&2
    exit 1
}
. $verdir/version
91

92
93
rm $verdir/version
rmdir $verdir
94

95
96
if $snapshot
then
97
98
    set `date -u +'%Y%m%d%H%M%S %Y/%m/%d %H:%M:%S UTC'`
    dstamp=$1
99
    RELEASETYPE=s
100
    RELEASEVER=${dstamp}${releasetag}
101
    shift
Mark Andrews's avatar
Mark Andrews committed
102
    case $tag in
Evan Hunt's avatar
Evan Hunt committed
103
    master)
Mark Andrews's avatar
Mark Andrews committed
104
105
106
107
108
109
	tag="$@"
	;;
    *)
	tag="$@"
	;;
    esac
110
111
fi

Mark Andrews's avatar
Mark Andrews committed
112
version=${MAJORVER}.${MINORVER}${PATCHVER:+.}${PATCHVER}${RELEASETYPE}${RELEASEVER}
113
114
115
116

echo "building release kit for BIND version $version, hold on..."

topdir=bind-$version
117

118
test ! -d $topdir || {
Evan Hunt's avatar
Evan Hunt committed
119
    echo "$0: directory $tmpdir/$topdir already exists" >&2
120
121
122
    exit 1
}

123
mkdir $topdir || exit 1
Evan Hunt's avatar
Evan Hunt committed
124

125
git archive --format=tar $remote $tag | ( cd $topdir; tar xf -)
126
shorthash=`git ls-remote $repo refs/heads/$tag | cut -c1-8`
127
128
129
130
131
132
133
if [ -z "$shorthash" ]; then
        shorthash=`git ls-remote $repo refs/tags/$tag | cut -c1-8`
fi
if [ -z "$shorthash" ]; then
        echo "Unable to determine hash for $tag, aborting."
        exit 1
fi
134

135
cd $topdir || exit 1
136

137
138
139
140
141
142
143
144
145
146
147
if $snapshot
then
    cat <<EOF >version
MAJORVER=$MAJORVER
MINORVER=$MINORVER
PATCHVER=$PATCHVER
RELEASETYPE=$RELEASETYPE
RELEASEVER=$RELEASEVER
EOF
fi

148
# Omit some files and directories from the kit.
149
150
151
152
153
154
#
# Some of these directories (doc/html, doc/man...) no longer
# contain any files and should therefore be absent in the
# checked-out tree, but they did exist at some point and
# we still delete them from releases just in case something 
# gets accidentally resurrected.
155

Mark Andrews's avatar
Mark Andrews committed
156
157
rm -rf TODO EXCLUDED conftools doc/design doc/dev doc/draft doc/expired \
    doc/html doc/rfc doc/todo doc/private bin/lwresd doc/man \
158
    lib/lwres/man/resolver.5 contrib/zkt/doc/rfc5011.txt \
159
    bin/tests/system/relay lib/cfg
160

161
# Remove everything but mksymtbl.pl from util
162
find util -name mksymtbl.pl -prune -o -type f -print | xargs rm -f
Mark Andrews's avatar
Mark Andrews committed
163
find util -depth -type d -print | xargs rmdir 2>/dev/null
164

Evan Hunt's avatar
Evan Hunt committed
165
166
# Remove all .gitignore files
find . -name .gitignore -print | xargs rm
167

Evan Hunt's avatar
Evan Hunt committed
168
169
170
# Remove branchsync.dat, if present
rm -f branchsync.dat

171
172
173
# populate srcid file
echo "SRCID=$shorthash" > srcid

174
# The following files should be executable.
Mark Andrews's avatar
Mark Andrews committed
175
176
177
178
179
180
chmod +x configure install-sh mkinstalldirs bin/tests/system/ifconfig.sh
# Fix up releases with libbind.
if test -f lib/bind/configure
then
	 chmod +x lib/bind/configure lib/bind/mkinstalldirs
fi
181

182
183
184
185
186
187
188
189
190
191
192
# Fix files which should be using DOS style newlines
windirs=`find lib bin -type d -name win32`
windirs="$windirs win32utils"
winnames="-name *.mak -or -name *.dsp -or -name *.dsw -or -name *.txt -or -name *.bat"
for f in `find $windirs -type f \( $winnames \) -print`
do
	awk '{sub("\r$", "", $0); printf("%s\r\n", $0);}' < $f > tmp
	touch -r $f tmp
	mv tmp $f
done

193
194
# check that documentation has been updated properly; issue a warning
# if it hasn't
195
196
197
198
199
200
201
202
203
204
ok=
for f in doc/arm/*.html
do
	if test "$f" -nt doc/arm/Bv9ARM-book.xml
	then
		ok=ok
	fi
done

if test "$ok" != ok
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
then
	echo "WARNING: ARM source is newer than the html version."
fi

if test doc/arm/Bv9ARM-book.xml -nt doc/arm/Bv9ARM.pdf
then
	echo "WARNING: ARM source is newer than the PDF version."
fi

for f in `find . -name "*.docbook" -print`
do
	docbookfile=$f
	htmlfile=${f%.docbook}.html
	if test $docbookfile -nt $htmlfile
	then
		echo "WARNING: $docbookfile is newer than the html version."
	fi
done

# build the tarball
225
226
227
cd .. || exit 1

kit=$topdir.tar.gz
Mark Andrews's avatar
Mark Andrews committed
228
tar -c -f - $topdir | gzip > $kit
229
echo "done, kit is in `pwd`/$kit"