kit.sh 4.76 KB
Newer Older
1
2
#!/bin/sh
#
3
# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
Mark Andrews's avatar
Mark Andrews committed
4
#
5
6
7
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
8
9
10
#
# See the COPYRIGHT file distributed with this work for additional
# information regarding copyright ownership.
11
12
13

# Make a release kit
#
14
# Usage: sh kit.sh tag tmpdir
15
#
16
17
18
19
20
#    (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
21
22
#

23
remote=--remote=git@gitlab.isc.org:isc-projects/bind9.git
24

25
26
27
28
29
30
31
case "${1:-}" in
--remote=*)
	remote="${1}"
	shift
	;;
esac

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

34
case $# in
35
    3)
36
37
	case "$1" in
	snapshot) ;;
38
	*) echo "usage: sh kit.sh [snapshot] gittag tmpdir" >&2
39
40
41
42
	   exit 1
	   ;;
	esac
	snapshot=true;
43
	releasetag=$2
44
45
	tag=$2
	tmpdir=$3
46
47
48
49
	;;
    2)
	tag=$1
	tmpdir=$2
50
	case $tag in
Evan Hunt's avatar
Evan Hunt committed
51
	    snapshot) tag=master; snapshot=true ; releasetag="" ;;
52
53
54
	    *) snapshot=false ;;
	esac
	;;
55
    *) echo "usage: sh kit.sh [snapshot] gittag tmpdir" >&2
56
57
58
59
       exit 1
       ;;
esac

Evan Hunt's avatar
Evan Hunt committed
60
# create tmpdir
61
62
63
64
65
66
test -d $tmpdir ||
mkdir $tmpdir || {
    echo "$0: could not create directory $tmpdir" >&2
    exit 1
}

67
68
69
70
71
cd $tmpdir || {
	echo "$0: cd $tmpdir failed"
	exit 1
}

Mark Andrews's avatar
Mark Andrews committed
72
73
74
hash=`git ls-remote $repo refs/heads/$tag | awk '{print $1}'`
if [ -z "$hash" ]; then
        hash=`git ls-remote $repo refs/tags/$tag | awk '{print $1}'`
75
fi
Mark Andrews's avatar
Mark Andrews committed
76
if [ -z "$hash" ]; then
77
78
79
        echo "Unable to determine hash for $tag, aborting."
        exit 1
fi
Mark Andrews's avatar
Mark Andrews committed
80
shorthash=`echo $hash | cut -c1-7`
81

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

94
95
rm $verdir/version
rmdir $verdir
96

97
98
99
if $snapshot
then
    RELEASETYPE=s
100
    RELEASEVER=${shorthash}
101
102
fi

103
version=${MAJORVER}.${MINORVER}${PATCHVER:+.}${PATCHVER}${RELEASETYPE}${RELEASEVER}${EXTENSIONS}
104
105
106
107

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

topdir=bind-$version
108

109
test ! -d $topdir || {
Evan Hunt's avatar
Evan Hunt committed
110
    echo "$0: directory $tmpdir/$topdir already exists" >&2
111
112
113
    exit 1
}

114
mkdir $topdir || exit 1
Evan Hunt's avatar
Evan Hunt committed
115

116
git archive --format=tar $remote $tag | ( cd $topdir; tar xf -)
117

118
cd $topdir || exit 1
119

120
121
122
123
124
125
126
127
if $snapshot
then
    cat <<EOF >version
MAJORVER=$MAJORVER
MINORVER=$MINORVER
PATCHVER=$PATCHVER
RELEASETYPE=$RELEASETYPE
RELEASEVER=$RELEASEVER
128
EXTENSIONS=$EXTENSIONS
129
130
131
EOF
fi

132
# Omit some files and directories from the kit.
133
134
135
136
137
138
#
# 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.
139

Mark Andrews's avatar
Mark Andrews committed
140
rm -rf TODO EXCLUDED conftools doc/design doc/dev doc/draft doc/expired \
141
142
    doc/html doc/rfc doc/todo doc/private doc/man doc/markdown \
    contrib/zkt/doc/rfc5011.txt \
143
    bin/tests/system/relay lib/cfg
144

Evan Hunt's avatar
Evan Hunt committed
145
146
# Remove everything but mksymtbl.pl and bindkeys.pl from util
find util -name bindkeys.pl -o -name mksymtbl.pl -prune -o -type f -print | xargs rm -f
Mark Andrews's avatar
Mark Andrews committed
147
find util -depth -type d -print | xargs rmdir 2>/dev/null
148

Evan Hunt's avatar
Evan Hunt committed
149
150
# Remove all .gitignore files
find . -name .gitignore -print | xargs rm
151

Evan Hunt's avatar
Evan Hunt committed
152
153
154
# Remove branchsync.dat, if present
rm -f branchsync.dat

155
156
157
# populate srcid file
echo "SRCID=$shorthash" > srcid

158
# The following files should be executable.
Mark Andrews's avatar
Mark Andrews committed
159
160
161
162
163
164
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
165

166
167
168
169
170
171
172
173
174
175
176
# 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

177
178
# check that documentation has been updated properly; issue a warning
# if it hasn't
179
180
181
182
183
184
185
186
187
188
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
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
209
210
211
cd .. || exit 1

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