xref: /freebsd/crypto/krb5/src/util/mkrel (revision 7f2fe78b9dd5f51c821d771b63d2e096f6fd49e9)
1*7f2fe78bSCy Schubert#!/bin/sh
2*7f2fe78bSCy Schubertset -e
3*7f2fe78bSCy Schubertrepository=git.mit.edu:/git/krb5.git
4*7f2fe78bSCy Schubertdodoc=t
5*7f2fe78bSCy Schubertdosrc=t
6*7f2fe78bSCy Schubertcheckout=t
7*7f2fe78bSCy Schubertmultitar=nil
8*7f2fe78bSCy Schubert: ${TAR=tar}
9*7f2fe78bSCy Schubertwhile test $# -gt 2; do
10*7f2fe78bSCy Schubert	case $1 in
11*7f2fe78bSCy Schubert	--srconly)
12*7f2fe78bSCy Schubert		dodoc=nil;;
13*7f2fe78bSCy Schubert	--doconly)
14*7f2fe78bSCy Schubert		dosrc=nil;;
15*7f2fe78bSCy Schubert	--multi*)
16*7f2fe78bSCy Schubert		multitar=t;;
17*7f2fe78bSCy Schubert	--repository)
18*7f2fe78bSCy Schubert		shift; repository=$1;;
19*7f2fe78bSCy Schubert	--nocheckout)
20*7f2fe78bSCy Schubert		checkout=nil;;
21*7f2fe78bSCy Schubert	esac
22*7f2fe78bSCy Schubert	shift
23*7f2fe78bSCy Schubertdone
24*7f2fe78bSCy Schubertif test $# -lt 2; then
25*7f2fe78bSCy Schubert	echo "usage: $0 [opts] release-tag release-dir"
26*7f2fe78bSCy Schubert	echo "	release-tag is relative to $repository/"
27*7f2fe78bSCy Schubert	exit 1
28*7f2fe78bSCy Schubertfi
29*7f2fe78bSCy Schubert
30*7f2fe78bSCy Schubertreltag=$1
31*7f2fe78bSCy Schubertreldir=$2
32*7f2fe78bSCy Schubert
33*7f2fe78bSCy Schubertrelmajor=0
34*7f2fe78bSCy Schubertrelminor=0
35*7f2fe78bSCy Schubertrelpatch=0
36*7f2fe78bSCy Schubertrelhead=
37*7f2fe78bSCy Schubert# reltail=
38*7f2fe78bSCy Schubertreldate=`date +%Y%m%d`
39*7f2fe78bSCy Schubert
40*7f2fe78bSCy Schubertcase "$reldir" in
41*7f2fe78bSCy Schubert*/*)
42*7f2fe78bSCy Schubert	echo "release-dir may not contain slashes."
43*7f2fe78bSCy Schubert	exit 1
44*7f2fe78bSCy Schubert	;;
45*7f2fe78bSCy Schubert*" "*|*"	"*)
46*7f2fe78bSCy Schubert	echo "release-dir may  not contain whitespace."
47*7f2fe78bSCy Schubert	exit 1
48*7f2fe78bSCy Schubert	;;
49*7f2fe78bSCy Schubertkrb5-*.*.*-*)
50*7f2fe78bSCy Schubert	release=`echo $reldir|sed -e 's/krb5-//'`
51*7f2fe78bSCy Schubert	relhead=`echo $release|sed -e 's/-.*//'`
52*7f2fe78bSCy Schubert	reltail=`echo $release|sed -e 's/.*-//'`
53*7f2fe78bSCy Schubert	relmajor=`echo $relhead|awk -F. '{print $1}'`
54*7f2fe78bSCy Schubert	relminor=`echo $relhead|awk -F. '{print $2}'`
55*7f2fe78bSCy Schubert	relpatch=`echo $relhead|awk -F. '{print $3}'`
56*7f2fe78bSCy Schubert	;;
57*7f2fe78bSCy Schubertkrb5-*.*.*)
58*7f2fe78bSCy Schubert	release=`echo $reldir|sed -e 's/krb5-//'`
59*7f2fe78bSCy Schubert	relmajor=`echo $release|awk -F. '{print $1}'`
60*7f2fe78bSCy Schubert	relminor=`echo $release|awk -F. '{print $2}'`
61*7f2fe78bSCy Schubert	relpatch=`echo $release|awk -F. '{print $3}'`
62*7f2fe78bSCy Schubert	;;
63*7f2fe78bSCy Schubertkrb5-*.*-current)
64*7f2fe78bSCy Schubert	release=`echo $reldir|sed -e 's/krb5-//'`
65*7f2fe78bSCy Schubert	relhead=`echo $release|sed -e 's/-.*//'`
66*7f2fe78bSCy Schubert	relmajor=`echo $relhead|awk -F. '{print $1}'`
67*7f2fe78bSCy Schubert	relminor=`echo $relhead|awk -F. '{print $2}'`
68*7f2fe78bSCy Schubert	release=${relhead}-$reldate
69*7f2fe78bSCy Schubert	;;
70*7f2fe78bSCy Schubertkrb5-*.*-*)
71*7f2fe78bSCy Schubert	release=`echo $reldir|sed -e 's/krb5-//'`
72*7f2fe78bSCy Schubert	relhead=`echo $release|sed -e 's/-.*//'`
73*7f2fe78bSCy Schubert	reltail=`echo $release|sed -e 's/.*-//'`
74*7f2fe78bSCy Schubert	relmajor=`echo $relhead|awk -F. '{print $1}'`
75*7f2fe78bSCy Schubert	relminor=`echo $relhead|awk -F. '{print $2}'`
76*7f2fe78bSCy Schubert	;;
77*7f2fe78bSCy Schubertkrb5-*.*)
78*7f2fe78bSCy Schubert	release=`echo $reldir|sed -e 's/krb5-//'`
79*7f2fe78bSCy Schubert	relmajor=`echo $release|awk -F. '{print $1}'`
80*7f2fe78bSCy Schubert	relminor=`echo $release|awk -F. '{print $2}'`
81*7f2fe78bSCy Schubert	;;
82*7f2fe78bSCy Schubertkrb5-current)
83*7f2fe78bSCy Schubert	release=current-$reldate
84*7f2fe78bSCy Schubert	;;
85*7f2fe78bSCy Schubert*)
86*7f2fe78bSCy Schubert	release="$reldir"
87*7f2fe78bSCy Schubert	;;
88*7f2fe78bSCy Schubertesac
89*7f2fe78bSCy Schubert
90*7f2fe78bSCy Schubertecho "release=$release"
91*7f2fe78bSCy Schubertecho "major=$relmajor minor=$relminor patch=$relpatch"
92*7f2fe78bSCy Schubert
93*7f2fe78bSCy Schubert# $release is used for send-pr
94*7f2fe78bSCy Schubert# $reltag, $release, $reldate are used for brand.c currently
95*7f2fe78bSCy Schubert# $relmajor, $relminor, $relpatch are used for patchlevel.h currently
96*7f2fe78bSCy Schubert
97*7f2fe78bSCy Schubertif test $checkout = t; then
98*7f2fe78bSCy Schubert	echo "Checking out krb5 with tag $reltag into directory $reldir..."
99*7f2fe78bSCy Schubert	git clone -q -n $repository $reldir
100*7f2fe78bSCy Schubert	(cd $reldir && git checkout -q $reltag)
101*7f2fe78bSCy Schubertfi
102*7f2fe78bSCy Schubert
103*7f2fe78bSCy Schubert#
104*7f2fe78bSCy Schubert# $newstyle = t if patchlevel.h is the master version stamp file.  If
105*7f2fe78bSCy Schubert# so, we don't edit it here.
106*7f2fe78bSCy Schubert#
107*7f2fe78bSCy Schubertif grep KRB5_RELDATE $reldir/src/patchlevel.h > /dev/null 2>&1; then
108*7f2fe78bSCy Schubert	newstyle=t;
109*7f2fe78bSCy Schubertelse
110*7f2fe78bSCy Schubert	newstyle=nil;
111*7f2fe78bSCy Schubertfi
112*7f2fe78bSCy Schubert
113*7f2fe78bSCy Schubertif test $newstyle = t; then
114*7f2fe78bSCy Schubert	echo "parsing new style patchlevel.h..."
115*7f2fe78bSCy Schubert	eval `sed -n 's/#define \([A-Z0-9_]*\)[ \t]*\(.*\)/\1=\2/p' < $reldir/src/patchlevel.h`
116*7f2fe78bSCy Schubert	if test "$KRB5_RELTAG" != $reltag && \
117*7f2fe78bSCy Schubert		test "$KRB5_RELTAG" != `echo $reltag|sed 's%[^/]*/%%'` ; then
118*7f2fe78bSCy Schubert		echo "WARNING: patchlevel.h '$KRB5_RELTAG' != $reltag"
119*7f2fe78bSCy Schubert	fi
120*7f2fe78bSCy Schubert	if test "$KRB5_MAJOR_RELEASE" != "$relmajor" || \
121*7f2fe78bSCy Schubert		test "$KRB5_MINOR_RELEASE" != "$relminor" || \
122*7f2fe78bSCy Schubert		test "$KRB5_PATCHLEVEL" != "$relpatch" || \
123*7f2fe78bSCy Schubert		( test -n "$reltail" && \
124*7f2fe78bSCy Schubert			test "$KRB5_RELTAIL" != "$reltail" ); then
125*7f2fe78bSCy Schubert
126*7f2fe78bSCy Schubert		echo "WARNING: patchlevel.h $KRB5_MAJOR_RELEASE.$KRB5_MINOR_RELEASE.$KRB5_PATCHLEVEL${KRB5_RELTAIL+-$KRB5_RELTAIL} != $relmajor.$relminor.$relpatch${reltail+-$reltail}"
127*7f2fe78bSCy Schubert	fi
128*7f2fe78bSCy Schubertelse
129*7f2fe78bSCy Schubert	echo "old style patchlevel.h"
130*7f2fe78bSCy Schubertfi
131*7f2fe78bSCy Schubert
132*7f2fe78bSCy Schubertecho "Editing release-specific files..."
133*7f2fe78bSCy Schubert
134*7f2fe78bSCy Schubertif test $newstyle = t; then
135*7f2fe78bSCy Schubert	(cd $reldir/src && \
136*7f2fe78bSCy Schubert		sed -e '/#[a-z 	]*KRB5_RELDATE/c\
137*7f2fe78bSCy Schubert#define KRB5_RELDATE "'"$reldate"'"' patchlevel.h > patchlevel.h.new && \
138*7f2fe78bSCy Schubert		mv patchlevel.h.new patchlevel.h)
139*7f2fe78bSCy Schubertelse
140*7f2fe78bSCy Schubert
141*7f2fe78bSCy Schubert	(cd $reldir/src/lib/krb5/krb && \
142*7f2fe78bSCy Schubert		sed -e '/static/s%KRB5_BRAND:[^"]*"%'"KRB5_BRAND: $reltag $release $reldate"'"%' \
143*7f2fe78bSCy Schubert			brand.c > brand.c.new && mv brand.c.new brand.c; \
144*7f2fe78bSCy Schubert		rm -f brand.c.new)
145*7f2fe78bSCy Schubert
146*7f2fe78bSCy Schubert	(cd $reldir/src/util/send-pr && \
147*7f2fe78bSCy Schubert		sed -e 's%RELEASE=.*%RELEASE='"krb5-$release"'%' Makefile.in \
148*7f2fe78bSCy Schubert			> Makefile.in.new && mv Makefile.in.new Makefile.in)
149*7f2fe78bSCy Schubert
150*7f2fe78bSCy Schubert	(cd $reldir/src && \
151*7f2fe78bSCy Schubert		cat > patchlevel.h <<EOF
152*7f2fe78bSCy Schubert#define KRB5_MAJOR_RELEASE $relmajor
153*7f2fe78bSCy Schubert#define KRB5_MINOR_RELEASE $relminor
154*7f2fe78bSCy Schubert#define KRB5_PATCHLEVEL    $relpatch
155*7f2fe78bSCy SchubertEOF
156*7f2fe78bSCy Schubert	)
157*7f2fe78bSCy Schubertfi
158*7f2fe78bSCy Schubert
159*7f2fe78bSCy Schubertif test $dosrc = t; then
160*7f2fe78bSCy Schubert	if test -d $reldir/src/util/autoconf; then
161*7f2fe78bSCy Schubert		echo "Building autoconf..."
162*7f2fe78bSCy Schubert		(cd $reldir/src/util/autoconf
163*7f2fe78bSCy Schubert			M4=gm4 ./configure
164*7f2fe78bSCy Schubert			make)
165*7f2fe78bSCy Schubert	fi
166*7f2fe78bSCy Schubert	echo "Creating configure scripts..."
167*7f2fe78bSCy Schubert	(cd $reldir/src; autoreconf -v)
168*7f2fe78bSCy Schubert
169*7f2fe78bSCy Schubert	if test -d $reldir/src/util/autoconf; then
170*7f2fe78bSCy Schubert		echo "Cleaning src/util/autoconf..."
171*7f2fe78bSCy Schubert		(cd $reldir/src/util/autoconf; make distclean)
172*7f2fe78bSCy Schubert	fi
173*7f2fe78bSCy Schubertfi
174*7f2fe78bSCy Schubert
175*7f2fe78bSCy Schubertecho "Nuking unneeded files..."
176*7f2fe78bSCy Schubertfind $reldir \( -name TODO -o -name todo -o -name .cvsignore \
177*7f2fe78bSCy Schubert	-o -name .gitignore -o -name BADSYMS -o -name .Sanitize \
178*7f2fe78bSCy Schubert	-o -name .rconf \) -print | xargs rm -f || true
179*7f2fe78bSCy Schubertfind $reldir -depth -type d \( -name autom4te.cache \
180*7f2fe78bSCy Schubert	-o -name \$ac_config_fragdir \) -exec rm -rf {} \; || true
181*7f2fe78bSCy Schubertrm -rf $reldir/.git || true
182*7f2fe78bSCy Schubert
183*7f2fe78bSCy Schubertif test $dodoc = t; then
184*7f2fe78bSCy Schubert	echo "Building doc..."
185*7f2fe78bSCy Schubert	(cd $reldir/src/doc && make -f Makefile.in \
186*7f2fe78bSCy Schubert	    top_srcdir=.. srcdir=. SPHINX_ARGS=-W PYTHON=python3 html pdf)
187*7f2fe78bSCy Schubert	(cd $reldir/src/doc && make -f Makefile.in \
188*7f2fe78bSCy Schubert	    top_srcdir=.. srcdir=. SPHINX_ARGS=-W PYTHON=python3 clean)
189*7f2fe78bSCy Schubertfi
190*7f2fe78bSCy Schubert
191*7f2fe78bSCy Schubertecho "Generating tarfiles..."
192*7f2fe78bSCy SchubertGZIP=-9; export GZIP
193*7f2fe78bSCy Schubertif test $multitar = t; then
194*7f2fe78bSCy Schubert	if test -d $reldir/src/lib/des425; then
195*7f2fe78bSCy Schubert		des425=$reldir/src/lib/des425
196*7f2fe78bSCy Schubert	fi
197*7f2fe78bSCy Schubert	if test -f $reldir/NOTICE;
198*7f2fe78bSCy Schubert		then notice=$reldir/NOTICE
199*7f2fe78bSCy Schubert	fi
200*7f2fe78bSCy Schubert	if test $dosrc = t; then
201*7f2fe78bSCy Schubert		$TAR --exclude $reldir/src/lib/crypto \
202*7f2fe78bSCy Schubert			--exclude $reldir/src/lib/des425 \
203*7f2fe78bSCy Schubert			--exclude $reldir/doc \
204*7f2fe78bSCy Schubert			-zcf ${reldir}.src.tar.gz $reldir
205*7f2fe78bSCy Schubert
206*7f2fe78bSCy Schubert		$TAR zcf ${reldir}.crypto.tar.gz \
207*7f2fe78bSCy Schubert			$reldir/src/lib/crypto \
208*7f2fe78bSCy Schubert			$des425
209*7f2fe78bSCy Schubert	fi
210*7f2fe78bSCy Schubert	if test $dodoc = t; then
211*7f2fe78bSCy Schubert		$TAR zcf ${reldir}.doc.tar.gz $reldir/doc $reldir/README $notice
212*7f2fe78bSCy Schubert	fi
213*7f2fe78bSCy Schubert	ls -l ${reldir}.*.tar.gz
214*7f2fe78bSCy Schubertfi
215*7f2fe78bSCy Schubert
216*7f2fe78bSCy Schubert$TAR zcf ${reldir}.tar.gz $reldir
217*7f2fe78bSCy Schubertls -l ${reldir}.tar.gz
218*7f2fe78bSCy Schubert
219*7f2fe78bSCy Schubertecho "Done."
220*7f2fe78bSCy Schubert
221*7f2fe78bSCy Schubertexit 0
222