-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-as-symlink.sh
executable file
·137 lines (126 loc) · 3.35 KB
/
install-as-symlink.sh
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/bash
echo
. runinplace.rc
if [ $? -ne 0 ]; then
echo "Error: runinplace.rc didn't run successfully. You must run this script from the nopackage repo (the same directory as runinplace.rc)"
exit 1
fi
src_sc="nopackage/usr/share/applications/nopackage.desktop"
if [ ! -f "$src_sc" ]; then
echo "Error: \"$src_sc\" is missing. You must run this script from the nopackage repo (the same directory as runinplace.rc)"
exit 1
fi
if [ -z "$FORCE" ]; then
FORCE=false
fi
UNINSTALL=false
for arg in "$@"
do
if [ "@$arg" == "@--force" ]; then
FORCE=true
elif [ "@$arg" == "@--uninstall" ]; then
UNINSTALL=true
else
echo "Error: \"$arg\" is not a valid option."
exit 1
fi
done
verb="install"
redo_verb="reinstall"
if [ "@$UNINSTALL" = "@true" ]; then
verb="uninstall"
redo_verb="uninstall"
# elif [ ! -d "$dst_libs" ]; then
# mkdir -p "$dst_libs"
# if [ $? -ne 0 ]; then exit 1; fi
fi
if [ -d "$dst_lib" ]; then
# dst_lib is deprecated, so the logic here changed to cleanup only
# existing_src="`readlink $dst_lib`"
# if [ -z "$existing_src" ]; then
if [ ! -L "$dst_lib" ]; then
# ^ If we are really, really sure it isn't a symlink, then:
# if [ "@$FORCE" = "@true" ]; then
rm -Rf "$dst_lib"
if [ $? -ne 0 ]; then exit 1; fi
echo "* removed existing $dst_lib (real directory, not symlink)"
# else
# echo "Error: \"$dst_lib\" already exists and isn't a symlink. Use --force to delete the entire directory and $redo_verb."
# exit 1
# fi
elif [ -L "$dst_lib" ]; then
rm "$dst_lib"
fi
fi
# src_bin="$src_lib/__init__.py"
# src_bin=$src_exe
dst_bin="$PREFIX/bin/nopackage"
# existing_src_bin="`readlink $dst_bin`"
if [ -f "$dst_bin" ]; then
rm "$dst_bin"
fi
if [ "@$UNINSTALL" != "@true" ]; then
# if [ "$existing_src_bin" != "$src_bin" ]; then
printf "* installing $dst_bin..."
ln -s "$src_exe" "$dst_bin"
code=$?
if [ $code -eq 0 ]; then
echo "OK"
else
echo "FAILED (line $LINENO)"
exit $code
fi
# fi
fi
OLD_dst_sc="$PREFIX/share/applications/install_any.desktop"
if [ -f "$OLD_dst_sc" ]; then
rm "$OLD_dst_sc"
if [ $? -ne 0 ]; then exit 1; fi
echo "* removed deprecated $OLD_dst_sc"
fi
dst_sc="$PREFIX/share/applications/nopackage.desktop"
if [ "@$UNINSTALL" = "@true" ]; then
if [ -f "$dst_sc" ]; then
printf "* removing \"$dst_sc\"..."
rm "$dst_sc"
code=$?
if [ $code -eq 0 ]; then
echo "OK"
else
echo "FAILED (line $LINENO)"
exit $code
fi
else
echo "* \"$dst_sc\"...OK (already uninstalled)"
fi
echo
echo "Uninstall is complete."
echo
exit 0
else
printf "* copying \"$dst_sc\"..."
cp "$src_sc" "$dst_sc"
fi
code=$?
if [ $code -eq 0 ]; then
echo "OK"
else
echo "FAILED (line $LINENO)"
exit $code
fi
# echo "Path=$HOME/.local/lib/nopackage" >> "$dst_sc"
echo "Path=$src_repo" >> "$dst_sc"
# ^ for metadata
echo "Exec=$HOME/.local/bin/nopackage" >> "$dst_sc"
printf "* installing \"$dst_sc\"..."
xdg-desktop-icon install --novendor $dst_sc
code=$?
if [ $code -eq 0 ]; then
echo "OK"
else
echo "FAILED ($LINENO)"
exit $code
fi
echo
echo "Install is complete."
echo