summaryrefslogtreecommitdiffstats
path: root/src/util/mkrel
blob: 97a08d1260fb9f8fa2ba7c472a48ae07a7f57c8c (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
#!/bin/sh
set -e
repository=:gserver:cvs.mit.edu:/cvs/krbdev
dodoc=t
dosrc=t
checkout=t
multitar=nil
while test $# -gt 2; do
	case $1 in
	--srconly)
		dodoc=nil;;
	--doconly)
		dosrc=nil;;
	--multi*)
		multitar=t;;
	--repository)
		shift; repository=$1;;
	--nocheckout)
		checkout=nil;;
	esac
	shift
done
if test $# -lt 2; then
	echo "usage: $0 [opts] release-tag release-dir"
	exit 1
fi

reltag=$1
reldir=$2

relmajor=0
relminor=0
relpatch=0
relhead=
# reltail=
reldate=`date +%Y%m%d`

case "$reldir" in
*/*)
	echo "release-dir may not contain slashes."
	exit 1
	;;
*" "*|*"	"*)
	echo "release-dir may  not contain whitespace."
	exit 1
	;;
krb5-*.*.*-*)
	release=`echo $reldir|sed -e 's/krb5-//'`
	relhead=`echo $release|sed -e 's/-.*//'`
	reltail=`echo $release|sed -e 's/.*-//'`
	relmajor=`echo $relhead|awk -F. '{print $1}'`
	relminor=`echo $relhead|awk -F. '{print $2}'`
	relpatch=`echo $relhead|awk -F. '{print $3}'`
	;;
krb5-*.*.*)
	release=`echo $reldir|sed -e 's/krb5-//'`
	relmajor=`echo $release|awk -F. '{print $1}'`
	relminor=`echo $release|awk -F. '{print $2}'`
	relpatch=`echo $release|awk -F. '{print $3}'`
	;;
krb5-*.*-current)
	release=`echo $reldir|sed -e 's/krb5-//'`
	relhead=`echo $release|sed -e 's/-.*//'`
	relmajor=`echo $relhead|awk -F. '{print $1}'`
	relminor=`echo $relhead|awk -F. '{print $2}'`
	release=${relhead}-$reldate
	;;
krb5-*.*-*)
	release=`echo $reldir|sed -e 's/krb5-//'`
	relhead=`echo $release|sed -e 's/-.*//'`
	reltail=`echo $release|sed -e 's/.*-//'`
	relmajor=`echo $relhead|awk -F. '{print $1}'`
	relminor=`echo $relhead|awk -F. '{print $2}'`
	;;
krb5-*.*)
	release=`echo $reldir|sed -e 's/krb5-//'`
	relmajor=`echo $release|awk -F. '{print $1}'`
	relminor=`echo $release|awk -F. '{print $2}'`
	;;
krb5-current)
	release=current-$reldate
	;;
*)
	release="$reldir"
	;;
esac

echo "release=$release"
echo "major=$relmajor minor=$relminor patch=$relpatch"

# $release is used for send-pr
# $reltag, $release, $reldate are used for brand.c currently
# $relmajor, $relminor, $relpatch are used for patchlevel.h currently

#
# $newstyle = t if patchlevel.h is the master version stamp file.  If
# so, we don't edit it here.
#
if test $checkout = t; then
	if cvs -q -d $repository checkout -p -r$reltag krb5/src/patchlevel.h | grep KRB5_RELDATE > /dev/null 2>&1; then
		newstyle=t
	else
		newstyle=nil;
	fi
else
	if grep KRB5_RELDATE $reldir/src/patchlevel.h > /dev/null 2>&1; then
		newstyle=t;
	else
		newstyle=nil;
	fi
fi

if test $newstyle = t; then
	echo "parsing new style patchlevel.h..."
	if test $checkout = t; then
		eval `cvs -q -d $repository checkout -p -r$reltag krb5/src/patchlevel.h | sed -n 's/#define \([A-Z0-9_]*\)[ \t]*\(.*\)/\1=\2/p'`
	else
		eval `sed -n 's/#define \([A-Z0-9_]*\)[ \t]*\(.*\)/\1=\2/p' < $reldir/src/patchlevel.h`
	fi
	if test "$KRB5_RELTAG" != $reltag; then
		echo "WARNING: patchlevel.h '$KRB5_RELTAG' != $reltag"
	fi
	if test "$KRB5_MAJOR_RELEASE" != $relmajor || \
		test "$KRB5_MINOR_RELEASE" != $relminor || \
		test "$KRB5_PATCHLEVEL" != $relpatch || \
		test "$KRB5_RELTAIL" != $reltail; then

		echo "WARNING: patchlevel.h $KRB5_MAJOR_RELEASE.$KRB5_MINOR_RELEASE.$KRB5_PATCHLEVEL${KRB5_RELTAIL+-$KRB5_RELTAIL} != $relmajor.$relminor.$relpatch${reltail+-$reltail}"
	fi
else
	echo "old style patchlevel.h"
fi

if test $checkout = t; then
	echo "Checking out krb5 with tag $reltag into directory $reldir..."
	cvs -q -d $repository export -r$reltag -d $reldir krb5
fi

if test $dosrc = t; then
	if test -d $reldir/src/util/autoconf; then
		echo "Building autoconf..."
		(cd $reldir/src/util/autoconf
			M4=gm4 ./configure
			make)
	fi
	echo "Creating configure scripts..."
	(cd $reldir/src; util/reconf)

	if test -d $reldir/src/util/autoconf; then
		echo "Cleaning src/util/autoconf..."
		(cd $reldir/src/util/autoconf; make distclean)
	fi
fi

echo "Editing release-specific files..."

if test $newstyle = t; then 
	(cd $reldir/src && \
		sed -e '/RELDATE/c\
#define KRB5_RELDATE "'"$reldate"'"' patchlevel.h > patchlevel.h.new && \
		mv patchlevel.h.new patchlevel.h)
else

	(cd $reldir/src/lib/krb5/krb && \
		sed -e '/static/s%KRB5_BRAND:[^"]*"%'"KRB5_BRAND: $reltag $release $reldate"'"%' \
			brand.c > brand.c.new && mv brand.c.new brand.c; \
		rm -f brand.c.new)

	(cd $reldir/src/util/send-pr && \
		sed -e 's%RELEASE=.*%RELEASE='"krb5-$release"'%' Makefile.in \
			> Makefile.in.new && mv Makefile.in.new Makefile.in)

	(cd $reldir/src && \
		cat > patchlevel.h <<EOF
#define KRB5_MAJOR_RELEASE $relmajor
#define KRB5_MINOR_RELEASE $relminor
#define KRB5_PATCHLEVEL    $relpatch
EOF
	)
fi

echo "Nuking unneeded files..."
find $reldir \( -name TODO -o -name todo -o -name .cvsignore \
	-o -name BADSYMS -o -name .Sanitize -o -name .rconf \) -print \
	| xargs rm -f || true
find $reldir -type d -name autom4te.cache -exec rm -rf {} \; || true

if test $dodoc = t; then
	echo "Building doc..."
	(cd $reldir/doc; make)
fi

echo "Generating tarfiles..."
GZIP=-9; export GZIP
if test $multitar = t; then
	if test $dosrc = t; then
		gtar --exclude $reldir/src/lib/crypto \
			--exclude $reldir/src/lib/des425 \
			--exclude $reldir/doc \
			-zcf ${reldir}.src.tar.gz $reldir

		gtar zcf ${reldir}.crypto.tar.gz \
			$reldir/src/lib/crypto \
			$reldir/src/lib/des425
	fi
	if test $dodoc = t; then
		gtar zcf ${reldir}.doc.tar.gz $reldir/doc $reldir/README
	fi
	ls -l ${reldir}.*.tar.gz
fi

gtar zcf ${reldir}.tar.gz $reldir
ls -l ${reldir}.tar.gz

echo "Done."

exit 0