-
Notifications
You must be signed in to change notification settings - Fork 50
/
install-scripts
executable file
·105 lines (89 loc) · 3.37 KB
/
install-scripts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/bash
usage() {
echo "Installs NASALib pvs-cripts/patches.
The option --pvs-dir <pvs path> can be used to provide the directory where PVS is installed.
This option can be omitted if the directory is in the \$PVS_DIR or the \$PATH environment variables."
}
pvsdir=
while [ $# -gt 0 ]
do
case $1 in
-h|-help|--help)
usage
exit 0;;
-p|-pvs-dir|--pvs-dir)
shift
pvsdir=$1;;
*)
echo "Error: unknown option $1"
echo "Type ./install-scripts -h for help"
exit 1;;
esac
shift
done
## Print current version of NASALib
./nasalib-version
[ ! "$?" -eq "0" ] && echo 'Please double-check PVS_LIBRARY_PATH contains the directory where an up-to-date version of NASALib is installed and try again.' && exit $?
## Append code into .pvsemacs in order to load
## automatically load el files into emacs-PVS
LOAD_EL_SNIPPET_v0="(let ((nasalib-path (pvs-send-and-wait \"(extra-pvs-nasalib)\"))) (loop for el-file in (directory-files (format \"%spvs-emacs\" nasalib-path) nil \".el\") do (load (format \"%spvs-emacs/%s\" nasalib-path el-file))))"
## Corrected version of snippet for newer emacs
BEGINNING_OF_MARKER=";; BEGINNING OF ADDITION BY install-scripts AT NASALib"
END_OF_MARKER=";; END OF ADDITION BY install-scripts AT NASALib"
LOAD_EL_SNIPPET_v1="$BEGINNING_OF_MARKER
(let ((nasalib-path (pvs-send-and-wait \"(nasalib-path)\")))
(when (and (stringp nasalib-path) (file-directory-p nasalib-path))
(cl-loop for el-file in (directory-files (format \"%spvs-emacs\" nasalib-path) nil \".el\")
when el-file
do (load (format \"%spvs-emacs/%s\" nasalib-path el-file)))))
$END_OF_MARKER"
if [ -f ~/.pvsemacs ]; then
echo "Modifying ~/.pvsemacs, backing-up the current file in ~/.pvsemacs.bak"
if grep -Fq "$LOAD_EL_SNIPPET_v0" ~/.pvsemacs
then ## Removing v0 addition
sed -e "s|$LOAD_EL_SNIPPET_v0|<<TODELETE>>|" -e "/<<TODELETE>>/ d" ~/.pvsemacs > ~/.pvsemacs.new
elif grep -Fq "$BEGINNING_OF_MARKER" ~/.pvsemacs
then ## Removing code between markers
sed -e "/$BEGINNING_OF_MARKER/,/$END_OF_MARKER/ d" ~/.pvsemacs > ~/.pvsemacs.new
else
cp -f ~/.pvsemacs ~/.pvsemacs.new
fi
echo "$LOAD_EL_SNIPPET_v1" >> ~/.pvsemacs.new
mv -f ~/.pvsemacs ~/.pvsemacs.bak
mv -f ~/.pvsemacs.new ~/.pvsemacs
else
echo "$LOAD_EL_SNIPPET_v1" >> ~/.pvsemacs
fi
## Check if there are scripts
if [ ! -d "pvs-scripts/patches" ]; then
echo "There are no pvs-scripts patches to be installed"
exit 0
fi
if [ -z "$pvsdir" ]; then
pvsdir=$PVS_DIR
fi
if [ ! -d "$pvsdir" ]; then
PVS=`command -v pvs`
if [ ! -z "$PVS" ]; then
pvsdir=${PVS%/*}
else
pvsdir="../"
fi
echo "Assuming $pvsdir as the PVS active installation directory."
fi
if [ -L "$pvsdir" ]; then
pvsdir=$(readlink -f "$pvsdir")
fi
if [ ! -f "$pvsdir/pvs" -o ! -x "$pvsdir/install-sh" ]; then
echo "PVS does not seem to be properly installed in '$pvsdir'.
Please use the --pvs-dir <pvs path> option to provide the directory where PVS is installed."
exit 1
fi
if [ ! -f "$pvsdir/install-sh" -o ! -x "$pvsdir/install-sh" ]; then
echo "PVS install script (install-sh) could not be found at '$pvsdir'.
Please double check that PVS is correctly installed in this directory and try again."
exit 1
fi
echo "Installing NASALib pvs-scripts/patches into $pvsdir"
rsync -av --existing --exclude '.*' pvs-scripts/patches/ $pvsdir/
cd $pvsdir;./install-sh