author | wenzelm |
Sun, 28 Mar 2021 12:10:14 +0200 | |
changeset 73508 | 001097314d09 |
parent 73507 | 2592a661ddc9 |
permissions | -rwxr-xr-x |
73487 | 1 |
#!/usr/bin/env bash |
2 |
# |
|
3 |
# Author: Makarius |
|
4 |
# |
|
5 |
# DESCRIPTION: setup for Isabelle repository clone or repository archive |
|
6 |
||
7 |
||
73501
f026a9a0a43f
proper Admin script, outside the settings environment;
wenzelm
parents:
73497
diff
changeset
|
8 |
## environment |
73487 | 9 |
|
73501
f026a9a0a43f
proper Admin script, outside the settings environment;
wenzelm
parents:
73497
diff
changeset
|
10 |
export ISABELLE_HOME="$(cd "$(dirname "$0")"; cd "$(pwd -P)"; cd ..; pwd)" |
73487 | 11 |
|
73491
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
12 |
ISABELLE_REPOS="https://isabelle.sketis.net/repos/isabelle" |
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
13 |
|
73501
f026a9a0a43f
proper Admin script, outside the settings environment;
wenzelm
parents:
73497
diff
changeset
|
14 |
|
f026a9a0a43f
proper Admin script, outside the settings environment;
wenzelm
parents:
73497
diff
changeset
|
15 |
## diagnostics |
f026a9a0a43f
proper Admin script, outside the settings environment;
wenzelm
parents:
73497
diff
changeset
|
16 |
|
73487 | 17 |
function usage() |
18 |
{ |
|
19 |
echo |
|
73501
f026a9a0a43f
proper Admin script, outside the settings environment;
wenzelm
parents:
73497
diff
changeset
|
20 |
echo "Usage: Admin/setup [OPTIONS]" |
73487 | 21 |
echo |
22 |
echo " Options are:" |
|
73502 | 23 |
echo " -C force clean working directory (no backup!)" |
73491
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
24 |
echo " -R version is current official release" |
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
25 |
echo " -U URL Isabelle repository server (default: \"$ISABELLE_REPOS\")" |
73487 | 26 |
echo " -V PATH version from explicit file or directory (file \"ISABELLE_VERSION\")" |
73502 | 27 |
echo " -c check clean working directory" |
73504 | 28 |
echo " -f fresh build of Isabelle/Scala/jEdit" |
29 |
echo " -n no build of Isabelle/Scala/jEdit" |
|
73493 | 30 |
echo " -r REV version according to Mercurial notation" |
73508 | 31 |
echo " -u version is tip (after pull from Isabelle repository server)" |
73487 | 32 |
echo |
33 |
echo " Setup the current ISABELLE_HOME directory, which needs to be a" |
|
34 |
echo " repository clone (all versions) or repository archive (fixed version)." |
|
73506 | 35 |
echo " Download required components and build Isabelle/Scala/jEdit (default)." |
73487 | 36 |
echo |
37 |
exit 1 |
|
38 |
} |
|
39 |
||
40 |
function fail() |
|
41 |
{ |
|
42 |
echo "$1" >&2 |
|
43 |
exit 2 |
|
44 |
} |
|
45 |
||
46 |
||
47 |
## process command line |
|
48 |
||
49 |
#options |
|
50 |
||
73504 | 51 |
BUILD_OPTIONS="-b" |
52 |
||
73502 | 53 |
CLEAN_FORCE="" |
54 |
CLEAN_CHECK="" |
|
73491
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
55 |
|
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
56 |
VERSION="" |
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
57 |
VERSION_RELEASE="" |
73487 | 58 |
VERSION_PATH="" |
73488 | 59 |
VERSION_REV="" |
73487 | 60 |
|
73504 | 61 |
while getopts "CRU:V:cfnr:u" OPT |
73487 | 62 |
do |
63 |
case "$OPT" in |
|
73488 | 64 |
C) |
73502 | 65 |
CLEAN_FORCE="--clean" |
73487 | 66 |
;; |
73491
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
67 |
R) |
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
68 |
VERSION="true" |
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
69 |
VERSION_RELEASE="true" |
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
70 |
VERSION_PATH="" |
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
71 |
VERSION_REV="" |
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
72 |
;; |
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
73 |
U) |
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
74 |
ISABELLE_REPOS="$OPTARG" |
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
75 |
;; |
73487 | 76 |
V) |
73491
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
77 |
VERSION="true" |
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
78 |
VERSION_RELEASE="" |
73487 | 79 |
VERSION_PATH="$OPTARG" |
73491
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
80 |
VERSION_REV="" |
73487 | 81 |
;; |
73502 | 82 |
c) |
83 |
CLEAN_CHECK="--check" |
|
84 |
;; |
|
73504 | 85 |
f) |
86 |
BUILD_OPTIONS="-b -f" |
|
87 |
;; |
|
88 |
n) |
|
89 |
BUILD_OPTIONS="" |
|
90 |
;; |
|
73488 | 91 |
r) |
73491
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
92 |
VERSION="true" |
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
93 |
VERSION_RELEASE="" |
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
94 |
VERSION_PATH="" |
73488 | 95 |
VERSION_REV="$OPTARG" |
96 |
;; |
|
73492 | 97 |
u) |
98 |
VERSION="true" |
|
99 |
VERSION_RELEASE="" |
|
100 |
VERSION_PATH="" |
|
73493 | 101 |
VERSION_REV="tip" |
73492 | 102 |
;; |
73487 | 103 |
\?) |
104 |
usage |
|
105 |
;; |
|
106 |
esac |
|
107 |
done |
|
108 |
||
109 |
shift $(($OPTIND - 1)) |
|
110 |
||
111 |
||
112 |
# args |
|
113 |
||
114 |
[ "$#" -ne 0 ] && usage |
|
115 |
||
116 |
||
117 |
## main |
|
118 |
||
73491
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
119 |
if [ -z "$VERSION" ]; then |
73504 | 120 |
"$ISABELLE_HOME/bin/isabelle" components -I || exit "?$" |
121 |
"$ISABELLE_HOME/bin/isabelle" components -a || exit "?$" |
|
122 |
if [ -n "$BUILD_OPTIONS" ]; then |
|
123 |
"$ISABELLE_HOME/bin/isabelle" jedit $BUILD_OPTIONS |
|
124 |
fi |
|
73487 | 125 |
elif [ ! -d "$ISABELLE_HOME/.hg" ]; then |
126 |
fail "Not a repository clone: cannot specify version" |
|
127 |
else |
|
128 |
if [ -n "$VERSION_REV" ]; then |
|
129 |
REV="$VERSION_REV" |
|
73491
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
130 |
elif [ -n "$VERSION_RELEASE" ]; then |
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
131 |
URL="$ISABELLE_REPOS/raw-file/tip/Admin/Release/official" |
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
132 |
REV="$(curl -s -f "$URL" | head -n1)" |
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
133 |
[ -z "$REV" ] && fail "Failed to access \"$URL\"" |
73487 | 134 |
elif [ -f "$VERSION_PATH" ]; then |
135 |
REV="$(cat "$VERSION_PATH")" |
|
136 |
elif [ -d "$VERSION_PATH" ]; then |
|
137 |
if [ -f "$VERSION_PATH/ISABELLE_VERSION" ]; then |
|
138 |
REV="$(cat "$VERSION_PATH/ISABELLE_VERSION")" |
|
139 |
else |
|
140 |
fail "Missing file \"$VERSION_PATH/ISABELLE_VERSION\"" |
|
141 |
fi |
|
142 |
else |
|
143 |
fail "Missing file \"$VERSION_PATH\"" |
|
144 |
fi |
|
145 |
||
73507 | 146 |
"$ISABELLE_HOME/bin/isabelle" components -I || exit "$?" |
147 |
||
73487 | 148 |
export LANG=C |
149 |
export HGPLAIN= |
|
150 |
||
151 |
#Atomic exec: avoid inplace update of running script! |
|
73505 | 152 |
export CLEAN_FORCE CLEAN_CHECK REV ISABELLE_REPOS BUILD_OPTIONS |
73487 | 153 |
exec bash -c ' |
154 |
set -e |
|
73493 | 155 |
"${HG:-hg}" -R "$ISABELLE_HOME" pull -r "$REV" "$ISABELLE_REPOS" |
73502 | 156 |
"${HG:-hg}" -R "$ISABELLE_HOME" update -r "$REV" $CLEAN_FORCE $CLEAN_CHECK |
73501
f026a9a0a43f
proper Admin script, outside the settings environment;
wenzelm
parents:
73497
diff
changeset
|
157 |
"$ISABELLE_HOME/bin/isabelle" components -a |
73504 | 158 |
if [ -n "$BUILD_OPTIONS" ]; then |
159 |
"$ISABELLE_HOME/bin/isabelle" jedit $BUILD_OPTIONS |
|
160 |
fi |
|
73489 | 161 |
"${HG:-hg}" -R "$ISABELLE_HOME" log -r "$REV" |
73501
f026a9a0a43f
proper Admin script, outside the settings environment;
wenzelm
parents:
73497
diff
changeset
|
162 |
if [ ! -f "$ISABELLE_HOME/Admin/setup" ]; then |
f026a9a0a43f
proper Admin script, outside the settings environment;
wenzelm
parents:
73497
diff
changeset
|
163 |
echo >&2 "### The Admin/setup script has disappeared in this version" |
73497 | 164 |
echo >&2 "### (need to invoke \"${HG:-hg} update\" before using it again)" |
73494 | 165 |
fi |
73487 | 166 |
' |
167 |
fi |