-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathuninstall_cutest
executable file
·101 lines (80 loc) · 2.51 KB
/
uninstall_cutest
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
#!/bin/bash
# Remove script for cutest
# version for Bourne/bash shell
# syntax: uninstall_cutest
# N. Gould, D. Orban & Ph. Toint
# ( Last modified on 20 October 2012 at 11:00 GMT )
if [[ ! -e ./install_cutest ]]; then
echo 'Error: This script must be run from the top-level CUTEst directory.'
exit 1
fi
. ./bin/cutest_envcheck
[[ $? != 0 ]] && exit $?
. $ARCHDEFS/bin/helper_functions
# check input arguments (if any)
if [[ $# != 0 ]]; then
echo "Use: uninstall_cutest"
exit 1
fi
export CUTEST=`dirs -l`
export CUTEST=`echo $CUTEST | \sed 's"/tmp_mnt""'`
finished='false'
while [[ $finished != 'true' ]]; do
# VERS=( `\ls $CUTEST/versions/*` )
VERS=( `\ls $CUTEST/versions/* 2>/dev/null` )
NUMBER=${#VERS[@]}
if [[ $NUMBER == 0 ]]; then
warning "No versions of CUTEST are currently installed."
exit 1
fi
LIST=( ${VERS[@]} )
CORRECT_VERSION="false"
while [[ $CORRECT_VERSION == "false" ]]; do
echo -e " The following versions of CUTEST are currently installed.\n"
count=0
for i in ${LIST[@]}; do
(( count++ ))
(( cnt = count-1 )) # 0-based indexing
VERSION="`cat ${VERS[$cnt]}`"
echo " ($count) ${VERSION}"
done
echo -e "\n Which do you wish to uninstall: (1-$NUMBER)?"
read CHOICE
(( CHOICE-- ))
i=0
while [[ $i -lt $NUMBER && $CORRECT_VERSION == "false" ]]; do
if [[ $CHOICE == $i ]]; then
CORRECT_VERSION="true"
CHOICE=$i
fi
(( i++ ))
done
if [[ $CORRECT_VERSION == "true" ]]; then
VERSION=${VERS[$CHOICE]##*/}
VERNAME=`cat ${VERS[$CHOICE]}`
else
echo " Please give an integer between 1 and $NUMBER"
fi
done
echo " Are you sure you wish to uninstall the version for"
yesno_default_yes " $VERNAME"
if [[ $? == 1 ]]; then
echo " Removing object files and libraries ... "
\rm -f -r $CUTEST/objects/$VERSION
echo " Removing module information files ... "
\rm -f -r $CUTEST/modules/$VERSION
echo " Removing non-standard package files ... "
\rm -f -r $CUTEST/packages/$VERSION
echo " Removing environment information file ... "
\rm -f -r $CUTEST/bin/sys/$VERSION
echo " Removing make information file ... "
\rm -f -r $CUTEST/makefiles/$VERSION
echo " Removing version record file ... "
\rm -f -r $CUTEST/versions/$VERSION
success " Version for
$VERNAME
successfully removed."
fi
yesno_default_no " Do you wish to uninstall another version"
[[ $? == 0 ]] && finished='true'
done