-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
executable file
·173 lines (142 loc) · 5.25 KB
/
install
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#!/bin/sh
project_name=DeepFileFind
project_unix_name=deepfilefind
install_description="install $project_name"
install_method_tip="sudo ./install"
lib_root=/usr/local/lib
bin_root=/usr/local/bin
assembly_name=DeepFileFind.exe
icons_root=/usr/share/pixmaps
subicons_dest_dir=$icons_root/$project_unix_name
icon_name=deepfilefind.png
applications_root=/usr/share/applications
icon_dest_path=$icons_root/$icon_name
# see https://martin.hoppenheit.info/blog/2016/where-to-put-application-icons-on-linux/ :
#* A 32x32 px XPM file in /usr/share/pixmaps/.
#* A 48x48 px PNG file in /usr/share/icons/hicolor/48x48/apps/.
#* Optionally, an SVG file in /usr/share/icons/hicolor/scalable/apps/.
#Of course you also need a desktop file in /usr/share/applications/ for your program.
#And just in case, you can easily create XPM and PNG files from a source SVG file:
#inkscape -e icon.png -C -w 48 -h 48 icon.svg
#inkscape -e tmp.png -C -w 32 -h 32 icon.svg
#convert tmp.png icon.xpm
#rm tmp.png
cd $(dirname "$0")
src_assembly_dir=./bin
src_assembly_path=$src_assembly_dir/$assembly_name
if [ -d ./bin/Release/$assembly_name ]; then
src_assembly_dir=./bin/Release
src_assembly_path=$src_assembly_dir/$assembly_name
fi
src_bin_path=etc/$project_unix_name
dest_bin_path=$bin_root/$project_unix_name
echo
echo
mono_path=$(command -v mono)
if [ ! -f "$mono_path" ]; then
echo "ERROR: Nothing done for $install_description since mono must be installed for this program to run."
exit 1
fi
if [ ! -d etc ]; then
cd ..
fi
if [ ! -d etc ]; then
echo "ERROR: Nothing done for $install_description since couldn't find repo dir (this script must be in repo dir where etc exists or etc folder in repo dir)"
exit 2
fi
if [ ! -f "$src_bin_path" ]; then
echo "ERROR: Nothing done for $install_description since couldn't find $src_bin_path in etc"
exit 3
fi
if [ ! -f "$src_assembly_path" ]; then
echo "ERROR: Nothing done for $install_description since couldn't find $src_assembly_path"
echo "Build the program to that assembly first, such as using the sln file via MonoDevelop"
exit 4
fi
dest_lib_dir=$lib_root/$project_unix_name
this_lib_path=$dest_lib_dir/$assembly_name
if [ ! -d "$dest_lib_dir" ]; then
mkdir "$dest_lib_dir"
fi
if [ ! -d "$dest_lib_dir" ]; then
echo "ERROR: this script must be run as root or with '$install_method_tip' (could not create $dest_lib_dir)"
exit 5
fi
if [ -f "$this_lib_path" ]; then
echo "removing old $this_lib_path..."
rm "$this_lib_path"
fi
if [ -f "$this_lib_path" ]; then
echo "ERROR: this script must be run as root or with '$install_method_tip' (could not remove $this_lib_path)"
exit 6
fi
cp "$src_assembly_path" "$dest_lib_dir/"
if [ ! -f "$this_lib_path" ]; then
echo "ERROR: this script must be run as root or with '$install_method_tip' (could not create $this_lib_path)"
exit 7
fi
if [ ! -z "$subicons_dest_dir" ]; then
#if [ ! -d "$subicons_dest_dir" ]; then
# mkdir "$subicons_dest_dir"
#fi
#remove incorrectly placed main application icon:
if [ -d "$subicons_dest_dir" ]; then
if [ -f "$subicons_dest_dir/$icon_name" ]; then
echo "removing old icon in nonstandard location..."
rm "$subicons_dest_dir/$icon_name"
fi
rmdir "$subicons_dest_dir"
fi
#if [ ! -d "$subicons_dest_dir" ]; then
# echo "ERROR: this script must be run as root or with '$install_method_tip' (could not create $dest_lib_dir)"
# exit 8
#fi
fi
if [ -f "$icon_dest_path" ]; then
echo "Removing old $icon_dest_path..."
rm "$icon_dest_path"
fi
if [ -f "$icon_dest_path" ]; then
echo "ERROR: this script must be run as root or with '$install_method_tip' (could not remove old $icon_dest_path)"
exit 9
fi
#cp "$icon_name" "$icon_dest_path"
cp "./PACKAGE/$icon_dest_path" "$icon_dest_path"
if [ ! -f "$icon_dest_path" ]; then
echo "ERROR: this script must be run as root or with '$install_method_tip' (could not copy icon to new file $icon_dest_path)"
exit 10
fi
if [ -f "$dest_bin_path" ]; then
echo "removing old $dest_bin_path"
rm "$dest_bin_path"
fi
if [ -f "$dest_bin_path" ]; then
echo "ERROR: this script must be run as root or with '$install_method_tip' (could not remove $dest_bin_path)"
exit 11
fi
cp "$src_bin_path" "$bin_root/"
if [ ! -f "$dest_bin_path" ]; then
echo "ERROR: this script must be run as root or with '$install_method_tip' (could not create $dest_bin_path)"
exit 12
fi
if [ -f "$applications_root/$project_unix_name.desktop" ]; then
echo "removing old $applications_root/$project_unix_name.desktop..."
rm -f "$applications_root/$project_unix_name.desktop"
fi
if [ -f "$applications_root/$project_unix_name.desktop" ]; then
echo "ERROR: this script must be run as root or with '$install_method_tip' (could not remove old $applications_root/$project_unix_name.desktop)"
exit 13
fi
cp "./PACKAGE/$applications_root/$project_unix_name.desktop" "$applications_root/$project_unix_name.desktop"
if [ ! -f "$applications_root/$project_unix_name.desktop" ]; then
echo "ERROR: this script must be run as root or with '$install_method_tip' (could not create $applications_root/$project_unix_name.desktop)"
exit 13
fi
#else
chmod +x "$dest_bin_path"
echo "$install_description finished successfully."
echo "Run using shortcut or command below (made shortcut in $applications_root):"
echo " $project_unix_name"
#fi
echo
echo