1 #!/usr/bin/env bash |
|
2 # |
|
3 # makebundle -- re-package with add-on components |
|
4 |
|
5 ## diagnostics |
|
6 |
|
7 PRG=$(basename "$0") |
|
8 |
|
9 function usage() |
|
10 { |
|
11 echo |
|
12 echo "Usage: $PRG ARCHIVE PLATFORM" |
|
13 echo |
|
14 echo " Re-package Isabelle source distribution with add-on components" |
|
15 echo " and heap images" |
|
16 echo |
|
17 exit 1 |
|
18 } |
|
19 |
|
20 function fail() |
|
21 { |
|
22 echo "$1" >&2 |
|
23 exit 2 |
|
24 } |
|
25 |
|
26 |
|
27 ## implicit and explicit arguments |
|
28 |
|
29 TMP="/var/tmp/isabelle-makebundle$$" |
|
30 mkdir "$TMP" || fail "Cannot create directory $TMP" |
|
31 |
|
32 [ "$#" -ne 2 ] && usage |
|
33 |
|
34 ARCHIVE="$1"; shift |
|
35 PLATFORM="$1"; shift |
|
36 |
|
37 [ -f "$ARCHIVE" ] || fail "Bad source archive: $ARCHIVE" |
|
38 |
|
39 |
|
40 ## main |
|
41 |
|
42 ARCHIVE_DIR="$(cd $(dirname "$ARCHIVE"); echo "$PWD")" |
|
43 ISABELLE_NAME="$(basename "$ARCHIVE" .tar.gz)" |
|
44 ISABELLE_HOME="$TMP/$ISABELLE_NAME" |
|
45 |
|
46 tar -C "$TMP" -x -z -f "$ARCHIVE" |
|
47 |
|
48 |
|
49 echo "#bundled components" >> "$ISABELLE_HOME/etc/components" |
|
50 |
|
51 for CONTRIB in "$ARCHIVE_DIR/contrib/"*.tar.gz "$ARCHIVE_DIR/contrib/$PLATFORM"/*.tar.gz |
|
52 do |
|
53 if [ -f "$CONTRIB" ]; then |
|
54 tar -C "$ISABELLE_HOME/contrib" -x -z -f "$CONTRIB" |
|
55 NAME="$(basename "$CONTRIB" .tar.gz)" |
|
56 [ -d "$ISABELLE_HOME/contrib/$NAME" ] || fail "Bad archive content $CONTRIB" |
|
57 |
|
58 if [ -e "$ISABELLE_HOME/contrib/$NAME/etc/settings" ]; then |
|
59 echo "component $NAME" |
|
60 if [ "$PLATFORM" != x86-cygwin -a "$NAME" = ProofGeneral-3.7.1.1 ]; then |
|
61 echo "#contrib/$NAME" >> "$ISABELLE_HOME/etc/components" |
|
62 elif [ "$PLATFORM" = x86-cygwin -a "$NAME" = ProofGeneral-4.1 ]; then |
|
63 echo "#contrib/$NAME" >> "$ISABELLE_HOME/etc/components" |
|
64 else |
|
65 echo "contrib/$NAME" >> "$ISABELLE_HOME/etc/components" |
|
66 fi |
|
67 else |
|
68 echo "package $NAME" |
|
69 fi |
|
70 fi |
|
71 done |
|
72 |
|
73 if [ "$PLATFORM" = x86-cygwin ]; then |
|
74 TAR="$ARCHIVE_DIR/contrib/x86-cygwin/Isabelle.tar" |
|
75 [ -e "$TAR" ] || fail "Missing $TAR" |
|
76 rm -f "$ISABELLE_HOME/Isabelle" |
|
77 tar -C "$ISABELLE_HOME" -xv -f "$TAR" |
|
78 |
|
79 ( |
|
80 cd "$ISABELLE_HOME" |
|
81 for DIR in $(find contrib -name x86-linux -o -name x86_64-linux -o -name x86-darwin -o -name x86_64-darwin | sort) |
|
82 do |
|
83 echo "removing $DIR" |
|
84 rm -rf "$DIR" |
|
85 done |
|
86 ) |
|
87 |
|
88 mv "$ISABELLE_HOME/contrib"/polyml* "$ISABELLE_HOME/contrib/cygwin-1.7.9/usr/local/" |
|
89 ( |
|
90 cd "$ISABELLE_HOME/contrib/cygwin-1.7.9" |
|
91 find usr/local/polyml-*/x86-cygwin | gzip > etc/setup/polyml.lst.gz |
|
92 ) |
|
93 |
|
94 for NAME in ANNOUNCE README NEWS COPYRIGHT CONTRIBUTORS contrib/README |
|
95 do |
|
96 FILE="$ISABELLE_HOME/$NAME" |
|
97 { |
|
98 echo '<?xml version="1.0" encoding="utf-8" ?>' |
|
99 echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' |
|
100 echo '<html xmlns="http://www.w3.org/1999/xhtml">' |
|
101 echo '<head>' |
|
102 echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>' |
|
103 echo "<title>${NAME}</title>" |
|
104 echo '</head>' |
|
105 echo '<body>' |
|
106 echo '<pre>' |
|
107 perl -w -p -e "s/&/&/g; s/</</g; s/>/>/g; s/'/'/g; s/\"/"/g;" "$FILE" |
|
108 echo '</pre>' |
|
109 echo '</body>' |
|
110 } > "${FILE}.html" |
|
111 done |
|
112 fi |
|
113 |
|
114 |
|
115 HEAPS_ARCHIVE="$ARCHIVE_DIR/${ISABELLE_NAME}_heaps_${PLATFORM}.tar.gz" |
|
116 [ -f "$HEAPS_ARCHIVE" ] || fail "Bad heaps archive: $HEAPS_ARCHIVE" |
|
117 echo "heaps" |
|
118 tar -C "$TMP" -x -z -f "$HEAPS_ARCHIVE" |
|
119 |
|
120 case "$PLATFORM" in |
|
121 x86_64-linux) |
|
122 perl -pi -e 's,^ML_PLATFORM=.*$,ML_PLATFORM="\$ISABELLE_PLATFORM64",g;' "$TMP/$ISABELLE_NAME/etc/settings" |
|
123 perl -pi -e "s,^ML_OPTIONS=.*$,ML_OPTIONS=\"-H 400\",g;" "$TMP/$ISABELLE_NAME/etc/settings" |
|
124 ;; |
|
125 *-darwin) |
|
126 perl -pi -e "s,lookAndFeel=.*,lookAndFeel=com.apple.laf.AquaLookAndFeel,g;" \ |
|
127 -e "s,delete-line.shortcut=.*,delete-line.shortcut=C+d,g;" \ |
|
128 -e "s,delete.shortcut2=.*,delete.shortcut2=A+d,g;" \ |
|
129 "$TMP/$ISABELLE_NAME/src/Tools/jEdit/dist/properties/jEdit.props" |
|
130 ;; |
|
131 *-cygwin) |
|
132 perl -pi -e "s,lookAndFeel=.*,lookAndFeel=com.sun.java.swing.plaf.windows.WindowsLookAndFeel,g;" \ |
|
133 "$TMP/$ISABELLE_NAME/src/Tools/jEdit/dist/properties/jEdit.props" |
|
134 ;; |
|
135 *) |
|
136 ;; |
|
137 esac |
|
138 |
|
139 BUNDLE_ARCHIVE="${ARCHIVE_DIR}/${ISABELLE_NAME}_bundle_${PLATFORM}.tar.gz" |
|
140 |
|
141 echo "$(basename "$BUNDLE_ARCHIVE")" |
|
142 tar -C "$TMP" -c -z -f "$BUNDLE_ARCHIVE" "$ISABELLE_NAME" |
|
143 |
|
144 |
|
145 # clean up |
|
146 cd /tmp |
|
147 rm -rf "$TMP" |
|