-
Notifications
You must be signed in to change notification settings - Fork 1
/
imgmerge
executable file
·344 lines (340 loc) · 13.3 KB
/
imgmerge
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
#!/usr/bin/sudo /bin/bash
basenames=$(wget -qO - https://appimage.github.io/apps | grep -Eo "<a href=\".*\">" | grep -v "github.com" | grep -v "twitter" | grep -v "opensuse" | grep -v "feed.xml" | cut -d "\"" -f2 | cut -d '/' -f2 | sed "/apps/d" | sed "/wishlist/d" | sed "/help/d" | sed "/^$/d" | tail -n+2)
#AppImage database directory
if [ ! -d /var/db/imgmerge ]; then
mkdir -p /var/db/imgmerge
fi
#AppImage install directory
if [ ! -d /Applications ]; then
mkdir /Applications
fi
if [ "$1" == "sync" ]; then
echo "Building AppImage database…"
for i in $basenames; do
wget -qO - https://appimage.github.io/$i | grep "button green" | cut -d "\"" -f2
done > /var/db/imgmerge/appimagelist
echo "Appending custom entries…"
for entry in $(cat /etc/imgmerge/fetch.conf); do
wget --show-progress $entry -qO ->> /var/db/imgmerge/appimagelist
done
elif [ "$1" == "search" ]; then
shift
pkgs="$(for i in $@; do grep "$i" /var/db/imgmerge/appimagelist; done)"
echo $pkgs
elif [ "$1" == "install" ]; then
shift
pkgs="$(for i in $@; do grep "$i" /var/db/imgmerge/appimagelist; done)"
if [ -z "$pkgs" ]; then
echo "Error: empty package list" && exit 137
else
for i in $pkgs; do
domain=$(echo $i | cut -d "/" -f3)
if [ "$domain" == "download.opensuse.org" ]; then
appimage=https://$domain$(wget -qO - $i | grep "mirrorbrain-btn" | cut -d\" -f2 )
elif [ "$domain" == "files.kde.org" ]; then
filename=$(wget -qO - $i | grep -Eo "href=\".*\.[Aa]pp[Ii]mage\"" | cut -d\" -f2 | sort -Vr | head -n1)
appimage=$i/$(echo $filename)
elif [ "$domain" == "libreoffice.soluzioniopen.com" ]; then
appimage=$i/LibreOffice-fresh.full-x86_64.AppImage
else
appimage=https://$domain$(wget -qO - $i | grep -v "\.com" | grep -v "\.org" | grep -Eo "/.*\.[Aa]pp[Ii]mage" | grep "$(uname -m)" | head -n1)
fi
if [[ "$i" == *"kdenlive"* ]]; then
wget -qO /Applications/$(echo $i | cut -d\/ -f4).AppImage --show-progress $appimage
chmod a+x /Applications/$(echo $i | cut -d\/ -f4).AppImage
cd /tmp
/Applications/$(echo $i | cut -d\/ -f4).AppImage --appimage-extract &>/dev/null
icons_static=$(find squashfs-root/usr/share/icons -iname "*.png" | cut -d\/ -f2-)
icons_scalable=$(find squashfs-root/usr/share/icons -iname "*.svg" | cut -d\/ -f2-)
desktop_files=$(find squashfs-root -iname "*.desktop" | cut -d\/ -f2-)
echo "Copying icons..."
for j in $icons_static; do
filebase=$(readlink squashfs-root/$j)
if [ -n "$filebase" ]; then
file="squashfs-root$filebase"
unlink $j
cp $file $j
icon_dir_static="/$(echo $j | rev | cut -d\/ -f2- | rev)"
if [ ! -d $icon_dir_static ]; then
mkdir -p $icon_dir_static
cp squashfs-root/$j /$j
else
cp squashfs-root/$j /$j
fi
else
icon_dir_static="/$(echo $j | rev | cut -d\/ -f2- | rev)"
if [ ! -d $icon_dir_static ]; then
mkdir -p $icon_dir_static
cp squashfs-root/$j /$j
else
cp squashfs-root/$j /$j
fi
fi
done
for k in $icons_scalable; do
filebase=$(readlink squashfs-root/$k)
if [ -n "$filebase" ]; then
file="squashfs-root$filebase"
unlink $k
cp $file $k
icon_dir_scalable="/$(echo $k | rev | cut -d\/ -f2- | rev)"
if [ ! -d $icon_dir_scalable ]; then
mkdir -p $icon_dir_scalable
cp squashfs-root/$k /$k
else
cp squashfs-root/$k /$k
fi
else
icon_dir_scalable="/$(echo $k | rev | cut -d\/ -f2- | rev)"
if [ ! -d $icon_dir_scalable ]; then
mkdir -p $icon_dir_scalable
cp squashfs-root/$k /$k
else
cp squashfs-root/$k /$k
fi
fi
done
echo "Reconfiguring icon themes..."
if [ ! -d /var/db/repos/gentoo ]; then
emerge --sync -q
fi
emerge -q kde-frameworks/breeze-icons
echo "Copying and configuring .desktop files..."
for l in $desktop_files; do
if [ -n "$(readlink $l)" ]; then
cp -f squashfs-root$(readlink $l) /$l
else
if [ ! -d $(echo /$l | rev | cut -d\/ -f2- | rev) ]; then
mkdir -p $(echo /$l | rev | cut -d\/ -f2- | rev)
fi
cp -rf squashfs-root/$l /$l
sed -i "s/Exec=.*/Exec=\/Applications\/$(echo $i | cut -d'/' -f4).AppImage/" /$l 2>/dev/null
fi
done
echo "Successfully installed $i"
elif [[ "$i" == *"libreoffice"* ]]; then
wget -qO /Applications/LibreOffice.AppImage --show-progress $appimage
chmod a+x /Applications/LibreOffice.AppImage
cd /tmp
/Applications/LibreOffice.AppImage --appimage-extract &>/dev/null
icons_static=$(find squashfs-root/usr/share/icons -iname "*.png" | cut -d\/ -f2-)
icons_scalable=$(find squashfs-root/usr/share/icons -iname "*.svg" | cut -d\/ -f2-)
desktop_files=$(find squashfs-root/usr/share/applications -iname "*.desktop" | cut -d\/ -f2-)
echo "Copying icons..."
for j in $icons_static; do
filebase=$(readlink squashfs-root/$j)
if [ -n "$filebase" ]; then
file="squashfs-root$filebase"
unlink $j
cp $file $j
icon_dir_static="/$(echo $j | rev | cut -d\/ -f2- | rev)"
if [ ! -d $icon_dir_static ]; then
mkdir -p $icon_dir_static
cp squashfs-root/$j /$j
else
cp squashfs-root/$j /$j
fi
else
icon_dir_static="/$(echo $j | rev | cut -d\/ -f2- | rev)"
if [ ! -d $icon_dir_static ]; then
mkdir -p $icon_dir_static
cp squashfs-root/$j /$j
else
cp squashfs-root/$j /$j
fi
fi
done
for k in $icons_scalable; do
filebase=$(readlink squashfs-root/$k)
if [ -n "$filebase" ]; then
file="squashfs-root$filebase"
unlink $k
cp $file $k
icon_dir_scalable="/$(echo $k | rev | cut -d\/ -f2- | rev)"
if [ ! -d $icon_dir_scalable ]; then
mkdir -p $icon_dir_scalable
cp squashfs-root/$k /$k
else
cp squashfs-root/$k /$k
fi
else
icon_dir_scalable="/$(echo $k | rev | cut -d\/ -f2- | rev)"
if [ ! -d $icon_dir_scalable ]; then
mkdir -p $icon_dir_scalable
cp squashfs-root/$k /$k
else
cp squashfs-root/$k /$k
fi
fi
done
echo "Reconfiguring icon themes..."
if [ ! -d /var/db/repos/gentoo ]; then
emerge --sync -q
fi
emerge -q kde-frameworks/breeze-icons
echo "Copying and configuring .desktop files..."
for l in $desktop_files; do
cp squashfs-root$(readlink squashfs-root/$l) /$l || cp squashfs-root/$l /$l 2>/dev/null
sed -i "s/Exec=.*/Exec=\/Applications\/LibreOffice.AppImage \-\-$(echo $l | cut -d\- -f2 | cut -d\. -f1)/" /$l
done
echo "Successfully installed $i"
else
wget -qO /Applications/$(echo $i | cut -d\/ -f5).AppImage --show-progress $appimage
chmod a+x /Applications/$(echo $i | cut -d\/ -f5).AppImage
cd /tmp
/Applications/$(echo $i | cut -d\/ -f5).AppImage --appimage-extract &>/dev/null
icons_static=$(find squashfs-root/usr/share/icons -iname "*.png" | cut -d\/ -f2-)
icons_scalable=$(find squashfs-root/usr/share/icons -iname "*.svg" | cut -d\/ -f2-)
desktop_files=$(find squashfs-root/usr/share/applications -iname "*.desktop" | cut -d\/ -f2-)
echo "Copying icons..."
for j in $icons_static; do
filebase=$(readlink squashfs-root/$j)
if [ -n "$filebase" ]; then
file="squashfs-root$filebase"
unlink $j
cp $file $j
icon_dir_static="/$(echo $j | rev | cut -d\/ -f2- | rev)"
if [ ! -d $icon_dir_static ]; then
mkdir -p $icon_dir_static
cp squashfs-root/$j /$j
else
cp squashfs-root/$j /$j
fi
else
icon_dir_static="/$(echo $j | rev | cut -d\/ -f2- | rev)"
if [ ! -d $icon_dir_static ]; then
mkdir -p $icon_dir_static
cp squashfs-root/$j /$j
else
cp squashfs-root/$j /$j
fi
fi
done
for k in $icons_scalable; do
filebase=$(readlink squashfs-root/$k)
if [ -n "$filebase" ]; then
file="squashfs-root$filebase"
unlink $k
cp $file $k
icon_dir_scalable="/$(echo $k | rev | cut -d\/ -f2- | rev)"
if [ ! -d $icon_dir_scalable ]; then
mkdir -p $icon_dir_scalable
cp squashfs-root/$k /$k
else
cp squashfs-root/$k /$k
fi
else
icon_dir_scalable="/$(echo $k | rev | cut -d\/ -f2- | rev)"
if [ ! -d $icon_dir_scalable ]; then
mkdir -p $icon_dir_scalable
cp squashfs-root/$k /$k
else
cp squashfs-root/$k /$k
fi
fi
done
echo "Reconfiguring icon themes..."
if [ ! -d /var/db/repos/gentoo ]; then
emerge --sync -q
fi
emerge -q kde-frameworks/breeze-icons
echo "Copying and configuring .desktop files..."
for l in $desktop_files; do
cp squashfs-root$(readlink squashfs-root/$l) /$l || cp squashfs-root/$l /$l 2>/dev/null
sed -i "s/Exec=.*/Exec=\/Applications\/$(echo $i | cut -d'/' -f5).AppImage/" /$l
done
echo "Successfully installed $i"
fi
done
rm -rf squashfs-root
fi
elif [ "$1" == "sideload" ]; then
shift
pkgs="$(for i in $@; do ls | grep $i.*\.[Aa]pp[Ii]mage; done)"
if [ -z "$pkgs" ]; then
echo "Error: empty package list" && exit 137
else
for i in $pkgs; do
appimage=$i
cp $appimage /Applications/$(echo $i | cut -d'-' -f1)
chmod a+x /Applications/$(echo $i | cut -d'-' -f1)
cd /tmp
/Applications/$(echo $i | cut -d'-' -f1).AppImage --appimage-extract &>/dev/null
icons_static=$(find -L squashfs-root/usr/share/icons -iname "*.png" | cut -d\/ -f2-)
icons_scalable=$(find -L squashfs-root/usr/share/icons -iname "*.svg" | cut -d\/ -f2-)
desktop_files=$(find -L squashfs-root/usr/share/applications -iname "*.desktop" | cut -d\/ -f2-)
echo "Copying icons..."
for j in $icons_static; do
filebase=$(readlink squashfs-root/$j)
if [ -n "$filebase" ]; then
file="squashfs-root$filebase"
unlink $j
cp $file $j
icon_dir_static="/$(echo $j | rev | cut -d\/ -f2- | rev)"
if [ ! -d $icon_dir_static ]; then
mkdir -p $icon_dir_static
cp squashfs-root/$j /$j
else
cp squashfs-root/$j /$j
fi
else
icon_dir_static="/$(echo $j | rev | cut -d\/ -f2- | rev)"
if [ ! -d $icon_dir_static ]; then
mkdir -p $icon_dir_static
cp squashfs-root/$j /$j
else
cp squashfs-root/$j /$j
fi
fi
done
for k in $icons_scalable; do
filebase=$(readlink squashfs-root/$k)
if [ -n "$filebase" ]; then
file="squashfs-root$filebase"
unlink $k
cp $file $k
icon_dir_scalable="/$(echo $k | rev | cut -d\/ -f2- | rev)"
if [ ! -d $icon_dir_scalable ]; then
mkdir -p $icon_dir_scalable
cp squashfs-root/$k /$k
else
cp squashfs-root/$k /$k
fi
else
icon_dir_scalable="/$(echo $k | rev | cut -d\/ -f2- | rev)"
if [ ! -d $icon_dir_scalable ]; then
mkdir -p $icon_dir_scalable
cp squashfs-root/$k /$k
else
cp squashfs-root/$k /$k
fi
fi
done
echo "Reconfiguring icon themes..."
if [ ! -d /var/db/repos/gentoo ]; then
emerge --sync -q
fi
emerge -q kde-frameworks/breeze-icons
echo "Copying and configuring .desktop files..."
for l in $desktop_files; do
cp squashfs-root$(readlink squashfs-root/$l) /$l || cp squashfs-root/$l /$l 2>/dev/null
sed -i "s/Exec=.*/Exec=\/Applications\/$(echo $i | cut -d'-' -f1).AppImage/" /$l
done
echo "Successfully installed $i"
done
rm -rf squashfs-root
fi
elif [ "$1" == "remove" ]; then
shift
for i in $(ls /Applications | grep $@); do
rm -f /Applications/$i
rm -f $(grep -r "\.AppImage" /usr/share/applications | cut -d ':' -f1 | grep "$i")
done
else
echo "Usage: imgmerge [sync|search|install <packagenames>|remove <packagenames>]"
echo " sync: Create database of AppImages to install"
echo " search: Search for an AppImage in the database"
echo " install <packagenames>: Install AppImages by name from the AppImageHub"
echo " sideload <packagenames>: Install AppImages by name from current working directory"
echo " remove <packagenames>: Delete AppImages"
fi