forked from ilius/starcal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall
executable file
·82 lines (63 loc) · 1.77 KB
/
uninstall
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
#!/bin/bash
function printUsage {
echo "Usage: $0 [--prefix=/usr/local]"
}
pkgName=starcal3
options=`getopt -o 'v' --long 'prefix:,verbose' -n "$0" -- "$@"`
if [ $? != 0 ] ; then
printUsage
exit 1
fi
eval set -- "$options" ## Note the quotes around $options are essential!
options=""
prefix=""
verbose=""
while true ; do
case "$1" in
--prefix) prefix="$2" ; shift 2 ;;
-v|--verbose) verbose="yes" ; shift 1 ;;
--) shift ; break ;;
*) echo "Internal error!" ; exit 1 ;;
esac
done
if [ -n "$1" ] ; then ## extra arguments
printUsage
exit 1
fi
if [ -z "$prefix" ] ; then ## prefix is empty (not been set)
prefix=/usr/local
for p in /usr/local /usr ; do
if [ -d $p/share/$pkgName ] ; then
prefix=$p
break
fi
done
else
n=${#prefix}
if [ ${prefix:n-1:1} = / ] ; then
prefix=${prefix::-1}
fi
fi
shareDir="${prefix}/share"
if [ -z $pkgName ] ; then ## do not f*** the system if pkgName was empty amiss!
echo "Internal Error! pkgName=''"
exit 1
fi
##================== Starting to remove files =====================
if [ -n "$verbose" ] ; then ## no output (note that quotation around $verbose is needed)
RM="rm -Rfv"
else
RM="rm -Rf"
fi
if [ -d "${shareDir}/$pkgName" ] ; then
$RM "${shareDir}/$pkgName"
fi
if [ -d "${shareDir}/doc/$pkgName" ] ; then
$RM "${shareDir}/doc/$pkgName"
fi
## what about the /etc/$pkgName and /var/log/$pkgName ## FIXME
$RM /etc/init.d/*${pkgName}d* /etc/rc.d/*${pkgName}d* 2>/dev/null ## FIXME
$RM $shareDir/$pkgName/icons/hicolor/*/apps/$pkgName.png 2>/dev/null
$RM $prefix/bin/$pkgName $prefix/bin/$pkgName-qt 2>/dev/null
$RM $shareDir/applications/$pkgName.desktop 2>/dev/null
$RM $prefix/share/locale/*/LC_MESSAGES/$pkgName.mo 2>/dev/null