| •1 |
#!/usr/bin/bashscip-shell filesystem . . `/usr/bin/bash`. |
| 2 |
|
| 3 |
# Instantiate links to library files in index template |
| 4 |
|
| 5 |
set -e |
| 6 |
|
| 7 |
FILE=$1 |
| 8 |
HIDDEN=$2 |
| 9 |
tmp=$(mktempscip-shell system . . mktemp.) |
| 10 |
tmp2=$(mktempscip-shell system . . mktemp.) |
| 11 |
|
| 12 |
cpscip-shell system . . cp. -f "$FILE.template" "$tmp" |
| 13 |
echoscip-shell system . . echo. -n "Building file index-list.prehtml... " |
| 14 |
|
| 15 |
LIBDIRS=$(findscip-shell system . . find. theories -type d ! -name .coq-native) |
| 16 |
|
| 17 |
missing= |
| 18 |
|
| 19 |
for k in $LIBDIRS; do |
| 20 |
d=$(basenamescip-shell system . . basename. "$k") |
| 21 |
p=$(echoscip-shell system . . echo. "$k" | sedscip-shell system . . sed. 's:^[^/]*/::' | sedscip-shell system . . sed. 's:/:.:g') |
| 22 |
for j in "$k"/*.v; do |
| 23 |
if ! [scip-shell system . . `[`. -e "$j" ]; then break; fi |
| 24 |
b=$(basenamescip-shell system . . basename. "$j" .v) |
| 25 |
|
| 26 |
a=0; grepscip-shell system . . grep. -q "$k/$b.v" "$tmp" || a=$? |
| 27 |
h=0; grepscip-shell system . . grep. -q "$k/$b.v" "$HIDDEN" || h=$? |
| 28 |
if [scip-shell system . . `[`. $a = 0 ]; then |
| 29 |
if [scip-shell system . . `[`. $h = 0 ]; then |
| 30 |
echoscip-shell system . . echo. "Error: $FILE and $HIDDEN both mention $k/$b.v" >&2 |
| 31 |
exit 1 |
| 32 |
else |
| 33 |
sedscip-shell system . . sed. -e "s:$k/$b.v:<a href=\"$p.$b.html\">$b</a>:g" "$tmp" > "$tmp2" |
| 34 |
mvscip-shell system . . mv. -f "$tmp2" "$tmp" |
| 35 |
fi |
| 36 |
else |
| 37 |
if [scip-shell system . . `[`. $h = 0 ]; then |
| 38 |
# Skipping file from the index |
| 39 |
: |
| 40 |
else |
| 41 |
missing="$missing $k/$b.v" |
| 42 |
fi |
| 43 |
fi |
| 44 |
done |
| 45 |
sedscip-shell system . . sed. -e "s/#$d#//" "$tmp" > "$tmp2" |
| 46 |
mvscip-shell system . . mv. -f "$tmp2" "$tmp" |
| 47 |
done |
| 48 |
|
| 49 |
if [scip-shell system . . `[`. "$missing" ]; then |
| 50 |
echoscip-shell system . . echo. "Error: none of $FILE and $HIDDEN mention$missing" >&2 |
| 51 |
exit 1 |
| 52 |
fi |
| 53 |
|
| 54 |
if a=$(grepscip-shell system . . grep. theories "$tmp"); then echoscip-shell system . . echo. Error: extra files: >&2; echoscip-shell system . . echo. "$a" >&2; exit 1; fi |
| 55 |
mvscip-shell system . . mv. "$tmp" "$FILE" |
| 56 |
echoscip-shell system . . echo. Done |