|
| 1 | +#!/bin/sh |
| 2 | +# |
| 3 | +# Copyright (C) Internet Systems Consortium, Inc. ("ISC") |
| 4 | +# |
| 5 | +# This Source Code Form is subject to the terms of the Mozilla Public |
| 6 | +# License, v. 2.0. If a copy of the MPL was not distributed with this |
| 7 | +# file, you can obtain one at https://mozilla.org/MPL/2.0/. |
| 8 | +# |
| 9 | +# See the COPYRIGHT file distributed with this work for additional |
| 10 | +# information regarding copyright ownership. |
| 11 | + |
| 12 | +# Make a release kit |
| 13 | +# |
| 14 | +# Usage: sh kit.sh tag tmpdir |
| 15 | +# |
| 16 | +# (e.g., sh kit.sh v9_0_0b5 /tmp/bindkit |
| 17 | +# |
| 18 | +# To build a snapshot release, use the pseudo-tag "snapshot". |
| 19 | +# |
| 20 | +# (e.g., sh kit.sh snapshot /tmp/bindkit |
| 21 | +# |
| 22 | + |
| 23 | +[email protected]:isc-projects/bind9.git |
| 24 | + |
| 25 | +case "${1:-}" in |
| 26 | +--remote=*) |
| 27 | + remote="${1}" |
| 28 | + shift |
| 29 | + ;; |
| 30 | +esac |
| 31 | + |
| 32 | +repo=`expr "X${remote}X" : '^X--remote=\(.*\)X$'` |
| 33 | + |
| 34 | +case $# in |
| 35 | + 3) |
| 36 | + case "$1" in |
| 37 | + snapshot) ;; |
| 38 | + *) echo "usage: sh kit.sh [snapshot] gittag tmpdir" >&2 |
| 39 | + exit 1 |
| 40 | + ;; |
| 41 | + esac |
| 42 | + snapshot=true; |
| 43 | + releasetag=$2 |
| 44 | + tag=$2 |
| 45 | + tmpdir=$3 |
| 46 | + ;; |
| 47 | + 2) |
| 48 | + tag=$1 |
| 49 | + tmpdir=$2 |
| 50 | + case $tag in |
| 51 | + snapshot) tag=master; snapshot=true ; releasetag="" ;; |
| 52 | + *) snapshot=false ;; |
| 53 | + esac |
| 54 | + ;; |
| 55 | + *) echo "usage: sh kit.sh [snapshot] gittag tmpdir" >&2 |
| 56 | + exit 1 |
| 57 | + ;; |
| 58 | +esac |
| 59 | + |
| 60 | +# create tmpdir |
| 61 | +test -d $tmpdir || |
| 62 | +mkdir $tmpdir || { |
| 63 | + echo "$0: could not create directory $tmpdir" >&2 |
| 64 | + exit 1 |
| 65 | +} |
| 66 | + |
| 67 | +cd $tmpdir || { |
| 68 | + echo "$0: cd $tmpdir failed" |
| 69 | + exit 1 |
| 70 | +} |
| 71 | + |
| 72 | +hash=`git ls-remote $repo refs/heads/$tag | awk '{print $1}'` |
| 73 | +if [ -z "$hash" ]; then |
| 74 | + hash=`git ls-remote $repo refs/tags/$tag | awk '{print $1}'` |
| 75 | +fi |
| 76 | +if [ -z "$hash" ]; then |
| 77 | + echo "Unable to determine hash for $tag, aborting." |
| 78 | + exit 1 |
| 79 | +fi |
| 80 | +shorthash=`echo $hash | cut -c1-7` |
| 81 | + |
| 82 | +verdir=bind9-kit.$$ |
| 83 | +mkdir $verdir || { |
| 84 | + echo "$0: could not create directory $tmpdir/$verdir" >&2 |
| 85 | + exit 1 |
| 86 | +} |
| 87 | +git archive --format=tar $remote $tag version | ( cd $verdir ;tar xf - ) |
| 88 | +test -f $verdir/version || { |
| 89 | + echo "$0: could not get 'version' file" >&2 |
| 90 | + exit 1 |
| 91 | +} |
| 92 | +. $verdir/version |
| 93 | + |
| 94 | +rm $verdir/version |
| 95 | +rmdir $verdir |
| 96 | + |
| 97 | +if $snapshot |
| 98 | +then |
| 99 | + RELEASETYPE=s |
| 100 | + RELEASEVER=${shorthash} |
| 101 | +fi |
| 102 | + |
| 103 | +version=${MAJORVER}.${MINORVER}${PATCHVER:+.}${PATCHVER}${RELEASETYPE}${RELEASEVER}${EXTENSIONS} |
| 104 | + |
| 105 | +echo "building release kit for BIND version $version, hold on..." |
| 106 | + |
| 107 | +topdir=bind-$version |
| 108 | + |
| 109 | +test ! -d $topdir || { |
| 110 | + echo "$0: directory $tmpdir/$topdir already exists" >&2 |
| 111 | + exit 1 |
| 112 | +} |
| 113 | + |
| 114 | +mkdir $topdir || exit 1 |
| 115 | + |
| 116 | +git archive --format=tar $remote $tag | ( cd $topdir; tar xf -) |
| 117 | + |
| 118 | +cd $topdir || exit 1 |
| 119 | + |
| 120 | +if $snapshot |
| 121 | +then |
| 122 | + cat <<EOF >version |
| 123 | +MAJORVER=$MAJORVER |
| 124 | +MINORVER=$MINORVER |
| 125 | +PATCHVER=$PATCHVER |
| 126 | +RELEASETYPE=$RELEASETYPE |
| 127 | +RELEASEVER=$RELEASEVER |
| 128 | +EXTENSIONS=$EXTENSIONS |
| 129 | +EOF |
| 130 | +fi |
| 131 | + |
| 132 | +# Omit some files and directories from the kit. |
| 133 | +# |
| 134 | +# Some of these directories (doc/html, doc/man...) no longer |
| 135 | +# contain any files and should therefore be absent in the |
| 136 | +# checked-out tree, but they did exist at some point and |
| 137 | +# we still delete them from releases just in case something |
| 138 | +# gets accidentally resurrected. |
| 139 | + |
| 140 | +rm -rf TODO EXCLUDED conftools doc/design doc/dev doc/draft doc/expired \ |
| 141 | + doc/html doc/rfc doc/todo doc/private bin/lwresd doc/man doc/markdown \ |
| 142 | + lib/lwres/man/resolver.5 contrib/zkt/doc/rfc5011.txt \ |
| 143 | + bin/tests/system/relay lib/cfg |
| 144 | + |
| 145 | +# Remove everything but mksymtbl.pl, bindkeys.pl and check-make-install.in |
| 146 | +# from util |
| 147 | +find util -name bindkeys.pl -o -name mksymtbl.pl -o -name check-make-install.in -prune -o -type f -print | xargs rm -f |
| 148 | +find util -depth -type d -print | xargs rmdir 2>/dev/null |
| 149 | + |
| 150 | +# Remove all .gitignore files |
| 151 | +find . -name .gitignore -print | xargs rm |
| 152 | + |
| 153 | +# Remove branchsync.dat, if present |
| 154 | +rm -f branchsync.dat |
| 155 | + |
| 156 | +# populate srcid file |
| 157 | +echo "SRCID=$shorthash" > srcid |
| 158 | + |
| 159 | +# The following files should be executable. |
| 160 | +chmod +x configure install-sh mkinstalldirs bin/tests/system/ifconfig.sh |
| 161 | +# Fix up releases with libbind. |
| 162 | +if test -f lib/bind/configure |
| 163 | +then |
| 164 | + chmod +x lib/bind/configure lib/bind/mkinstalldirs |
| 165 | +fi |
| 166 | + |
| 167 | +# Fix files which should be using DOS style newlines |
| 168 | +windirs=`find lib bin -type d -name win32` |
| 169 | +windirs="$windirs win32utils" |
| 170 | +winnames="-name *.mak -or -name *.dsp -or -name *.dsw -or -name *.txt -or -name *.bat" |
| 171 | +for f in `find $windirs -type f \( $winnames \) -print` |
| 172 | +do |
| 173 | + awk '{sub("\r$", "", $0); printf("%s\r\n", $0);}' < $f > tmp |
| 174 | + touch -r $f tmp |
| 175 | + mv tmp $f |
| 176 | +done |
| 177 | + |
| 178 | +# check that documentation has been updated properly; issue a warning |
| 179 | +# if it hasn't |
| 180 | +ok= |
| 181 | +for f in doc/arm/*.html |
| 182 | +do |
| 183 | + if test "$f" -nt doc/arm/Bv9ARM-book.xml |
| 184 | + then |
| 185 | + ok=ok |
| 186 | + fi |
| 187 | +done |
| 188 | + |
| 189 | +if test "$ok" != ok |
| 190 | +then |
| 191 | + echo "WARNING: ARM source is newer than the html version." |
| 192 | +fi |
| 193 | + |
| 194 | +if test doc/arm/Bv9ARM-book.xml -nt doc/arm/Bv9ARM.pdf |
| 195 | +then |
| 196 | + echo "WARNING: ARM source is newer than the PDF version." |
| 197 | +fi |
| 198 | + |
| 199 | +for f in `find . -name "*.docbook" -print` |
| 200 | +do |
| 201 | + docbookfile=$f |
| 202 | + htmlfile=${f%.docbook}.html |
| 203 | + if test $docbookfile -nt $htmlfile |
| 204 | + then |
| 205 | + echo "WARNING: $docbookfile is newer than the html version." |
| 206 | + fi |
| 207 | +done |
| 208 | + |
| 209 | +# build the tarball |
| 210 | +cd .. || exit 1 |
| 211 | + |
| 212 | +kit=$topdir.tar.gz |
| 213 | +tar -c -f - $topdir | gzip > $kit |
| 214 | +echo "done, kit is in `pwd`/$kit" |
0 commit comments