| author | wenzelm |
| Sun, 28 Mar 2021 11:35:08 +0200 | |
| changeset 73501 | f026a9a0a43f |
| parent 73497 | lib/Tools/setup@7cdcf131699d |
| child 73502 | c582bf975a5b |
| 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:" |
|
| 73488 | 23 |
echo " -C enforce clean update of 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\")" |
| 73493 | 27 |
echo " -r REV version according to Mercurial notation" |
| 73492 | 28 |
echo " -u version is remote tip" |
| 73487 | 29 |
echo |
30 |
echo " Setup the current ISABELLE_HOME directory, which needs to be a" |
|
31 |
echo " repository clone (all versions) or repository archive (fixed version)." |
|
32 |
echo |
|
33 |
exit 1 |
|
34 |
} |
|
35 |
||
36 |
function fail() |
|
37 |
{
|
|
38 |
echo "$1" >&2 |
|
39 |
exit 2 |
|
40 |
} |
|
41 |
||
42 |
||
43 |
## process command line |
|
44 |
||
45 |
#options |
|
46 |
||
| 73488 | 47 |
CLEAN="" |
|
73491
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
48 |
|
|
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
49 |
VERSION="" |
|
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
50 |
VERSION_RELEASE="" |
| 73487 | 51 |
VERSION_PATH="" |
| 73488 | 52 |
VERSION_REV="" |
| 73487 | 53 |
|
| 73492 | 54 |
while getopts "CRU:V:r:u" OPT |
| 73487 | 55 |
do |
56 |
case "$OPT" in |
|
| 73488 | 57 |
C) |
58 |
CLEAN="--clean" |
|
| 73487 | 59 |
;; |
|
73491
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
60 |
R) |
|
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
61 |
VERSION="true" |
|
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
62 |
VERSION_RELEASE="true" |
|
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
63 |
VERSION_PATH="" |
|
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
64 |
VERSION_REV="" |
|
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
65 |
;; |
|
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
66 |
U) |
|
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
67 |
ISABELLE_REPOS="$OPTARG" |
|
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
68 |
;; |
| 73487 | 69 |
V) |
|
73491
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
70 |
VERSION="true" |
|
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
71 |
VERSION_RELEASE="" |
| 73487 | 72 |
VERSION_PATH="$OPTARG" |
|
73491
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
73 |
VERSION_REV="" |
| 73487 | 74 |
;; |
| 73488 | 75 |
r) |
|
73491
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
76 |
VERSION="true" |
|
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
77 |
VERSION_RELEASE="" |
|
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
78 |
VERSION_PATH="" |
| 73488 | 79 |
VERSION_REV="$OPTARG" |
80 |
;; |
|
| 73492 | 81 |
u) |
82 |
VERSION="true" |
|
83 |
VERSION_RELEASE="" |
|
84 |
VERSION_PATH="" |
|
| 73493 | 85 |
VERSION_REV="tip" |
| 73492 | 86 |
;; |
| 73487 | 87 |
\?) |
88 |
usage |
|
89 |
;; |
|
90 |
esac |
|
91 |
done |
|
92 |
||
93 |
shift $(($OPTIND - 1)) |
|
94 |
||
95 |
||
96 |
# args |
|
97 |
||
98 |
[ "$#" -ne 0 ] && usage |
|
99 |
||
100 |
||
101 |
## main |
|
102 |
||
|
73491
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
103 |
if [ -z "$VERSION" ]; then |
|
73501
f026a9a0a43f
proper Admin script, outside the settings environment;
wenzelm
parents:
73497
diff
changeset
|
104 |
"$ISABELLE_HOME/bin/isabelle" components -I && \ |
|
f026a9a0a43f
proper Admin script, outside the settings environment;
wenzelm
parents:
73497
diff
changeset
|
105 |
"$ISABELLE_HOME/bin/isabelle" components -a |
| 73487 | 106 |
elif [ ! -d "$ISABELLE_HOME/.hg" ]; then |
107 |
fail "Not a repository clone: cannot specify version" |
|
108 |
else |
|
109 |
if [ -n "$VERSION_REV" ]; then |
|
110 |
REV="$VERSION_REV" |
|
|
73491
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
111 |
elif [ -n "$VERSION_RELEASE" ]; then |
|
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
112 |
URL="$ISABELLE_REPOS/raw-file/tip/Admin/Release/official" |
|
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
113 |
REV="$(curl -s -f "$URL" | head -n1)" |
|
dbe5bbc2331e
clarified treatment of multiple versions: last one counts;
wenzelm
parents:
73490
diff
changeset
|
114 |
[ -z "$REV" ] && fail "Failed to access \"$URL\"" |
| 73487 | 115 |
elif [ -f "$VERSION_PATH" ]; then |
116 |
REV="$(cat "$VERSION_PATH")" |
|
117 |
elif [ -d "$VERSION_PATH" ]; then |
|
118 |
if [ -f "$VERSION_PATH/ISABELLE_VERSION" ]; then |
|
119 |
REV="$(cat "$VERSION_PATH/ISABELLE_VERSION")" |
|
120 |
else |
|
121 |
fail "Missing file \"$VERSION_PATH/ISABELLE_VERSION\"" |
|
122 |
fi |
|
123 |
else |
|
124 |
fail "Missing file \"$VERSION_PATH\"" |
|
125 |
fi |
|
126 |
||
127 |
export LANG=C |
|
128 |
export HGPLAIN= |
|
129 |
||
|
73501
f026a9a0a43f
proper Admin script, outside the settings environment;
wenzelm
parents:
73497
diff
changeset
|
130 |
"$ISABELLE_HOME/bin/isabelle" components -I || exit "$?" |
| 73487 | 131 |
|
132 |
#Atomic exec: avoid inplace update of running script! |
|
| 73493 | 133 |
export CLEAN REV ISABELLE_REPOS |
| 73487 | 134 |
exec bash -c ' |
135 |
set -e |
|
| 73493 | 136 |
"${HG:-hg}" -R "$ISABELLE_HOME" pull -r "$REV" "$ISABELLE_REPOS"
|
| 73489 | 137 |
"${HG:-hg}" -R "$ISABELLE_HOME" update -r "$REV" $CLEAN
|
|
73501
f026a9a0a43f
proper Admin script, outside the settings environment;
wenzelm
parents:
73497
diff
changeset
|
138 |
"$ISABELLE_HOME/bin/isabelle" components -a |
| 73489 | 139 |
"${HG:-hg}" -R "$ISABELLE_HOME" log -r "$REV"
|
|
73501
f026a9a0a43f
proper Admin script, outside the settings environment;
wenzelm
parents:
73497
diff
changeset
|
140 |
if [ ! -f "$ISABELLE_HOME/Admin/setup" ]; then |
|
f026a9a0a43f
proper Admin script, outside the settings environment;
wenzelm
parents:
73497
diff
changeset
|
141 |
echo >&2 "### The Admin/setup script has disappeared in this version" |
| 73497 | 142 |
echo >&2 "### (need to invoke \"${HG:-hg} update\" before using it again)"
|
| 73494 | 143 |
fi |
| 73487 | 144 |
' |
145 |
fi |