27644
|
1 |
#!/usr/bin/env bash
|
|
2 |
#
|
|
3 |
# $Id$
|
|
4 |
#
|
|
5 |
# makedist_mercurial -- make Isabelle source distribution (via Mercurial)
|
|
6 |
|
|
7 |
## global settings
|
|
8 |
|
|
9 |
REPOS="http://isabelle.in.tum.de/isabelle-bin/mercurial.cgi"
|
|
10 |
|
|
11 |
DISTPREFIX=${DISTPREFIX:-~/tmp/isadist}
|
|
12 |
TMP="tmp-$USER$$"
|
|
13 |
|
|
14 |
umask 022
|
|
15 |
|
|
16 |
|
|
17 |
## diagnostics
|
|
18 |
|
|
19 |
PRG=$(basename "$0")
|
|
20 |
THIS=$(cd $(dirname "$0"); echo "$PWD")
|
|
21 |
|
|
22 |
function usage()
|
|
23 |
{
|
|
24 |
cat <<EOF
|
|
25 |
|
|
26 |
Usage: $PRG [OPTIONS] [VERSION]
|
|
27 |
|
|
28 |
Options are:
|
|
29 |
-r NAME proper release with name"
|
|
30 |
|
|
31 |
FIXME Make Isabelle distribution from the master sources at TUM.
|
|
32 |
|
|
33 |
VERSION may be either a tag like "IsabelleXXXX" that specifies the
|
|
34 |
release to be exported from the repository, or "-" to checkout the
|
|
35 |
current sources as an unofficial release.
|
|
36 |
|
|
37 |
NAME specifies an explicit distribution name, by default it is
|
|
38 |
derived from VERSION.
|
|
39 |
|
|
40 |
EOF
|
|
41 |
exit 1
|
|
42 |
}
|
|
43 |
|
|
44 |
function fail()
|
|
45 |
{
|
|
46 |
echo "$1" >&2
|
|
47 |
exit 2
|
|
48 |
}
|
|
49 |
|
|
50 |
|
|
51 |
## process command line
|
|
52 |
|
|
53 |
# options
|
|
54 |
|
|
55 |
RELEASE=""
|
|
56 |
|
|
57 |
while getopts "r:" OPT
|
|
58 |
do
|
|
59 |
case "$OPT" in
|
|
60 |
r)
|
|
61 |
RELEASE="$OPTARG"
|
|
62 |
;;
|
|
63 |
\?)
|
|
64 |
usage
|
|
65 |
;;
|
|
66 |
esac
|
|
67 |
done
|
|
68 |
|
|
69 |
shift $(($OPTIND - 1))
|
|
70 |
|
|
71 |
|
|
72 |
# args
|
|
73 |
|
|
74 |
VERSION="tip"
|
|
75 |
[ "$#" -gt 0 ] && { VERSION="$1"; shift; }
|
|
76 |
|
|
77 |
[ "$#" -gt 0 ] && usage
|
|
78 |
|
|
79 |
|
|
80 |
## main
|
|
81 |
|
|
82 |
# retrieve archive and resolve version identifier
|
|
83 |
|
|
84 |
mkdir "$DISTPREFIX/$TMP" || fail "Failed to create fresh directory"
|
|
85 |
cd "$DISTPREFIX/$TMP"
|
|
86 |
|
|
87 |
echo "###"
|
|
88 |
echo "### Retrieving $REPOS/archive/${VERSION}.tar.gz"
|
|
89 |
echo "###"
|
|
90 |
|
|
91 |
{ wget -q "$REPOS/archive/${VERSION}.tar.gz" && tar -x -z -f "${VERSION}.tar.gz"; } || \
|
|
92 |
fail "Failed to retrieve $VERSION"
|
|
93 |
|
|
94 |
rm "${VERSION}.tar.gz"
|
|
95 |
IDENT=$(echo * | sed 's/Isabelle-repository-//')
|
|
96 |
|
|
97 |
rm "Isabelle-repository-$IDENT/.hg_archival.txt"
|
|
98 |
rm "Isabelle-repository-$IDENT/.hgtags"
|
|
99 |
|
|
100 |
|
|
101 |
# dist name
|
|
102 |
|
|
103 |
DATE=$(env LC_ALL=C date "+%d-%b-%Y")
|
|
104 |
DISTDATE=$(env LC_ALL=C date "+%B %Y")
|
|
105 |
|
|
106 |
if [ -z "$RELEASE" ]; then
|
|
107 |
DISTNAME="Isabelle_$DATE"
|
|
108 |
DISTVERSION="Isabelle repository snapshot $IDENT ($DATE)"
|
|
109 |
else
|
|
110 |
DISTNAME="$RELEASE"
|
|
111 |
DISTVERSION="$DISTNAME: $DISTDATE"
|
|
112 |
fi
|
|
113 |
|
|
114 |
DISTBASE="$DISTPREFIX/dist-$DISTNAME"
|
|
115 |
mkdir -p "$DISTBASE" || fail "Unable to create distribution base dir $DISTBASE!"
|
|
116 |
[ -e "$DISTBASE/$DISTNAME" ] && fail "$DISTBASE/$DISTNAME already exists!"
|
|
117 |
[ -e "$DISTBASE/pdf/$DISTNAME" ] && fail "$DISTBASE/pdf/$DISTNAME already exists!"
|
|
118 |
|
|
119 |
cd "$DISTBASE"
|
|
120 |
mv "$DISTPREFIX/$TMP/Isabelle-repository-$IDENT" "$DISTNAME"
|
|
121 |
rm -rf "$DISTPREFIX/$TMP"
|
|
122 |
|
|
123 |
cd "$DISTNAME" || fail "No dist directory: $DISTBASE/$DISTNAME"
|
|
124 |
|
|
125 |
|
|
126 |
# website
|
|
127 |
|
|
128 |
mkdir -p ../website
|
|
129 |
cat > ../website/distinfo.mak <<EOF
|
|
130 |
# this is a generated file - do not edit unless you know what you are doing!
|
|
131 |
|
|
132 |
DISTNAME=$DISTNAME
|
|
133 |
DISTBASE=$DISTBASE
|
|
134 |
EOF
|
|
135 |
|
|
136 |
cp lib/html/library_index_content.template ../website/
|
|
137 |
|
|
138 |
|
|
139 |
# prepare dist for release
|
|
140 |
|
|
141 |
echo "###"
|
|
142 |
echo "### Preparing distribution $DISTNAME"
|
|
143 |
echo "###"
|
|
144 |
|
|
145 |
find . "(" -name \*.thy -o -name \*.ML ")" -perm +111 -print | xargs chmod -x
|
|
146 |
find . -print | xargs chmod u+rw
|
|
147 |
|
|
148 |
./Admin/build all || fail "Failed to build distribution"
|
|
149 |
rm -rf Admin
|
|
150 |
|
|
151 |
MOVE=$(find doc-src \( -type f -a -not -type l -a -not -name isabelle_isar.pdf -a -not -name pghead.pdf -a \( -name \*.dvi -o -name \*.eps -o -name \*.ps -o -name \*.pdf \) -a -print \) | grep -v 'gfx/.*pdf')
|
|
152 |
mv -f $MOVE doc
|
|
153 |
rm doc/Isa-logics.eps
|
|
154 |
rm doc/codegen_process.pdf
|
|
155 |
rm -rf doc-src
|
|
156 |
|
|
157 |
mkdir contrib
|
|
158 |
|
|
159 |
cp doc/isabelle*.eps lib/logo
|
|
160 |
|
|
161 |
|
|
162 |
if [ -z "$RELEASE" ]; then
|
|
163 |
{
|
|
164 |
echo
|
|
165 |
echo "IMPORTANT NOTE"
|
|
166 |
echo "=============="
|
|
167 |
echo
|
|
168 |
echo "This is an unofficial snapshot of Isabelle, created by $LOGNAME $DATE."
|
|
169 |
echo "See $REPOS/log/$IDENT for details."
|
|
170 |
echo
|
|
171 |
} >ANNOUNCE
|
|
172 |
else
|
|
173 |
perl -pi -e "s/val is_official = false/val is_official = true/" src/Pure/ROOT.ML
|
|
174 |
fi
|
|
175 |
|
|
176 |
perl -pi -e "s/val changelog = \"\"/val changelog = \"$REPOS/log/$IDENT\"/" src/Pure/ROOT.ML
|
|
177 |
perl -pi -e "s/ISABELLE_IDENTIFIER=\"\"/ISABELLE_IDENTIFIER=\"$DISTNAME\"/g;" lib/scripts/getsettings
|
|
178 |
perl -pi -e "s/{ISABELLE}/$DISTNAME/g;" lib/html/library_index_header.template
|
|
179 |
perl -pi -e "s/Isabelle repository version/$DISTVERSION/" src/Pure/ROOT.ML lib/Tools/version
|
|
180 |
perl -pi -e "s/the internal repository version of Isabelle/$DISTVERSION/" README
|
|
181 |
|
|
182 |
|
|
183 |
# create archives
|
|
184 |
|
|
185 |
echo "###"
|
|
186 |
echo "### Creating archives ..."
|
|
187 |
echo "###"
|
|
188 |
|
|
189 |
cd "$DISTBASE"
|
|
190 |
|
|
191 |
echo "$DISTBASE/$DISTNAME.tar.gz" > ../ISABELLE_DIST
|
|
192 |
echo "$IDENT" >../ISABELLE_IDENT
|
|
193 |
|
|
194 |
rm -f Isabelle
|
|
195 |
ln -s "$DISTNAME" Isabelle
|
|
196 |
|
|
197 |
chown -R "$LOGNAME" "$DISTNAME"
|
|
198 |
chmod -R u+w "$DISTNAME"
|
|
199 |
chmod -R g=o "$DISTNAME"
|
|
200 |
chgrp -R isabelle "$DISTNAME" Isabelle
|
|
201 |
|
|
202 |
mkdir -p "pdf/$DISTNAME/doc"
|
|
203 |
mv "$DISTNAME/doc/"*.pdf "pdf/$DISTNAME/doc"
|
|
204 |
|
|
205 |
echo "$DISTNAME.tar.gz"
|
|
206 |
tar -c -z -f "$DISTNAME.tar.gz" Isabelle "$DISTNAME"
|
|
207 |
|
|
208 |
echo "${DISTNAME}_pdf.tar.gz"
|
|
209 |
tar -C pdf -c -z -f "${DISTNAME}_pdf.tar.gz" "$DISTNAME"
|
|
210 |
|
|
211 |
mv "pdf/$DISTNAME/doc/"*.pdf "$DISTNAME/doc"
|
|
212 |
rmdir "pdf/$DISTNAME/doc" "pdf/$DISTNAME" pdf
|
|
213 |
|
|
214 |
|
|
215 |
# cleanup dist
|
|
216 |
|
|
217 |
mv "$DISTNAME" "${DISTNAME}-old"
|
|
218 |
mkdir "$DISTNAME"
|
|
219 |
|
|
220 |
mv "${DISTNAME}-old/README" "${DISTNAME}-old/INSTALL" "${DISTNAME}-old/NEWS" \
|
|
221 |
"${DISTNAME}-old/ANNOUNCE" "${DISTNAME}-old/COPYRIGHT" "${DISTNAME}-old/CONTRIBUTORS" \
|
|
222 |
"$DISTNAME"
|
|
223 |
mkdir "$DISTNAME/doc"
|
|
224 |
mv "${DISTNAME}-old/doc/"*.pdf "${DISTNAME}-old/doc/Contents" "$DISTNAME/doc"
|
|
225 |
|
|
226 |
chgrp -R isabelle "$DISTNAME"
|
|
227 |
|
|
228 |
rm -rf "${DISTNAME}-old"
|
|
229 |
|
|
230 |
echo "###"
|
|
231 |
echo "### Finished makedist."
|
|
232 |
echo "###"
|