cvs updates from Wed Dec 15 17:45:22 EST 2010
[tridge/bind9.git] / util / kit.sh
1 #!/bin/sh
2 #
3 # Copyright (C) 2004, 2007-2010  Internet Systems Consortium, Inc. ("ISC")
4 # Copyright (C) 2000-2003  Internet Software Consortium.
5 #
6 # Permission to use, copy, modify, and/or distribute this software for any
7 # purpose with or without fee is hereby granted, provided that the above
8 # copyright notice and this permission notice appear in all copies.
9 #
10 # THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
11 # REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
12 # AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
13 # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
14 # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
15 # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16 # PERFORMANCE OF THIS SOFTWARE.
17
18 # $Id: kit.sh,v 1.44 2010/11/03 01:04:36 marka Exp $
19
20 # Make a release kit
21 #
22 # Usage: sh kit.sh tag tmpdir
23 #
24 #    (e.g., sh kit.sh v9_0_0b5 /tmp/bindkit
25 #
26 # To build a snapshot release, use the pseudo-tag "snapshot".
27 #
28 #   (e.g., sh kit.sh snapshot /tmp/bindkit
29 #
30
31 arg=-r
32 case $# in
33     3)
34         case "$1" in
35         snapshot) ;;
36         *) echo "usage: sh kit.sh [snapshot] cvstag tmpdir" >&2
37            exit 1
38            ;;
39         esac
40         snapshot=true;
41         releasetag=$2
42         tag=$2
43         tmpdir=$3
44         ;;
45     2)
46         tag=$1
47         tmpdir=$2
48         case $tag in
49             snapshot) tag=HEAD; snapshot=true ; releasetag="" ;;
50             *) snapshot=false ;;
51         esac
52         ;;
53     *) echo "usage: sh kit.sh [snapshot] cvstag tmpdir" >&2
54        exit 1
55        ;;
56 esac
57
58
59
60 test -d $tmpdir ||
61 mkdir $tmpdir || {
62     echo "$0: could not create directory $tmpdir" >&2
63     exit 1
64 }
65
66 cd $tmpdir || exit 1
67
68 cvs checkout -p -r $tag bind9/version >version.tmp
69 . ./version.tmp
70
71
72 if $snapshot
73 then
74     set `date -u +'%Y%m%d%H%M%S %Y/%m/%d %H:%M:%S UTC'`
75     dstamp=$1
76     RELEASETYPE=s
77     RELEASEVER=${dstamp}${releasetag}
78     shift
79     case $tag in
80     HEAD)
81         tag="$@"
82         arg=-D
83         ;;
84     *)
85         arg="-r $tag -D"
86         tag="$@"
87         ;;
88     esac
89 fi
90
91 version=${MAJORVER}.${MINORVER}${PATCHVER:+.}${PATCHVER}${RELEASETYPE}${RELEASEVER}
92
93 echo "building release kit for BIND version $version, hold on..."
94
95 topdir=bind-$version
96
97 test ! -d $topdir || {
98     echo "$0: directory `pwd`/$topdir already exists" >&2
99     exit 1
100 }
101
102 cvs -Q export $arg "$tag" -d $topdir bind9
103
104 cd $topdir || exit 1
105
106 if $snapshot
107 then
108     cat <<EOF >version
109 MAJORVER=$MAJORVER
110 MINORVER=$MINORVER
111 PATCHVER=$PATCHVER
112 RELEASETYPE=$RELEASETYPE
113 RELEASEVER=$RELEASEVER
114 EOF
115 fi
116
117 # Omit some files and directories from the kit.
118 #
119 # Some of these directories (doc/html, doc/man...) no longer
120 # contain any files and should therefore be absent in the
121 # checked-out tree, but they did exist at some point and
122 # we still delete them from releases just in case something 
123 # gets accidentally resurrected.
124
125 rm -rf TODO EXCLUDED conftools doc/design doc/dev doc/expired \
126     doc/html doc/todo doc/private bin/lwresd doc/man \
127     lib/lwres/man/resolver.5 \
128     bin/tests/system/relay lib/cfg
129
130 # Remove everything but mksymtbl.pl from util
131 find util -name mksymtbl.pl -prune -o -type f -print | xargs rm -f
132 find util -depth -type d -print | xargs rmdir 2>/dev/null
133
134 # Remove all .cvsignore files
135 find . -name .cvsignore -print | xargs rm
136
137 # The following files should be executable.
138 chmod +x configure install-sh mkinstalldirs bin/tests/system/ifconfig.sh
139 # Fix up releases with libbind.
140 if test -f lib/bind/configure
141 then
142          chmod +x lib/bind/configure lib/bind/mkinstalldirs
143 fi
144
145 # Fix files which should be using DOS style newlines
146 windirs=`find lib bin -type d -name win32`
147 windirs="$windirs win32utils"
148 winnames="-name *.mak -or -name *.dsp -or -name *.dsw -or -name *.txt -or -name *.bat"
149 for f in `find $windirs -type f \( $winnames \) -print`
150 do
151         awk '{sub("\r$", "", $0); printf("%s\r\n", $0);}' < $f > tmp
152         touch -r $f tmp
153         mv tmp $f
154 done
155
156 # check that documentation has been updated properly; issue a warning
157 # if it hasn't
158 ok=
159 for f in doc/arm/*.html
160 do
161         if test "$f" -nt doc/arm/Bv9ARM-book.xml
162         then
163                 ok=ok
164         fi
165 done
166
167 if test "$ok" != ok
168 then
169         echo "WARNING: ARM source is newer than the html version."
170 fi
171
172 if test doc/arm/Bv9ARM-book.xml -nt doc/arm/Bv9ARM.pdf
173 then
174         echo "WARNING: ARM source is newer than the PDF version."
175 fi
176
177 for f in `find . -name "*.docbook" -print`
178 do
179         docbookfile=$f
180         htmlfile=${f%.docbook}.html
181         if test $docbookfile -nt $htmlfile
182         then
183                 echo "WARNING: $docbookfile is newer than the html version."
184         fi
185 done
186
187 # build the tarball
188 cd .. || exit 1
189
190 kit=$topdir.tar.gz
191
192 tar -c -f - $topdir | gzip > $kit
193
194 echo "done, kit is in `pwd`/$kit"