summaryrefslogtreecommitdiff
path: root/util/bind.sh
blob: c873de7c1585da04b87171cfaee0d13613d92a3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#!/bin/sh
#
# Copyright (C) 2009-2020  Internet Systems Consortium, Inc. ("ISC")
#
# 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/.
#
# 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.

#
# Get the bind sources from BIND9 repository.
# This script is used to build the DHCP distribution and shouldn't be shipped
#
# Usage (from main DHCP directory):
#
# sh util/bind.sh [--remote=<path>] <DHCP version>
#
# The script recreates whole bind/ directory. Before running it, make sure
# there are no files that that'd you'd be unhappy to lose.
#
# Earlier versions of this script used BIND's kit.sh script that produced
# tarballs for export libraries. Sadly, it was not maintained well and
# didn't work for later versions. Thus the import has changed. It now uses
# git clone/git checkout <tag> to get the bind sources.
#
# This approach imports all files from BIND9 repo (including those we don't
# care about, such as win32 files). As a result of this, the dhcp tarball
# will get a bit bigger. On the flip side, the import is super generic
# and can import any versions, you have the ability to review changes
# before commiting them and it's also very easy to tell what exactly
# has changed between BIND releases.

# BIND9 update procedure
#
# 1. Get a clean DHCP repo. Cloning fresh works best, but you could also
#    do: git reset --hard; git checkout master; git clean -fxd
# 2. edit the list with corresponding versions below (around line 100)
# 3. do: sh util/bind.sh 4.4.3
# 4. commit all new and changed files in bind/bind9. NOTE: there is a
#    bind/bind9/.gitignore that comes from bind repo that hides some
#    of the files. Make sure you commit only those that are really
#    needed, not some generated during compilation.
# 5. test that it compiles, dist, distcheck works etc.
# 6. push your changes

topdir=`pwd`
binddir=$topdir/bind

# repo_host and repo_path are used together to from urls for wget calls
# to fetch the version and kit.sh files, and then also as the --remote
# argument passed into kit.sh
repo_host="gitlab.isc.org"
repo_path="isc-projects/bind9"

while :
do
	case "${1:-}" in
	--repo_host=*)
		repo_host="${1}";
		shift
		continue
		;;
	--repo_path=*)
		repo_path="${1}";
		shift
		continue
		;;
	esac
	break;
done

case $# in
    1)
	case "$1" in
	###
	### Robie calls this script with the building branch name so we can
	### build with BIND9 HEAD for the relevant branch we would release
	### with.
	###
	### XXX: We can't use the 'snapshot' syntax right now because kit.sh
	### pulls the version.tmp off the branch name, and then stores a
	### tarball with vastly different values.  So the version.tmp can not
	### be used to chdir down into the directory that is unpacked.
	###
	v4_2) noSNAP=snapshot BINDTAG=v9_9 ;;
	v4_3) noSNAP=snapshot BINDTAG=v9_9 ;;
	v4_4) noSNAP=snapshot BINDTAG=v9_11 ;;
	HEAD|v[0-9]_[0-9].*) noSNAP=snapshot BINDTAG=v9_11 ;;
	### HEAD|v[0-9]_[0-9].*) noSNAP=snapshot BINDTAG=HEAD ;;
	###
	### For ease of use, this records the sticky tag of versions
	### released with each point release.
	###
	4.4.3) BINDTAG=v9_11_36 ;;
	4.4.2) noSNAP=snapshot BINDTAG=v9_11_14 ;;
	4.4.2b1) noSNAP=snapshot BINDTAG=v9_11_14 ;;
	4.4.2-dev) noSNAP=snapshot BINDTAG=v9_11_8 ;;
	4.4.1) noSNAP=snapshot BINDTAG=v9_11_2_P1 ;;
	4.4.0) noSNAP=snapshot BINDTAG=v9_11_2_P1 ;;
	4.4.0b1) noSNAP=snapshot BINDTAG=v9_11_2 ;;
	4.4.0a1) noSNAP=snapshot BINDTAG=v9_11_2 ;;
	4.3.4|4.3.4b1) BINDTAG=v9_9_8_P4 ;;
	4.3.3) BINDTAG=v9_9_7_P3 ;;
	4.3.3b1) BINDTAG=v9_9_7_P2 ;;
	4.3.2|4.3.2rc2) BINDTAG=v9_9_7 ;;
	4.3.2rc1) BINDTAG=v9_9_7rc2 ;;
	4.3.2b1) BINDTAG=v9_9_7rc1 ;;
	4.3.2.pre-beta) BINDTAG=v9_9_5_P1 ;;
	4.3.1b1|4.3.1rc1|4.3.1) BINDTAG=v9_9_5_P1 ;;
	4.3.0) BINDTAG=v9_9_5 ;;
	4.3.0rc1) BINDTAG=v9_9_5rc2 ;;
	4.3.0b1) BINDTAG=v9_9_5rc1 ;;
	4.3.0a1) BINDTAG=v9_9_5b1 ;;
	4.2.6) BINDTAG=v9_9_5 ;;
	4.2.6rc1) BINDTAG=v9_9_5rc2 ;;
	4.2.6b1) BINDTAG=v9_9_5rc1 ;;
	4.2.5b1|4.2.5rc1|4.2.5) BINDTAG=v9_8_4_P1 ;;
	4.2.4rc2|4.2.4) BINDTAG=v9_8_3 ;;
	4.2.4b1|4.2.4rc1) BINDTAG=v9_8_2 ;;
	4.2.3-P1|4.2.3-P2) BINDTAG=v9_8_1_P1 ;;
	4.2.3rc1|4.2.3) BINDTAG=v9_8_1 ;;
	4.2.2rc1|4.2.2) BINDTAG=v9_8_0_P4 ;;
	4.2.1|4.2.1-P1|4.2.2b1) BINDTAG=v9_8_0 ;;
	4.2.1rc1) BINDTAG=v9_8_0rc1 ;;
	4.2.1b1) BINDTAG=v9_8_0b1 ;;
	4.2.0rc1|4.2.0) BINDTAG=v9_7_1 ;;
	4.2.0b2) BINDTAG=v9_7_1rc1 ;;
	4.2.0b1) BINDTAG=v9_7_0_P1 ;;
	4.2.0a2|4.2.0a1) BINDTAG=v9_7_0b3 ;;
	*) echo "bind.sh: unsupported version: $1" >&2
	   exit 1
	   ;;
	esac
	;;
    *) echo "usage: sh bind.sh [--repo_host=<host>] [--repo_path=<project path>] ( <branch>|<version> )" >&2
       exit 1
       ;;
esac

echo "Getting BIND9 version ${BINDTAG}"

if test -d bind/bind9/.git
then
	echo "Detected existing bind9 repo"
	cd bind/bind9
	git reset --hard
	git clean -fxd
	git checkout main
	git branch -D $BINDTAG
	git pull --ff-only
	git checkout $BINDTAG -b $BINDTAG
else
	echo "Checking out a new repo"
	# Delete all previous bind stuff
	rm -rf bind

	# Make and move to our directory for all things bind
	mkdir -p $binddir
	cp util/Makefile.bind.in bind/Makefile.in
	cd $binddir

	# Get the bind code of specified version. Couple tricks here:
	# --single-branch will download only a history from a single branch (see --branch)
	# --depth 1 will get only the latest commit
	# As a result, the repo will take 68MB rather than 360MB+.
	#git clone --depth 1 https://$repo_host/$repo_path --branch ${BINDTAG} --single-branch bind9
	git clone https://$repo_host/$repo_path bind9
	cd bind9
	git checkout $BINDTAG -b $BINDTAG
fi

cd ..

# This is a bit drastic, but we don't want this 300MB+ dir to ever be commited
# into dhcp repo. Also, when it's present, it confuses git to think that the
# bind/bind9 is a sub-project.
rm -rf bind9/.git

# Now generate version
# I'm too lazy to get rid of v from v9 in the bindtag. But that's ok.
# We'll never have any other number here than 9.
MAJORVER="9"
MINORVER="$(echo ${BINDTAG} | cut -d'_' -f2)"
PATCHVER="$(echo ${BINDTAG} | cut -d'_' -f3)"
RELEASETYPE=
RELEASEVER=
EXTENSIONS=

cat <<EOF >version.tmp
# This file must follow /bin/sh rules.  It is imported directly via
# configure.
#
PRODUCT=BIND
DESCRIPTION="(Extended Support Version)"
MAJORVER=${MAJORVER}
MINORVER=${MINORVER}
PATCHVER=${PATCHVER}
RELEASETYPE=${RELEASETYPE}
RELEASEVER=${RELEASEVER}
EXTENSIONS=${EXTENSIONS}
EOF

cd ..

echo "BIND9 ${BINDTAG} import complete."
echo "BIND9 sources available in bind/bind9."
echo "If you want to commit them to dhcp repository, do the following:"
echo ""
echo "1. git add <all new and changes files in bind/bind9>"
echo "2. git commit"
echo ""
echo "Before commiting, please make sure the code compiles and works."
echo "Before compiling, make sure to run ./configure."