forked from NLnetLabs/unbound
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makedist.sh
executable file
·595 lines (535 loc) · 21.3 KB
/
makedist.sh
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
#!/bin/sh
# Build unbound distribution tar from the git repository.
#
# Copyright (c) 2007, NLnet Labs. All rights reserved.
#
# This software is open source.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# Neither the name of the NLNET LABS nor the names of its contributors may
# be used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# Abort script on unexpected errors.
set -e
# Remember the current working directory.
cwd=`pwd`
# Utility functions.
usage () {
cat >&2 <<EOF
Usage $0: [-h] [-s] [-u git_url] [-b git_branch] [-w ...args...]
Generate a distribution tar file for unbound.
-h This usage information.
-s Build a snapshot distribution file. The current date is
automatically appended to the current unbound version number.
-rc <nr> Build a release candidate, the given string will be added
to the version number
(which will then be unbound-<version>rc<number>)
-u git_url Retrieve the source from the specified repository url.
Detected from the working copy if not specified.
-b git_branch Retrieve the the specified branch or tag.
Detected from the working copy if not specified.
-wssl openssl.xx.tar.gz Also build openssl from tarball for windows dist.
-wxp expat.xx.tar.gz Also build expat from tarball for windows dist.
-w32 32bit windows compile.
-w ... Build windows binary dist. last args passed to configure.
EOF
exit 1
}
info () {
echo "$0: info: $1"
}
error () {
echo "$0: error: $1" >&2
exit 1
}
question () {
printf "%s (y/n) " "$*"
read answer
case "$answer" in
[Yy]|[Yy][Ee][Ss])
return 0
;;
*)
return 1
;;
esac
}
# Only use cleanup and error_cleanup after generating the temporary
# working directory.
cleanup () {
info "Deleting temporary working directory."
cd $cwd && rm -rf $temp_dir
}
error_cleanup () {
echo "$0: error: $1" >&2
cleanup
exit 1
}
replace_text () {
(cp "$1" "$1".orig && \
sed -e "s/$2/$3/g" < "$1".orig > "$1" && \
rm "$1".orig) || error_cleanup "Replacement for $1 failed."
}
replace_all () {
info "Updating '$1' with the version number."
replace_text "$1" "@version@" "$version"
info "Updating '$1' with today's date."
replace_text "$1" "@date@" "`date +'%b %e, %Y'`"
}
replace_version () {
local v1=`echo $2 | sed -e 's/^.*\..*\.//'`
local v2=`echo $3 | sed -e 's/^.*\..*\.//'`
replace_text "$1" "VERSION_MICRO\],\[$v1" "VERSION_MICRO\],\[$v2"
}
check_git_repo () {
# Check if git repo and branch are specified.
if [ -z "$GITREPO" ]; then
if git status 2>&1 | grep "not a git repository" >/dev/null; then
error "specify repo (using -u) or use settings detected by starting from working copy directory"
else
GITREPO="`git config --get remote.origin.url`"
fi
fi
if [ -z "$GITBRANCH" ]; then
if git status 2>&1 | grep "not a git repository" >/dev/null; then
error "specify branch (using -b) or use settings detected by starting from working copy directory"
else
GITBRANCH="`git branch | grep '^\*' | sed -e 's/^\* //'`"
fi
fi
}
create_temp_dir () {
# Creating temp directory
info "Creating temporary working directory"
temp_dir=`mktemp -d unbound-dist-XXXXXX`
info "Directory '$temp_dir' created."
cd $temp_dir
}
# pass filename as $1 arg.
# creates file.sha1 and file.sha256
storehash () {
case $OSTYPE in
linux*)
sha=`sha1sum $1 | awk '{ print $1 }'`
sha256=`sha256sum $1 | awk '{ print $1 }'`
;;
freebsd*)
sha=`sha1 $1 | awk '{ print $5 }'`
sha256=`sha256 $1 | awk '{ print $5 }'`
;;
*)
# in case $OSTYPE is gone.
case `uname` in
Linux*)
sha=`sha1sum $1 | awk '{ print $1 }'`
sha256=`sha256sum $1 | awk '{ print $1 }'`
;;
FreeBSD*)
sha=`sha1 $1 | awk '{ print $5 }'`
sha256=`sha256 $1 | awk '{ print $5 }'`
;;
*)
sha=`sha1sum $1 | awk '{ print $1 }'`
sha256=`sha256sum $1 | awk '{ print $1 }'`
;;
esac
;;
esac
echo $sha > $1.sha1
echo $sha256 > $1.sha256
echo "hash of $1.{sha1,sha256}"
echo "sha1 $sha"
echo "sha256 $sha256"
}
SNAPSHOT="no"
RC="no"
DOWIN="no"
W64="yes"
WINSSL=""
WINEXPAT=""
MINJ=""
# Parse the command line arguments.
while [ "$1" ]; do
case "$1" in
"-h")
usage
;;
"-u")
GITREPO="$2"
shift
;;
"-b")
GITBRANCH="$2"
shift
;;
"-s")
SNAPSHOT="yes"
;;
"-wssl")
WINSSL="$2"
shift
;;
"-wxp")
WINEXPAT="$2"
shift
;;
"-w32")
W64="no"
;;
"-w")
DOWIN="yes"
shift
break
;;
"-rc")
RC="$2"
shift
;;
*)
error "Unrecognized argument -- $1"
;;
esac
shift
done
if [ "$DOWIN" = "yes" ]; then
# detect crosscompile, from Fedora13 at this point.
if test "`uname`" = "Linux"; then
info "Crosscompile windows dist"
cross="yes"
if test "$W64" = "yes"; then
warch="x86_64" # i686 for 32bit, or x86_64 for 64bit
mw64="mingw64" # mingw32 or mingw64
else
warch="i686"
mw64="mingw32"
fi
configure="${mw64}-configure" # mingw32-configure, mingw64-configure
strip="${warch}-w64-mingw32-strip"
makensis="makensis" # from mingw32-nsis package
# flags for crosscompiled dependency libraries
cross_flag=""
shared_cross_flag=""
check_git_repo
create_temp_dir
# crosscompile openssl for windows.
if test -n "$WINSSL"; then
info "Cross compile $WINSSL"
info "winssl tar unpack"
(cd ..; gzip -cd $WINSSL) | tar xf - || error_cleanup "tar unpack of $WINSSL failed"
sslinstall="`pwd`/sslinstall"
cp -r openssl-* openssl_shared
cd openssl-* || error_cleanup "no openssl-X dir in tarball"
# configure for crosscompile, without CAPI because it fails
# cross-compilation and it is not used anyway
# before 1.0.1i need --cross-compile-prefix=i686-w64-mingw32-
if test "$mw64" = "mingw64"; then
sslflags="no-asm -DOPENSSL_NO_CAPIENG mingw64"
sspdll="/usr/x86_64-w64-mingw32/sys-root/mingw/bin/libssp-0.dll"
else
sslflags="no-asm -DOPENSSL_NO_CAPIENG mingw"
sspdll="/usr/i686-w64-mingw32/sys-root/mingw/bin/libssp-0.dll"
fi
if test -f "$sspdll"; then
# stack protector lib needs to link in to make
# -lws2_32 work in openssl link stage
SSPLIB="-l:libssp.a"
else
# disable SSPLIB if no such file
SSPLIB=""
fi
info "winssl: Configure no-shared $sslflags"
set -x # echo the configure command
__CNF_LDLIBS=$SSPLIB CC=${warch}-w64-mingw32-gcc AR=${warch}-w64-mingw32-ar RANLIB=${warch}-w64-mingw32-ranlib WINDRES=${warch}-w64-mingw32-windres ./Configure --prefix="$sslinstall" no-shared $sslflags || error_cleanup "OpenSSL Configure failed"
set +x
info "winssl: make"
make $MINJ || error_cleanup "OpenSSL crosscompile failed"
# only install sw not docs, which take a long time.
info "winssl: make install_sw"
make install_sw || error_cleanup "OpenSSL install failed"
cross_flag="$cross_flag --with-ssl=$sslinstall"
cd ..
# shared compile
sslsharedinstall="`pwd`/sslsharedinstall"
cd openssl_shared
info "winssl: Configure shared $sslflags"
set -x # echo the configure command
__CNF_LDLIBS=$SSPLIB CC=${warch}-w64-mingw32-gcc AR=${warch}-w64-mingw32-ar RANLIB=${warch}-w64-mingw32-ranlib WINDRES=${warch}-w64-mingw32-windres ./Configure --prefix="$sslsharedinstall" shared $sslflags || error_cleanup "OpenSSL Configure failed"
set +x
info "winssl: make"
make $MINJ || error_cleanup "OpenSSL crosscompile failed"
info "winssl: make install_sw"
make install_sw || error_cleanup "OpenSSL install failed"
shared_cross_flag="$shared_cross_flag --with-ssl=$sslsharedinstall"
cd ..
fi
if test -n "$WINEXPAT"; then
info "Cross compile $WINEXPAT"
info "wxp: tar unpack"
(cd ..; bzip2 -cd $WINEXPAT) | tar xf - || error_cleanup "tar unpack of $WINEXPAT failed"
wxpinstall="`pwd`/wxpinstall"
cd expat-* || error_cleanup "no expat-X dir in tarball"
info "wxp: configure"
$configure --prefix="$wxpinstall" --exec-prefix="$wxpinstall" --bindir="$wxpinstall/bin" --includedir="$wxpinstall/include" --mandir="$wxpinstall/man" --libdir="$wxpinstall/lib" || error_cleanup "libexpat configure failed"
info "wxp: make"
make $MINJ || error_cleanup "libexpat crosscompile failed"
info "wxp: make install"
make install || error_cleanup "libexpat install failed"
cross_flag="$cross_flag --with-libexpat=$wxpinstall"
shared_cross_flag="$shared_cross_flag --with-libexpat=$wxpinstall"
cd ..
fi
info "GITREPO is $GITREPO"
info "GITBRANCH is $GITBRANCH"
info "Exporting source from git."
info "git clone --depth=1 --no-tags -b $GITBRANCH $GITREPO unbound"
git clone --depth=1 --no-tags -b $GITBRANCH $GITREPO unbound || error_cleanup "git clone failed"
cd unbound || error_cleanup "Unbound not exported correctly from git"
rm -rf .git .travis.yml .gitattributes .github .gitignore || error_cleanup "Failed to remove .git tracking and ci information"
# on a re-configure the cache may no longer be valid...
if test -f mingw32-config.cache; then rm mingw32-config.cache; fi
else
cross="no" # mingw and msys
cross_flag=""
configure="./configure"
strip="strip"
makensis="c:/Program Files/NSIS/makensis.exe" # http://nsis.sf.net
fi
# version gets compiled into source, edit the configure to set it
version=`./configure --version | head -1 | awk '{ print $3 }'` \
|| error_cleanup "Cannot determine version number."
if [ "$RC" != "no" -o "$SNAPSHOT" != "no" ]; then
if [ "$RC" != "no" ]; then
version2=`echo $version | sed -e 's/rc.*$//' -e 's/_20.*$//'`
version2=`echo $version2 | sed -e 's/rc.*//'`"rc$RC"
fi
if [ "$SNAPSHOT" != "no" ]; then
version2=`echo $version | sed -e 's/rc.*$//' -e 's/_20.*$//'`
version2="${version2}_`date +%Y%m%d`"
fi
replace_version "configure.ac" "$version" "$version2"
version="$version2"
info "Rebuilding configure script (autoconf) snapshot."
autoconf -f || error_cleanup "Autoconf failed."
autoheader -f || error_cleanup "Autoheader failed."
rm -r autom4te* || echo "ignored"
fi
if test "`uname`" = "Linux"; then
(cd ..; cp -r unbound unbound_shared)
fi
# procedure for making unbound installer on mingw.
info "Creating windows dist unbound $version"
info "Calling configure"
if test "$W64" = "no"; then
file_flag="--with-conf-file=C:\Program Files (x86)\Unbound\service.conf"
file2_flag="--with-rootkey-file=C:\Program Files (x86)\Unbound\root.key"
file3_flag="--with-rootcert-file=C:\Program Files (x86)\Unbound\icannbundle.pem"
version="$version"-w32
fi
if test "$W64" = "no"; then
# Disable stack-protector for 32-bit windows builds.
echo "$configure"' --enable-debug --enable-static-exe --disable-flto --disable-gost '"$* $cross_flag" "$file_flag" "$file2_flag" "$file3_flag" CFLAGS='-O2 -g -fno-stack-protector'
$configure --enable-debug --enable-static-exe --disable-flto --disable-gost $* $cross_flag "$file_flag" "$file2_flag" "$file3_flag" CFLAGS='-O2 -g -fno-stack-protector'\
|| error_cleanup "Could not configure"
else
echo "$configure"' --enable-debug --enable-static-exe --disable-flto --disable-gost '"$* $cross_flag"
$configure --enable-debug --enable-static-exe --disable-flto --disable-gost $* $cross_flag \
|| error_cleanup "Could not configure"
fi
info "Calling make"
make $MINJ || error_cleanup "Could not make"
info "Make complete"
if test "`uname`" = "Linux"; then
info "Make DLL"
cd ../unbound_shared
if test "$W64" = "no"; then
# Disable stack-protector for 32-bit windows builds.
echo "$configure"' --enable-debug --disable-flto --disable-gost '"$* $shared_cross_flag" "$file_flag" "$file2_flag" "$file3_flag" CFLAGS='-O2 -g -fno-stack-protector'
$configure --enable-debug --disable-flto --disable-gost $* $shared_cross_flag "$file_flag" "$file2_flag" "$file3_flag" CFLAGS='-O2 -g -fno-stack-protector'\
|| error_cleanup "Could not configure"
else
echo "$configure"' --enable-debug --disable-flto --disable-gost '"$* $shared_cross_flag"
$configure --enable-debug --disable-flto --disable-gost $* $shared_cross_flag \
|| error_cleanup "Could not configure"
fi
info "Calling make for DLL"
make $MINJ || error_cleanup "Could not make DLL"
info "Make DLL complete"
cd ../unbound
fi
info "Unbound version: $version"
file="unbound-$version.zip"
rm -f $file
info "Creating $file"
grep '^". IN DS' smallapp/unbound-anchor.c | sed -e 's/"//' -e 's/\\n.*$//' > root.key
mkdir tmp.$$
# keep debug symbols
#$strip unbound.exe
#$strip anchor-update.exe
#$strip unbound-control.exe
#$strip unbound-host.exe
#$strip unbound-anchor.exe
#$strip unbound-checkconf.exe
#$strip unbound-service-install.exe
#$strip unbound-service-remove.exe
cd tmp.$$
cp ../root.key .
cp ../doc/example.conf ../doc/Changelog .
cp ../unbound.exe ../unbound-anchor.exe ../unbound-host.exe ../unbound-control.exe ../unbound-checkconf.exe ../unbound-service-install.exe ../unbound-service-remove.exe ../LICENSE ../winrc/unbound-control-setup.cmd ../winrc/unbound-website.url ../winrc/service.conf ../winrc/README.txt ../contrib/create_unbound_ad_servers.cmd ../contrib/warmup.cmd ../contrib/unbound_cache.cmd .
mkdir libunbound
# test to see if lib or lib64 (for openssl 3.0.0) needs to be used
if test -f ../../sslsharedinstall/lib/libcrypto.dll.a; then
cp ../../sslsharedinstall/lib/libcrypto.dll.a libunbound/.
else
cp ../../sslsharedinstall/lib64/libcrypto.dll.a libunbound/.
fi
if test -f ../../sslsharedinstall/lib/libssl.dll.a; then
cp ../../sslsharedinstall/lib/libssl.dll.a libunbound/.
else
cp ../../sslsharedinstall/lib64/libssl.dll.a libunbound/.
fi
cp ../../unbound_shared/unbound.h ../../unbound_shared/.libs/libunbound*.dll ../../unbound_shared/.libs/libunbound.dll.a ../../unbound_shared/.libs/libunbound.a ../../unbound_shared/.libs/libunbound*.def ../../sslsharedinstall/bin/libcrypto*.dll ../../sslsharedinstall/bin/libssl*.dll ../../wxpinstall/bin/libexpat*.dll ../../wxpinstall/lib/libexpat.dll.a libunbound/.
if test -f "$sspdll"; then
cp "$sspdll" libunbound/.
fi
# zipfile
zip -r ../$file LICENSE README.txt unbound.exe unbound-anchor.exe unbound-host.exe unbound-control.exe unbound-checkconf.exe unbound-service-install.exe unbound-service-remove.exe unbound-control-setup.cmd example.conf service.conf root.key unbound-website.url create_unbound_ad_servers.cmd warmup.cmd unbound_cache.cmd Changelog libunbound
info "Testing $file"
(cd .. ; zip -T $file )
# installer
info "Creating installer"
quadversion=`cat ../config.h | grep RSRC_PACKAGE_VERSION | sed -e 's/#define RSRC_PACKAGE_VERSION //' -e 's/,/\\./g'`
cat ../winrc/setup.nsi | sed -e 's/define VERSION.*$/define VERSION "'$version'"/' -e 's/define QUADVERSION.*$/define QUADVERSION "'$quadversion'"/' > ../winrc/setup_ed.nsi
if test "$W64" = "no"; then
mv ../winrc/setup_ed.nsi ../winrc/setup_ed_old.nsi
cat ../winrc/setup_ed_old.nsi | sed -e 's/PROGRAMFILES64/PROGRAMFILES/' -e 's/SetRegView 64/SetRegView 32/' > ../winrc/setup_ed.nsi
fi
"$makensis" ../winrc/setup_ed.nsi
info "Created installer"
cd ..
rm -rf tmp.$$
mv winrc/unbound_setup_$version.exe .
if test "$cross" = "yes"; then
mv unbound_setup_$version.exe $cwd/.
mv unbound-$version.zip $cwd/.
cleanup
fi
storehash unbound_setup_$version.exe
storehash unbound-$version.zip
ls -lG unbound_setup_$version.exe
ls -lG unbound-$version.zip
info "Done"
exit 0
fi
check_git_repo
# Start the packaging process.
info "GITREPO is $GITREPO"
info "GITBRANCH is $GITBRANCH"
info "SNAPSHOT is $SNAPSHOT"
#question "Do you wish to continue with these settings?" || error "User abort."
create_temp_dir
info "Exporting source from git."
# --depth=1 and --no-tags reduce the download size.
info "git clone --depth=1 --no-tags -b $GITBRANCH $GITREPO unbound"
git clone --depth=1 --no-tags -b $GITBRANCH $GITREPO unbound || error_cleanup "git clone failed"
cd unbound || error_cleanup "Unbound not exported correctly from git"
rm -rf .git .travis.yml .gitattributes .github .gitignore || error_cleanup "Failed to remove .git tracking and ci information"
info "Adding libtool utils (libtoolize)."
libtoolize -c --install || libtoolize -c || error_cleanup "Libtoolize failed."
# https://www.gnu.org/software/gettext/manual/html_node/config_002eguess.html
info "Updating config.guess and config.sub"
wget -O config.guess 'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD'
wget -O config.sub 'https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD'
chmod a+x config.guess config.sub
# Remove quarantine bit on Apple platforms
if [ `uname -s | grep -i -c darwin` -ne 0 ]; then
if [ -n `command -v xattr` ]; then
xattr -d com.apple.quarantine config.guess
xattr -d com.apple.quarantine config.sub
fi
fi
info "Building configure script (autoreconf)."
autoreconf -f || error_cleanup "Autoconf failed."
rm -r autom4te* || error_cleanup "Failed to remove autoconf cache directory."
info "Building lexer and parser."
echo "#include \"config.h\"" > util/configlexer.c || error_cleanup "Failed to create configlexer"
echo "#include \"util/configyyrename.h\"" >> util/configlexer.c || error_cleanup "Failed to create configlexer"
flex -i -t util/configlexer.lex >> util/configlexer.c || error_cleanup "Failed to create configlexer"
if test -x `which bison` 2>&1; then YACC=bison; else YACC=yacc; fi
$YACC -y -d -o util/configparser.c util/configparser.y || error_cleanup "Failed to create configparser"
find . -name .c-mode-rc.el -exec rm {} \;
find . -name .cvsignore -exec rm {} \;
rm makedist.sh || error_cleanup "Failed to remove makedist.sh."
info "Determining Unbound version."
version=`./configure --version | head -1 | awk '{ print $3 }'` || \
error_cleanup "Cannot determine version number."
info "Unbound version: $version"
RECONFIGURE="no"
if [ "$RC" != "no" ]; then
info "Building Unbound release candidate $RC."
version2="${version}rc$RC"
info "Version number: $version2"
replace_version "configure.ac" "$version" "$version2"
version="$version2"
RECONFIGURE="yes"
fi
if [ "$SNAPSHOT" = "yes" ]; then
info "Building Unbound snapshot."
version2="${version}_`date +%Y%m%d`"
info "Snapshot version number: $version2"
replace_version "configure.ac" "$version" "$version2"
version="$version2"
RECONFIGURE="yes"
fi
if [ "$RECONFIGURE" = "yes" ]; then
info "Rebuilding configure script (autoconf) snapshot."
autoreconf -f || error_cleanup "Autoconf failed."
rm -r autom4te* || error_cleanup "Failed to remove autoconf cache directory."
fi
replace_all doc/README
replace_all doc/unbound.8.in
replace_all doc/unbound.conf.5.in
replace_all doc/unbound-checkconf.8.in
replace_all doc/unbound-control.8.in
replace_all doc/unbound-anchor.8.in
replace_all doc/unbound-host.1.in
replace_all doc/example.conf.in
replace_all doc/libunbound.3.in
info "Renaming Unbound directory to unbound-$version."
cd ..
mv unbound unbound-$version || error_cleanup "Failed to rename unbound directory."
tarfile="../unbound-$version.tar.gz"
if [ -f $tarfile ]; then
(question "The file $tarfile already exists. Overwrite?" \
&& rm -f $tarfile) || error_cleanup "User abort."
fi
info "Creating tar unbound-$version.tar.gz"
tar czf ../unbound-$version.tar.gz unbound-$version || error_cleanup "Failed to create tar file."
cleanup
storehash unbound-$version.tar.gz
echo "create unbound-$version.tar.gz.asc with:"
echo " gpg --armor --detach-sign --digest-algo SHA256 unbound-$version.tar.gz"
echo " gpg --armor --detach-sign --digest-algo SHA256 unbound-$version.zip"
echo " gpg --armor --detach-sign --digest-algo SHA256 unbound_setup_$version.exe"
info "Unbound distribution created successfully."