forked from Ximi1970/systray-x
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_linux_kde_installers.sh
executable file
·572 lines (465 loc) · 12.7 KB
/
create_linux_kde_installers.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
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
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
#!/bin/bash
VERSION=`git describe --long | sed "s/-.*//"`
OBS_REPO_BASE="https://download.opensuse.org/repositories/home:/Ximi1970:/Mozilla:/Add-ons"
TARGET_DIR="bin"
OBS_PACKAGE="systray-x"
ENABLE_RPM=true
ENABLE_DEB=true
ENABLE_PAC=true
OBS_RPM_ARCHS=""
OBS_RPM_PKS=""
OBS_RPM_ARCHS+="openSUSE_Leap_15.4/x86_64 "
OBS_RPM_PKS+="_ "
OBS_RPM_ARCHS+="openSUSE_Tumbleweed/i586 "
OBS_RPM_PKS+="tmblwd "
OBS_RPM_ARCHS+="openSUSE_Tumbleweed/x86_64 "
OBS_RPM_PKS+="tmblwd "
OBS_RPM_ARCHS+="15.4/x86_64 "
OBS_RPM_PKS+="lp154 "
OBS_RPM_ARCHS+="15.5/x86_64 "
OBS_RPM_PKS+="lp155 "
OBS_RPM_ARCHS+="Fedora_37/x86_64 "
OBS_RPM_PKS+="fed37 "
OBS_RPM_ARCHS+="Fedora_38/x86_64 "
OBS_RPM_PKS+="fed38 "
OBS_RPM_ARCHS+="Fedora_39/x86_64 "
OBS_RPM_PKS+="fed39 "
OBS_RPM_ARCHS+="Fedora_Rawhide/x86_64 "
OBS_RPM_PKS+="fedraw "
OBS_DEB_ARCHS=""
OBS_DEB_PKS=""
OBS_DEB_ARCHS+="Debian_10/i386 "
OBS_DEB_PKS+="deb10 "
OBS_DEB_ARCHS+="Debian_10/amd64 "
OBS_DEB_PKS+="deb10 "
OBS_DEB_ARCHS+="Debian_11/i386 "
OBS_DEB_PKS+="deb11 "
OBS_DEB_ARCHS+="Debian_11/amd64 "
OBS_DEB_PKS+="deb11 "
OBS_DEB_ARCHS+="Debian_12/i386 "
OBS_DEB_PKS+="deb12 "
OBS_DEB_ARCHS+="Debian_12/amd64 "
OBS_DEB_PKS+="deb12 "
OBS_DEB_ARCHS+="Debian_Unstable/amd64 "
OBS_DEB_PKS+="debunstable "
OBS_DEB_ARCHS+="Debian_Testing/amd64 "
OBS_DEB_PKS+="debtest "
OBS_DEB_ARCHS+="xUbuntu_18.04/i386 "
OBS_DEB_PKS+="bionic1804 "
OBS_DEB_ARCHS+="xUbuntu_18.04/amd64 "
OBS_DEB_PKS+="bionic1804 "
OBS_DEB_ARCHS+="xUbuntu_20.04/amd64 "
OBS_DEB_PKS+="focal2004 "
OBS_DEB_ARCHS+="xUbuntu_22.04/amd64 "
OBS_DEB_PKS+="jammy2022 "
OBS_DEB_ARCHS+="xUbuntu_23.04/amd64 "
OBS_DEB_PKS+="lunar2023 "
OBS_DEB_ARCHS+="xUbuntu_23.10/amd64 "
OBS_DEB_PKS+="mantic2023 "
OBS_PAC_ARCHS=""
OBS_PAC_PKS=""
OBS_PAC_ARCHS+="Arch/x86_64 "
OBS_PAC_PKS+="arch "
create_rpm_tar() {
local REPO_BASE=$1
local REPO_DISTR=$2
local REPO_ARCH=$3
local RPM_NAME_EXT=$4
##########################################
#
# Create the SysTray-X tar
#
##########################################
#
# Get index.html
#
rm -f index.html
wget -q "${REPO_BASE}/${REPO_DISTR}/${REPO_ARCH}/"
#
# Find rpm
#
local RPM_FILE=$(grep ">${OBS_PACKAGE}-${VERSION}.*rpm<" index.html | sed -e "s/.*>\(${OBS_PACKAGE}.*rpm\)<.*/\1/")
rm -f index.html
echo "Found: "${RPM_FILE}
FOUND_VERSION=$(echo ${RPM_FILE} | sed -e "s/${OBS_PACKAGE}-\(.*\)-.*/\1/")
echo "Version: "${FOUND_VERSION}
#
# Create tar dir
#
local TAR_DIR=SysTray-X-${FOUND_VERSION}-${REPO_DISTR}
rm -rf ${TAR_DIR}
mkdir -p ${TAR_DIR}
#
# Get the SysTray-X rpm
#
if [ ! -f ${RPM_FILE} ] ; then
wget -q "${REPO_BASE}/${REPO_DISTR}/${REPO_ARCH}/${RPM_FILE}"
fi
#
# Get compression type
#
COMPRESSION=$(rpm -qp --qf '%{PAYLOADCOMPRESSOR}\n' ${RPM_FILE})
# echo ${COMPRESSION}
case ${COMPRESSION} in
# zstd)
#
# Extract
#
# rpm2cpio ${RPM_FILE} | zstd -d | cpio --quiet -idm
#
# Get files
#
# cp -f ./usr/bin/SysTray-X ./${TAR_DIR}/SysTray-X
# chmod 755 ./${TAR_DIR}/SysTray-X
# cp -f ./usr/share/doc/${OBS_PACKAGE}/[email protected] ./${TAR_DIR}/[email protected]
# ;;
*)
#
# Extract
#
rpm2cpio ${RPM_FILE} | cpio --quiet -idm
#
# Get files
#
cp -f ./usr/bin/SysTray-X ./${TAR_DIR}/SysTray-X
chmod 755 ./${TAR_DIR}/SysTray-X
if [ -d ./usr/share/doc/packages ] ; then
cp -f ./usr/share/doc/packages/${OBS_PACKAGE}/[email protected] ./${TAR_DIR}/[email protected]
else
if [ -d ./usr/share/doc/${OBS_PACKAGE} ] ; then
cp -f ./usr/share/doc/${OBS_PACKAGE}/[email protected] ./${TAR_DIR}/[email protected]
else
cp -f ./usr/share/doc/${OBS_PACKAGE}*/[email protected] ./${TAR_DIR}/[email protected]
fi
fi
;;
esac
#
# Cleanup
#
rm -rf ./usr
if [ ! -f [email protected] ] ; then
cp -f ./${TAR_DIR}/[email protected] .
fi
#
# Get JSON
#
cp -f ../app/config/linux/SysTray_X.json.template ./${TAR_DIR}/SysTray_X.json.template
#
# Create tar
#
tar -C ./${TAR_DIR} -cJf ${TAR_DIR}.tar.xz .
#
# Rename the RPM
#
if [ "${RPM_NAME_EXT}" != "_" ] ; then
NEW_RPM_FILE=`echo ${RPM_FILE} | sed -s "s/\(${OBS_PACKAGE}-${FOUND_VERSION}-\)\(.*\)/\1${RPM_NAME_EXT}\.\2/"`
mv -f ${RPM_FILE} $NEW_RPM_FILE
fi
#
# Cleanup
#
rm -rf ${TAR_DIR}
}
create_deb_tar() {
local REPO_BASE=$1
local REPO_DISTR=$2
local REPO_ARCH=$3
local DEB_NAME_EXT=$4
##########################################
#
# Create the SysTray-X tar
#
##########################################
#
# Get index.html
#
rm -f index.html
wget -q "${REPO_BASE}/${REPO_DISTR}/${REPO_ARCH}/"
#
# Find deb
#
local DEB_FILE=$(grep ">${OBS_PACKAGE}_${VERSION}.*\.deb<" index.html | sed -e "s/.*>\(${OBS_PACKAGE}.*deb\)<.*/\1/")
rm -f index.html
echo "Found: "${DEB_FILE}
FOUND_VERSION=$(echo ${DEB_FILE} | sed -e "s/${OBS_PACKAGE}_\(.*\)_.*/\1/")
echo "Version: "${FOUND_VERSION}
#
# Create tar dir
#
local TAR_DIR=SysTray-X-${FOUND_VERSION}-${REPO_DISTR}
rm -rf ${TAR_DIR}
mkdir -p ${TAR_DIR}
#
# Get the SysTray-X deb
#
if [ ! -f ${DEB_FILE} ] ; then
wget -q "${REPO_BASE}/${REPO_DISTR}/${REPO_ARCH}/${DEB_FILE}"
fi
#
# Extract
#
dpkg-deb --fsys-tarfile ${DEB_FILE} | tar xOf - ./usr/bin/SysTray-X > ./${TAR_DIR}/SysTray-X
chmod 755 ./${TAR_DIR}/SysTray-X
dpkg-deb --fsys-tarfile ${DEB_FILE} | tar xOf - ./usr/lib/thunderbird-addons/extensions/[email protected] > ./${TAR_DIR}/[email protected]
if [ ! -f [email protected] ] ; then
cp -f ./${TAR_DIR}/[email protected] .
fi
#
# Get JSON
#
cp -f ../app/config/linux/SysTray_X.json.template ./${TAR_DIR}/SysTray_X.json.template
#
# Create tar
#
tar -C ./${TAR_DIR} -cJf ${TAR_DIR}.tar.xz .
#
# Rename the DEB
#
if [ "${DEB_NAME_EXT}" != "_" ] ; then
NEW_DEB_FILE=`echo ${DEB_FILE} | sed -s "s/\(${OBS_PACKAGE}\_${FOUND_VERSION}\_\)\(.*\)/\1${DEB_NAME_EXT}\_\2/"`
mv -f ${DEB_FILE} ${NEW_DEB_FILE}
fi
#
# Cleanup
#
rm -rf ${TAR_DIR}
}
create_pac_tar() {
local REPO_BASE=$1
local REPO_DISTR=$2
local REPO_ARCH=$3
local PAC_NAME_EXT=$4
##########################################
#
# Create the SysTray-X tar
#
##########################################
#
# Get index.html
#
rm -f index.html
curl -s "${REPO_BASE}/${REPO_DISTR}/${REPO_ARCH}/" > index.html
#
# Find rpm
#
local PAC_FILE=$(grep ">${OBS_PACKAGE}-[^dgm].*${VERSION}.*\.zst<" index.html | sed -e "s/.*>\(${OBS_PACKAGE}-[^d].*zst\)<.*/\1/")
rm -f index.html
echo "Found: "${PAC_FILE}
FOUND_VERSION=$(echo ${PAC_FILE} | sed -e "s/${OBS_PACKAGE}-\(.*\)-.*/\1/")
echo "Version: "${FOUND_VERSION}
#
# Create tar dir
#
local TAR_DIR=SysTray-X-${FOUND_VERSION}-${REPO_DISTR}
rm -rf ${TAR_DIR}
mkdir -p ${TAR_DIR}
#
# Get the SysTray-X rpm
#
if [ ! -f ${PAC_FILE} ] ; then
wget -q "${REPO_BASE}/${REPO_DISTR}/${REPO_ARCH}/${PAC_FILE}"
fi
if [ ! -f systray-x.tar.zst ] ; then
cp -f ${PAC_FILE} systray-x.tar.zst
fi
tar -I zstd -xf systray-x.tar.zst
rm -f systray-x.tar.zst
rm -f .BUILDINFO
rm -f .INSTALL
rm -f .MTREE
rm -f .PKGINFO
#
# Get files
#
cp -f ./usr/bin/SysTray-X ./${TAR_DIR}/SysTray-X
chmod 755 ./${TAR_DIR}/SysTray-X
cp -f ./usr/lib/thunderbird/distribution/extensions/[email protected] ./${TAR_DIR}/[email protected]
#
# Cleanup
#
rm -rf ./usr
if [ ! -f [email protected] ] ; then
cp -f ./${TAR_DIR}/[email protected] .
fi
#
# Get JSON
#
cp -f ../app/config/linux/SysTray_X.json.template ./${TAR_DIR}/SysTray_X.json.template
#
# Create tar
#
# tar -C "./${TAR_DIR}" -cJf "${TAR_DIR}.tar.xz" .
tar -C "./${TAR_DIR}" -cJf systray-x.tar.xz .
mv -f systray-x.tar.xz ${TAR_DIR}.tar.xz
#
# Rename the PAC
#
if [ "${PAC_NAME_EXT}" != "_" ] ; then
NEW_PAC_FILE=`echo ${PAC_FILE} | sed -s "s/\(${OBS_PACKAGE}-${FOUND_VERSION}-\)\(.*\)/\1${PAC_NAME_EXT}\.\2/"`
mv -f "${PAC_FILE}" "$NEW_PAC_FILE"
fi
#
# Cleanup
#
rm -rf "${TAR_DIR}"
}
#################################################################################
#
#
# Main
#
#
#################################################################################
mkdir -p $TARGET_DIR
pushd $TARGET_DIR > /dev/null 2>&1
if [ "$ENABLE_RPM" = true ] ; then
#
# Create bash installers for RPM based distributions
#
INDEX=1
for rpmdir in $OBS_RPM_ARCHS ; do
echo
echo
echo "Generating installer: "${rpmdir}
echo
#
# Get base of the repo
#
REPO_DISTR=$(echo ${rpmdir} | cut -d'/' -f1)
REPO_ARCH=$(echo ${rpmdir} | cut -d'/' -f2)
RPM_NAME_EXT=$(echo ${OBS_RPM_PKS} | cut -d' ' -f${INDEX})
#
# Generate the SysTray-X tar file
#
create_rpm_tar ${OBS_REPO_BASE} ${REPO_DISTR} ${REPO_ARCH} ${RPM_NAME_EXT}
#
# Create installer
#
INSTALLER=SysTray-X-${FOUND_VERSION}-${REPO_DISTR}-${REPO_ARCH}-KDE-install.sh
cp -f ../dist/install.sh ${INSTALLER}
#
# Insert Kde setup
#
sed -i -e "/__XXXX_SETUP__/r../dist/install.${REPO_DISTR}-Kde.sh" ${INSTALLER}
sed -i -e "s/__GNOME_INSTALLER__/SysTray-X-${FOUND_VERSION}-${REPO_DISTR}-${REPO_ARCH}-GNOME-install.sh/" ${INSTALLER}
sed -i -e "s/__MINIMAL_INSTALLER__/SysTray-X-${FOUND_VERSION}-${REPO_DISTR}-${REPO_ARCH}-Minimal-install.sh/" ${INSTALLER}
sed -i -e "s/__XXXX_SETUP__//" ${INSTALLER}
#
# Insert install tar
#
cat SysTray-X-${FOUND_VERSION}-${REPO_DISTR}.tar.xz >> ${INSTALLER}
chmod 755 ${INSTALLER}
#
# Cleanup
#
rm -f SysTray-X-${FOUND_VERSION}-${REPO_DISTR}.tar.xz
#
# Update index
#
INDEX=$((INDEX+1))
done
fi
if [ "$ENABLE_DEB" = true ] ; then
#
# Cleanup
#
rm -f gnome-shell-extension.tar.xz
#
# Create bash installers for DEB based distributions
#
INDEX=1
for debdir in $OBS_DEB_ARCHS ; do
echo
echo
echo "Generating installer: "${debdir}
echo
#
# Get base of the repo
#
REPO_DISTR=$(echo ${debdir} | cut -d'/' -f1)
REPO_ARCH=$(echo ${debdir} | cut -d'/' -f2)
DEB_NAME_EXT=$(echo ${OBS_DEB_PKS} | cut -d' ' -f${INDEX})
#
# Generate the SysTray-X tar file
#
create_deb_tar ${OBS_REPO_BASE} ${REPO_DISTR} ${REPO_ARCH} ${DEB_NAME_EXT}
#
# Create installer
#
INSTALLER=SysTray-X-${FOUND_VERSION}-${REPO_DISTR}-${REPO_ARCH}-KDE-install.sh
cp -f ../dist/install.sh ${INSTALLER}
#
# Insert Kde setup
#
sed -i -e "/__XXXX_SETUP__/r../dist/install.${REPO_DISTR}-Kde.sh" ${INSTALLER}
sed -i -e "s/__GNOME_INSTALLER__/SysTray-X-${FOUND_VERSION}-${REPO_DISTR}-${REPO_ARCH}-GNOME-install.sh/" ${INSTALLER}
sed -i -e "s/__MINIMAL_INSTALLER__/SysTray-X-${FOUND_VERSION}-${REPO_DISTR}-${REPO_ARCH}-Minimal-install.sh/" ${INSTALLER}
sed -i -e "s/__XXXX_SETUP__//" ${INSTALLER}
#
# Insert install tar
#
cat SysTray-X-${FOUND_VERSION}-${REPO_DISTR}.tar.xz >> ${INSTALLER}
chmod 755 ${INSTALLER}
#
# Cleanup
#
rm -f SysTray-X-${FOUND_VERSION}-${REPO_DISTR}.tar.xz
#
# Update index
#
INDEX=$((INDEX+1))
done
fi
if [ "$ENABLE_PAC" = true ] ; then
#
# Create bash installers for PAC based distributions
#
INDEX=1
for pacdir in $OBS_PAC_ARCHS ; do
echo
echo
echo "Generating installer: "${pacdir}
echo
#
# Get base of the repo
#
REPO_DISTR=$(echo ${pacdir} | cut -d'/' -f1)
REPO_ARCH=$(echo ${pacdir} | cut -d'/' -f2)
PAC_NAME_EXT=$(echo ${OBS_PAC_PKS} | cut -d' ' -f${INDEX})
#
# Generate the SysTray-X tar file
#
create_pac_tar ${OBS_REPO_BASE} ${REPO_DISTR} ${REPO_ARCH} ${PAC_NAME_EXT}
#
# Create installer
#
INSTALLER=SysTray-X-${FOUND_VERSION}-${REPO_DISTR}-${REPO_ARCH}-KDE-install.sh
cp -f ../dist/install.sh ${INSTALLER}
#
# Insert Kde setup
#
sed -i -e "/__XXXX_SETUP__/r../dist/install.${REPO_DISTR}-Kde.sh" ${INSTALLER}
sed -i -e "s/__GNOME_INSTALLER__/SysTray-X-${FOUND_VERSION}-${REPO_DISTR}-${REPO_ARCH}-GNOME-install.sh/" ${INSTALLER}
sed -i -e "s/__MINIMAL_INSTALLER__/SysTray-X-${FOUND_VERSION}-${REPO_DISTR}-${REPO_ARCH}-Minimal-install.sh/" ${INSTALLER}
sed -i -e "s/__XXXX_SETUP__//" ${INSTALLER}
#
# Insert install tar
#
cat SysTray-X-${FOUND_VERSION}-${REPO_DISTR}.tar.xz >> ${INSTALLER}
chmod 755 ${INSTALLER}
#
# Cleanup
#
rm -f SysTray-X-${FOUND_VERSION}-${REPO_DISTR}.tar.xz
#
# Update index
#
INDEX=$((INDEX+1))
done
fi
#
# Cleanup
#
rm -f gnome-shell-extension-*.tar.xz
popd > /dev/null 2>&1