Update the bundled version of makeself used to create static builds. (#14822)
* Update bundled makeself to v2.5.0. It includes numerous fixes that should resolve a number of the problems we’ve seen crop up recently with our static build installation process. * Update static archive metadata. * Add the makeself scripts to the shellcheck CI exclude list. They have numerous warnings, but we intentionally want to stay as close as possible to being in-sync with the upstream copies, so just ignore them with shellcheck in CI. * Silence shellcheck warnings. * Ensure required directories actually exist in static archive.
Austin S. Hemmelgarn committed
Apr 12, 2023 at 06:58 UTC
f269cdb88070feed23ab5999a119223e54120b8e
6 files changed
+557
-229
.github/workflows/review.yml
+4
-1
@@ -230,7 +230,10 @@ jobs:
230
reporter: github-pr-check
231
path: "."
232
pattern: "*.sh*"
233
- exclude: "./.git/*"
233
+ exclude: |
234
+ ./.git/*
235
+ packaging/makeself/makeself.sh
236
+ packaging/makeself/makeself-header.sh
237
238
yamllint:
239
name: yamllint
packaging/makeself/jobs/99-makeself.install.sh
+8
@@ -60,6 +60,14 @@ run rm "${NETDATA_INSTALL_PATH}/sbin" \
60
"${NETDATA_INSTALL_PATH}/usr/sbin" \
61
"${NETDATA_INSTALL_PATH}/usr/local"
62
63
+# -----------------------------------------------------------------------------
64
+# ensure required directories actually exist
65
+
66
+for dir in var/lib/netdata var/cache/netdata var/log/netdata ; do
67
+ run mkdir -p "${NETDATA_INSTALL_PATH}/${dir}"
68
+ run touch "${NETDATA_INSTALL_PATH}/${dir}/.keep"
69
+done
70
+
71
# -----------------------------------------------------------------------------
72
# create the makeself archive
73
packaging/makeself/makeself-header.sh
+215
-54
@@ -1,9 +1,10 @@
1
-# SPDX-License-Identifier: GPL-3.0-or-later
1
+# SPDX-License-Identifier: GPL-2.0-or-later
2
# shellcheck shell=sh
3
# shellcheck disable=SC2154,SC2039
4
cat << EOF > "$archname"
5
#!/bin/sh
6
# This script was generated using Makeself $MS_VERSION
7
+# The license covering this archive and its contents, if any, is wholly independent of the Makeself license (GPL)
8
9
ORIG_UMASK=\`umask\`
10
if test "$KEEP_UMASK" = n; then
@@ -12,22 +13,31 @@ fi
13
14
CRCsum="$CRCsum"
15
MD5="$MD5sum"
16
+SHA="$SHAsum"
17
+SIGNATURE="$Signature"
18
TMPROOT=\${TMPDIR:=/tmp}
16
-USER_PWD="\$PWD"; export USER_PWD
19
+USER_PWD="\$PWD"
20
+export USER_PWD
21
+ARCHIVE_DIR=\`dirname "\$0"\`
22
+export ARCHIVE_DIR
23
24
label="$LABEL"
25
script="$SCRIPT"
26
scriptargs="$SCRIPTARGS"
27
+cleanup_script="${CLEANUP_SCRIPT}"
28
licensetxt="$LICENSE"
22
-helpheader='$HELPHEADER'
29
+helpheader="${HELPHEADER}"
30
targetdir="$archdirname"
31
filesizes="$filesizes"
32
+totalsize="$totalsize"
33
keep="$KEEP"
34
nooverwrite="$NOOVERWRITE"
35
quiet="n"
36
accept="n"
37
nodiskspace="n"
38
export_conf="$EXPORT_CONF"
39
+decrypt_cmd="$DECRYPT_CMD"
40
+skip="$SKIP"
41
42
print_cmd_arg=""
43
if type printf > /dev/null; then
@@ -43,6 +53,11 @@ if test -d /usr/xpg4/bin; then
53
export PATH
54
fi
55
56
+if test -d /usr/sfw/bin; then
57
+ PATH=\$PATH:/usr/sfw/bin
58
+ export PATH
59
+fi
60
+
61
unset CDPATH
62
63
MS_Printf()
@@ -52,8 +67,14 @@ MS_Printf()
67
68
MS_PrintLicense()
69
{
70
+ PAGER=\${PAGER:=more}
71
if test x"\$licensetxt" != x; then
56
- echo "\$licensetxt"
72
+ PAGER_PATH=\`exec <&- 2>&-; which \$PAGER || command -v \$PAGER || type \$PAGER\`
73
+ if test -x "\$PAGER_PATH"; then
74
+ echo "\$licensetxt" | \$PAGER
75
+ else
76
+ echo "\$licensetxt"
77
+ fi
78
if test x"\$accept" != xy; then
79
while true
80
do
@@ -74,7 +95,7 @@ MS_PrintLicense()
95
MS_diskspace()
96
{
97
(
77
- df -kP "\$1" | tail -1 | awk '{ if (\$4 ~ /%/) {print \$3} else {print \$4} }'
98
+ df -k "\$1" | tail -1 | awk '{ if (\$4 ~ /%/) {print \$3} else {print \$4} }'
99
)
100
}
101
@@ -82,15 +103,20 @@ MS_dd()
103
{
104
blocks=\`expr \$3 / 1024\`
105
bytes=\`expr \$3 % 1024\`
85
- dd if="\$1" ibs=\$2 skip=1 obs=1024 conv=sync 2> /dev/null | \\
86
- { test \$blocks -gt 0 && dd ibs=1024 obs=1024 count=\$blocks ; \\
87
- test \$bytes -gt 0 && dd ibs=1 obs=1024 count=\$bytes ; } 2> /dev/null
106
+ # Test for ibs, obs and conv feature
107
+ if dd if=/dev/zero of=/dev/null count=1 ibs=512 obs=512 conv=sync 2> /dev/null; then
108
+ dd if="\$1" ibs=\$2 skip=1 obs=1024 conv=sync 2> /dev/null | \\
109
+ { test \$blocks -gt 0 && dd ibs=1024 obs=1024 count=\$blocks ; \\
110
+ test \$bytes -gt 0 && dd ibs=1 obs=1024 count=\$bytes ; } 2> /dev/null
111
+ else
112
+ dd if="\$1" bs=\$2 skip=1 2> /dev/null
113
+ fi
114
}
115
116
MS_dd_Progress()
117
{
118
if test x"\$noprogress" = xy; then
93
- MS_dd \$@
119
+ MS_dd "\$@"
120
return \$?
121
fi
122
file="\$1"
@@ -104,7 +130,7 @@ MS_dd_Progress()
130
blocks=\`expr \$length / \$bsize\`
131
bytes=\`expr \$length % \$bsize\`
132
(
107
- dd ibs=\$offset skip=1 2>/dev/null
133
+ dd ibs=\$offset skip=1 count=1 2>/dev/null
134
pos=\`expr \$pos \+ \$bsize\`
135
MS_Printf " 0%% " 1>&2
136
if test \$blocks -gt 0; then
@@ -134,34 +160,68 @@ MS_dd_Progress()
160
MS_Help()
161
{
162
cat << EOH >&2
137
-\${helpheader}Makeself version $MS_VERSION
163
+Makeself version $MS_VERSION
164
1) Getting help or info about \$0 :
165
\$0 --help Print this message
166
\$0 --info Print embedded info : title, default target directory, embedded script ...
167
\$0 --lsm Print embedded lsm entry (or no LSM)
168
\$0 --list Print the list of files in the archive
169
\$0 --check Checks integrity of the archive
170
+ \$0 --verify-sig key Verify signature agains a provided key id
171
172
2) Running \$0 :
173
\$0 [options] [--] [additional arguments to embedded script]
174
with following options (in that order)
175
--confirm Ask before running embedded script
149
- --quiet Do not print anything except error messages
176
+ --quiet Do not print anything except error messages
177
--accept Accept the license
151
- --noexec Do not run embedded script
178
+ --noexec Do not run embedded script (implies --noexec-cleanup)
179
+ --noexec-cleanup Do not run embedded cleanup script
180
--keep Do not erase target directory after running
153
- the embedded script
181
+ the embedded script
182
--noprogress Do not show the progress during the decompression
183
--nox11 Do not spawn an xterm
156
- --nochown Do not give the extracted files to the current user
184
+ --nochown Do not give the target folder to the current user
185
+ --chown Give the target folder to the current user recursively
186
--nodiskspace Do not check for available disk space
158
- --target dir Extract directly to a target directory
159
- directory path can be either absolute or relative
187
+ --target dir Extract directly to a target directory (absolute or relative)
188
+ This directory may undergo recursive chown (see --nochown).
189
--tar arg1 [arg2 ...] Access the contents of the archive through the tar command
161
- -- Following arguments will be passed to the embedded script
190
+ --ssl-pass-src src Use the given src as the source of password to decrypt the data
191
+ using OpenSSL. See "PASS PHRASE ARGUMENTS" in man openssl.
192
+ Default is to prompt the user to enter decryption password
193
+ on the current terminal.
194
+ --cleanup-args args Arguments to the cleanup script. Wrap in quotes to provide
195
+ multiple arguments.
196
+ -- Following arguments will be passed to the embedded script\${helpheader}
197
EOH
198
}
199
200
+MS_Verify_Sig()
201
+{
202
+ GPG_PATH=\`exec <&- 2>&-; which gpg || command -v gpg || type gpg\`
203
+ MKTEMP_PATH=\`exec <&- 2>&-; which mktemp || command -v mktemp || type mktemp\`
204
+ test -x "\$GPG_PATH" || GPG_PATH=\`exec <&- 2>&-; which gpg || command -v gpg || type gpg\`
205
+ test -x "\$MKTEMP_PATH" || MKTEMP_PATH=\`exec <&- 2>&-; which mktemp || command -v mktemp || type mktemp\`
206
+ offset=\`head -n "\$skip" "\$1" | wc -c | sed "s/ //g"\`
207
+ temp_sig=\`mktemp -t XXXXX\`
208
+ echo \$SIGNATURE | base64 --decode > "\$temp_sig"
209
+ gpg_output=\`MS_dd "\$1" \$offset \$totalsize | LC_ALL=C "\$GPG_PATH" --verify "\$temp_sig" - 2>&1\`
210
+ gpg_res=\$?
211
+ rm -f "\$temp_sig"
212
+ if test \$gpg_res -eq 0 && test \`echo \$gpg_output | grep -c Good\` -eq 1; then
213
+ if test \`echo \$gpg_output | grep -c \$sig_key\` -eq 1; then
214
+ test x"\$quiet" = xn && echo "GPG signature is good" >&2
215
+ else
216
+ echo "GPG Signature key does not match" >&2
217
+ exit 2
218
+ fi
219
+ else
220
+ test x"\$quiet" = xn && echo "GPG signature failed to verify" >&2
221
+ exit 2
222
+ fi
223
+}
224
+
225
MS_Check()
226
{
227
OLD_PATH="\$PATH"
@@ -169,18 +229,44 @@ MS_Check()
229
MD5_ARG=""
230
MD5_PATH=\`exec <&- 2>&-; which md5sum || command -v md5sum || type md5sum\`
231
test -x "\$MD5_PATH" || MD5_PATH=\`exec <&- 2>&-; which md5 || command -v md5 || type md5\`
172
- test -x "\$MD5_PATH" || MD5_PATH=\`exec <&- 2>&-; which digest || command -v digest || type digest\`
232
+ test -x "\$MD5_PATH" || MD5_PATH=\`exec <&- 2>&-; which digest || command -v digest || type digest\`
233
PATH="\$OLD_PATH"
234
235
+ SHA_PATH=\`exec <&- 2>&-; which shasum || command -v shasum || type shasum\`
236
+ test -x "\$SHA_PATH" || SHA_PATH=\`exec <&- 2>&-; which sha256sum || command -v sha256sum || type sha256sum\`
237
+
238
if test x"\$quiet" = xn; then
239
MS_Printf "Verifying archive integrity..."
240
fi
178
- offset=\`head -n $SKIP "\$1" | wc -c | tr -d " "\`
241
+ offset=\`head -n "\$skip" "\$1" | wc -c | sed "s/ //g"\`
242
+ fsize=\`cat "\$1" | wc -c | sed "s/ //g"\`
243
+ if test \$totalsize -ne \`expr \$fsize - \$offset\`; then
244
+ echo " Unexpected archive size." >&2
245
+ exit 2
246
+ fi
247
verb=\$2
248
i=1
249
for s in \$filesizes
250
do
251
crc=\`echo \$CRCsum | cut -d" " -f\$i\`
252
+ if test -x "\$SHA_PATH"; then
253
+ if test x"\`basename \$SHA_PATH\`" = xshasum; then
254
+ SHA_ARG="-a 256"
255
+ fi
256
+ sha=\`echo \$SHA | cut -d" " -f\$i\`
257
+ if test x"\$sha" = x0000000000000000000000000000000000000000000000000000000000000000; then
258
+ test x"\$verb" = xy && echo " \$1 does not contain an embedded SHA256 checksum." >&2
259
+ else
260
+ shasum=\`MS_dd_Progress "\$1" \$offset \$s | eval "\$SHA_PATH \$SHA_ARG" | cut -b-64\`;
261
+ if test x"\$shasum" != x"\$sha"; then
262
+ echo "Error in SHA256 checksums: \$shasum is different from \$sha" >&2
263
+ exit 2
264
+ elif test x"\$quiet" = xn; then
265
+ MS_Printf " SHA256 checksums are OK." >&2
266
+ fi
267
+ crc="0000000000";
268
+ fi
269
+ fi
270
if test -x "\$MD5_PATH"; then
271
if test x"\`basename \$MD5_PATH\`" = xdigest; then
272
MD5_ARG="-a md5"
@@ -193,8 +279,8 @@ MS_Check()
279
if test x"\$md5sum" != x"\$md5"; then
280
echo "Error in MD5 checksums: \$md5sum is different from \$md5" >&2
281
exit 2
196
- else
197
- test x"\$verb" = xy && MS_Printf " MD5 checksums are OK." >&2
282
+ elif test x"\$quiet" = xn; then
283
+ MS_Printf " MD5 checksums are OK." >&2
284
fi
285
crc="0000000000"; verb=n
286
fi
@@ -203,11 +289,11 @@ MS_Check()
289
test x"\$verb" = xy && echo " \$1 does not contain a CRC checksum." >&2
290
else
291
sum1=\`MS_dd_Progress "\$1" \$offset \$s | CMD_ENV=xpg4 cksum | awk '{print \$1}'\`
206
- if test x"\$sum1" = x"\$crc"; then
207
- test x"\$verb" = xy && MS_Printf " CRC checksums are OK." >&2
208
- else
292
+ if test x"\$sum1" != x"\$crc"; then
293
echo "Error in checksums: \$sum1 is different from \$crc" >&2
210
- exit 2;
294
+ exit 2
295
+ elif test x"\$quiet" = xn; then
296
+ MS_Printf " CRC checksums are OK." >&2
297
fi
298
fi
299
i=\`expr \$i + 1\`
@@ -218,22 +304,55 @@ MS_Check()
304
fi
305
}
306
307
+MS_Decompress()
308
+{
309
+ if test x"\$decrypt_cmd" != x""; then
310
+ { eval "\$decrypt_cmd" || echo " ... Decryption failed." >&2; } | eval "$GUNZIP_CMD"
311
+ else
312
+ eval "$GUNZIP_CMD"
313
+ fi
314
+
315
+ if test \$? -ne 0; then
316
+ echo " ... Decompression failed." >&2
317
+ fi
318
+}
319
+
320
UnTAR()
321
{
322
if test x"\$quiet" = xn; then
224
- tar \$1vf - $UNTAR_EXTRA 2>&1 || { echo " ... Extraction failed." > /dev/tty; kill -15 \$$; }
323
+ tar \$1vf - $UNTAR_EXTRA 2>&1 || { echo " ... Extraction failed." >&2; kill -15 \$$; }
324
else
226
- tar \$1f - $UNTAR_EXTRA 2>&1 || { echo Extraction failed. > /dev/tty; kill -15 \$$; }
325
+ tar \$1f - $UNTAR_EXTRA 2>&1 || { echo Extraction failed. >&2; kill -15 \$$; }
326
+ fi
327
+}
328
+
329
+MS_exec_cleanup() {
330
+ if test x"\$cleanup" = xy && test x"\$cleanup_script" != x""; then
331
+ cleanup=n
332
+ cd "\$tmpdir"
333
+ eval "\"\$cleanup_script\" \$scriptargs \$cleanupargs"
334
fi
335
}
336
337
+MS_cleanup()
338
+{
339
+ echo 'Signal caught, cleaning up' >&2
340
+ MS_exec_cleanup
341
+ cd "\$TMPROOT"
342
+ rm -rf "\$tmpdir"
343
+ eval \$finish; exit 15
344
+}
345
+
346
finish=true
347
xterm_loop=
348
noprogress=$NOPROGRESS
349
nox11=$NOX11
350
copy=$COPY
235
-ownership=y
351
+ownership=$OWNERSHIP
352
verbose=n
353
+cleanup=y
354
+cleanupargs=
355
+sig_key=
356
357
initargs="\$@"
358
@@ -258,8 +377,11 @@ do
377
echo Target directory: "\$targetdir"
378
echo Uncompressed size: $USIZE KB
379
echo Compression: $COMPRESS
380
+ if test x"$ENCRYPT" != x""; then
381
+ echo Encryption: $ENCRYPT
382
+ fi
383
echo Date of packaging: $DATE
262
- echo Built with Makeself version $MS_VERSION on $OSTYPE
384
+ echo Built with Makeself version $MS_VERSION
385
echo Build command was: "$MS_COMMAND"
386
if test x"\$script" != x; then
387
echo Script run after extraction:
@@ -282,15 +404,17 @@ do
404
echo LABEL=\"\$label\"
405
echo SCRIPT=\"\$script\"
406
echo SCRIPTARGS=\"\$scriptargs\"
407
+ echo CLEANUPSCRIPT=\"\$cleanup_script\"
408
echo archdirname=\"$archdirname\"
409
echo KEEP=$KEEP
410
echo NOOVERWRITE=$NOOVERWRITE
411
echo COMPRESS=$COMPRESS
412
echo filesizes=\"\$filesizes\"
413
+ echo totalsize=\"\$totalsize\"
414
echo CRCsum=\"\$CRCsum\"
291
- echo MD5sum=\"\$MD5\"
292
- echo OLDUSIZE=$USIZE
293
- echo OLDSKIP=$((SKIP + 1))
415
+ echo MD5sum=\"\$MD5sum\"
416
+ echo SHAsum=\"\$SHAsum\"
417
+ echo SKIP=\"\$skip\"
418
exit 0
419
;;
420
--lsm)
@@ -303,21 +427,21 @@ EOLSM
427
;;
428
--list)
429
echo Target directory: \$targetdir
306
- offset=\`head -n $SKIP "\$0" | wc -c | tr -d " "\`
430
+ offset=\`head -n "\$skip" "\$0" | wc -c | sed "s/ //g"\`
431
for s in \$filesizes
432
do
309
- MS_dd "\$0" \$offset \$s | eval "$GUNZIP_CMD" | UnTAR t
433
+ MS_dd "\$0" \$offset \$s | MS_Decompress | UnTAR t
434
offset=\`expr \$offset + \$s\`
435
done
436
exit 0
437
;;
438
--tar)
315
- offset=\`head -n $SKIP "\$0" | wc -c | tr -d " "\`
439
+ offset=\`head -n "\$skip" "\$0" | wc -c | sed "s/ //g"\`
440
arg1="\$2"
317
- if ! shift 2; then MS_Help; exit 1; fi
441
+ shift 2 || { MS_Help; exit 1; }
442
for s in \$filesizes
443
do
320
- MS_dd "\$0" \$offset \$s | eval "$GUNZIP_CMD" | tar "\$arg1" - "\$@"
444
+ MS_dd "\$0" \$offset \$s | MS_Decompress | tar "\$arg1" - "\$@"
445
offset=\`expr \$offset + \$s\`
446
done
447
exit 0
@@ -326,22 +450,32 @@ EOLSM
450
MS_Check "\$0" y
451
exit 0
452
;;
453
+ --verify-sig)
454
+ sig_key="\$2"
455
+ shift 2 || { MS_Help; exit 1; }
456
+ MS_Verify_Sig "\$0"
457
+ ;;
458
--confirm)
459
verbose=y
460
shift
461
;;
462
--noexec)
463
script=""
464
+ cleanup_script=""
465
shift
466
;;
467
+ --noexec-cleanup)
468
+ cleanup_script=""
469
+ shift
470
+ ;;
471
--keep)
472
keep=y
473
shift
474
;;
475
--target)
476
keep=y
343
- targetdir=\${2:-.}
344
- if ! shift 2; then MS_Help; exit 1; fi
477
+ targetdir="\${2:-.}"
478
+ shift 2 || { MS_Help; exit 1; }
479
;;
480
--noprogress)
481
noprogress=y
@@ -355,6 +489,10 @@ EOLSM
489
ownership=n
490
shift
491
;;
492
+ --chown)
493
+ ownership=y
494
+ shift
495
+ ;;
496
--nodiskspace)
497
nodiskspace=y
498
shift
@@ -370,6 +508,18 @@ EOLSM
508
copy=phase2
509
shift
510
;;
511
+ --ssl-pass-src)
512
+ if test x"$ENCRYPT" != x"openssl"; then
513
+ echo "Invalid option --ssl-pass-src: \$0 was not encrypted with OpenSSL!" >&2
514
+ exit 1
515
+ fi
516
+ decrypt_cmd="\$decrypt_cmd -pass \$2"
517
+ shift 2 || { MS_Help; exit 1; }
518
+ ;;
519
+ --cleanup-args)
520
+ cleanupargs="\$2"
521
+ shift 2 || { MS_Help; exit 1; }
522
+ ;;
523
--)
524
shift
525
break ;;
@@ -390,7 +540,7 @@ fi
540
541
if test x"$NEED_ROOT" = xy -a \`id -u\` -ne 0; then
542
echo "Administrative privileges required for this archive (use su or sudo)" >&2
393
- exit 1
543
+ exit 1
544
fi
545
546
if test x"\$copy" \!= xphase2; then
@@ -399,7 +549,7 @@ fi
549
550
case "\$copy" in
551
copy)
402
- tmpdir=\$TMPROOT/makeself.\$RANDOM.\`date +"%y%m%d%H%M%S"\`.\$\$
552
+ tmpdir="\$TMPROOT"/makeself.\$RANDOM.\`date +"%y%m%d%H%M%S"\`.\$\$
553
mkdir "\$tmpdir" || {
554
echo "Could not create temporary directory \$tmpdir" >&2
555
exit 1
@@ -409,6 +559,7 @@ copy)
559
cp "\$0" "\$SCRIPT_COPY"
560
chmod +x "\$SCRIPT_COPY"
561
cd "\$TMPROOT"
562
+ export USER_PWD="\$tmpdir"
563
exec "\$SCRIPT_COPY" --phase2 -- \$initargs
564
;;
565
phase2)
@@ -417,7 +568,7 @@ phase2)
568
esac
569
570
if test x"\$nox11" = xn; then
420
- if tty -s; then # Do we have a terminal?
571
+ if test -t 1; then # Do we have a terminal on stdout?
572
:
573
else
574
if test x"\$DISPLAY" != x -a x"\$xterm_loop" = x; then # No, but do we have X?
@@ -429,11 +580,11 @@ if test x"\$nox11" = xn; then
580
break
581
fi
582
done
432
- chmod a+x \$0 || echo Please add execution rights on \$0
583
+ chmod a+x \$0 || echo Please add execution rights on \$0 >&2
584
if test \`echo "\$0" | cut -c1\` = "/"; then # Spawn a terminal!
434
- exec \$XTERM -title "\$label" -e "\$0" --xwin "\$initargs"
585
+ exec \$XTERM -e "\$0 --xwin \$initargs"
586
else
436
- exec \$XTERM -title "\$label" -e "./\$0" --xwin "\$initargs"
587
+ exec \$XTERM -e "./\$0 --xwin \$initargs"
588
fi
589
fi
590
fi
@@ -457,7 +608,7 @@ else
608
tmpdir="\$TMPROOT/selfgz\$\$\$RANDOM"
609
dashp=""
610
fi
460
- mkdir \$dashp \$tmpdir || {
611
+ mkdir \$dashp "\$tmpdir" || {
612
echo 'Cannot create target directory' \$tmpdir >&2
613
echo 'You should try option --target dir' >&2
614
eval \$finish
@@ -469,7 +620,7 @@ location="\`pwd\`"
620
if test x"\$SETUP_NOCHECK" != x1; then
621
MS_Check "\$0"
622
fi
472
-offset=\`head -n $SKIP "\$0" | wc -c | tr -d " "\`
623
+offset=\`head -n "\$skip" "\$0" | wc -c | sed "s/ //g"\`
624
625
if test x"\$verbose" = xy; then
626
MS_Printf "About to extract $USIZE KB in \$tmpdir ... Proceed ? [Y/n] "
@@ -480,15 +631,21 @@ if test x"\$verbose" = xy; then
631
fi
632
633
if test x"\$quiet" = xn; then
483
- MS_Printf "Uncompressing \$label"
634
+ # Decrypting with openssl will ask for password,
635
+ # the prompt needs to start on new line
636
+ if test x"$ENCRYPT" = x"openssl"; then
637
+ echo "Decrypting and uncompressing \$label..."
638
+ else
639
+ MS_Printf "Uncompressing \$label"
640
+ fi
641
fi
642
res=3
643
if test x"\$keep" = xn; then
487
- trap 'echo Signal caught, cleaning up >&2; cd \$TMPROOT; /bin/rm -rf \$tmpdir; eval \$finish; exit 15' 1 2 3 15
644
+ trap MS_cleanup 1 2 3 15
645
fi
646
647
if test x"\$nodiskspace" = xn; then
491
- leftspace=\`MS_diskspace \$tmpdir\`
648
+ leftspace=\`MS_diskspace "\$tmpdir"\`
649
if test -n "\$leftspace"; then
650
if test "\$leftspace" -lt $USIZE; then
651
echo
@@ -504,7 +661,7 @@ fi
661
662
for s in \$filesizes
663
do
507
- if MS_dd_Progress "\$0" \$offset \$s | eval "$GUNZIP_CMD" | ( cd "\$tmpdir"; umask \$ORIG_UMASK ; UnTAR xp ) 1>/dev/null; then
664
+ if MS_dd_Progress "\$0" \$offset \$s | MS_Decompress | ( cd "\$tmpdir"; umask \$ORIG_UMASK ; UnTAR xp ) 1>/dev/null; then
665
if test x"\$ownership" = xy; then
666
(cd "\$tmpdir"; chown -R \`id -u\` .; chgrp -R \`id -g\` .)
667
fi
@@ -531,6 +688,7 @@ if test x"\$script" != x; then
688
MS_KEEP="\$KEEP"
689
MS_NOOVERWRITE="\$NOOVERWRITE"
690
MS_COMPRESS="\$COMPRESS"
691
+ MS_CLEANUP="\$cleanup"
692
export MS_BUNDLE MS_LABEL MS_SCRIPT MS_SCRIPTARGS
693
export MS_ARCHDIRNAME MS_KEEP MS_NOOVERWRITE MS_COMPRESS
694
fi
@@ -548,9 +706,12 @@ if test x"\$script" != x; then
706
test x"\$verbose" = xy && echo "The program '\$script' returned an error code (\$res)" >&2
707
fi
708
fi
709
+
710
+MS_exec_cleanup
711
+
712
if test x"\$keep" = xn; then
552
- cd \$TMPROOT
553
- /bin/rm -rf \$tmpdir
713
+ cd "\$TMPROOT"
714
+ rm -rf "\$tmpdir"
715
fi
716
eval \$finish; exit \$res
717
EOF
packaging/makeself/makeself-license.txt
+5
-8
@@ -4,7 +4,7 @@
4
| '-' '-' '-' '-' real-time performance monitoring, done right!
5
+----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+--->
6
7
- (C) Copyright 2017, Costa Tsaousis
7
+ (C) Copyright 2017-2023, Costa Tsaousis
8
All rights reserved
9
Released under GPL v3+
10
@@ -24,13 +24,10 @@
24
- /etc/logrotate.d/netdata
25
26
# SYSTEM INIT
27
- This file will be installed if this system runs with systemd:
28
-
29
- - /lib/systemd/system/netdata.service
30
-
31
- or, for older CentOS, Debian/Ubuntu or OpenRC Gentoo:
32
-
33
- - /etc/init.d/netdata will be created
27
+ If a supported init system is detected, appropriate configuration will be
28
+ installed to allow Netdata to run as a system service. We currently support
29
+ systemd, OpenRC, LSB init scripts, and traditional init.d setups, as well as
30
+ having experimental support for runit.
31
32
33
This package can also update a netdata installation that has been
packaging/makeself/makeself.lsm
+1
-1
@@ -10,7 +10,7 @@ Description: netdata is a system for distributed real-time performance and he
10
Keywords: real-time performance and health monitoring
11
Author: Costa Tsaousis (costa@tsaousis.gr)
12
Maintained-by: Costa Tsaousis (costa@tsaousis.gr)
13
-Original-site: https://my-netdata.io/
13
+Original-site: https://netdata.cloud/
14
Platform: Unix
15
Copying-policy: GPL
16
End
packaging/makeself/makeself.sh
+324
-165
@@ -1,85 +1,31 @@
1
#!/bin/sh
2
-# SPDX-License-Identifier: GPL-3.0-or-later
2
#
4
-# Makeself version 2.3.x
3
+# SPDX-License-Identifier: GPL-2.0-or-later
4
+#
5
+# shellcheck disable=SC2209,SC2006,SC2016,SC2034,SC2086,SC2003,SC2268,SC1090,SC2002,SC2046
6
+#
7
+# Makeself version 2.5.x
8
# by Stephane Peter <megastep@megastep.org>
9
#
10
# Utility to create self-extracting tar.gz archives.
11
# The resulting archive is a file holding the tar.gz archive with
12
# a small Shell script stub that uncompresses the archive to a temporary
10
-# directory and then executes a given script from within that directory.
11
-#
12
-# Makeself home page: http://makeself.io/
13
+# directory and then executes a given script from withing that directory.
14
#
14
-# Version 2.0 is a rewrite of version 1.0 to make the code easier to read and maintain.
15
+# Makeself home page: https://makeself.io/ - Version history available on GitHub
16
#
16
-# Version history :
17
-# - 1.0 : Initial public release
18
-# - 1.1 : The archive can be passed parameters that will be passed on to
19
-# the embedded script, thanks to John C. Quillan
20
-# - 1.2 : Package distribution, bzip2 compression, more command line options,
21
-# support for non-temporary archives. Ideas thanks to Francois Petitjean
22
-# - 1.3 : More patches from Bjarni R. Einarsson and Francois Petitjean:
23
-# Support for no compression (--nocomp), script is no longer mandatory,
24
-# automatic launch in an xterm, optional verbose output, and -target
25
-# archive option to indicate where to extract the files.
26
-# - 1.4 : Improved UNIX compatibility (Francois Petitjean)
27
-# Automatic integrity checking, support of LSM files (Francois Petitjean)
28
-# - 1.5 : Many bugfixes. Optionally disable xterm spawning.
29
-# - 1.5.1 : More bugfixes, added archive options -list and -check.
30
-# - 1.5.2 : Cosmetic changes to inform the user of what's going on with big
31
-# archives (Quake III demo)
32
-# - 1.5.3 : Check for validity of the DISPLAY variable before launching an xterm.
33
-# More verbosity in xterms and check for embedded command's return value.
34
-# Bugfix for Debian 2.0 systems that have a different "print" command.
35
-# - 1.5.4 : Many bugfixes. Print out a message if the extraction failed.
36
-# - 1.5.5 : More bugfixes. Added support for SETUP_NOCHECK environment variable to
37
-# bypass checksum verification of archives.
38
-# - 1.6.0 : Compute MD5 checksums with the md5sum command (patch from Ryan Gordon)
39
-# - 2.0 : Brand new rewrite, cleaner architecture, separated header and UNIX ports.
40
-# - 2.0.1 : Added --copy
41
-# - 2.1.0 : Allow multiple tarballs to be stored in one archive, and incremental updates.
42
-# Added --nochown for archives
43
-# Stopped doing redundant checksums when not necessary
44
-# - 2.1.1 : Work around insane behavior from certain Linux distros with no 'uncompress' command
45
-# Cleaned up the code to handle error codes from compress. Simplified the extraction code.
46
-# - 2.1.2 : Some bug fixes. Use head -n to avoid problems.
47
-# - 2.1.3 : Bug fixes with command line when spawning terminals.
48
-# Added --tar for archives, allowing to give arbitrary arguments to tar on the contents of the archive.
49
-# Added --noexec to prevent execution of embedded scripts.
50
-# Added --nomd5 and --nocrc to avoid creating checksums in archives.
51
-# Added command used to create the archive in --info output.
52
-# Run the embedded script through eval.
53
-# - 2.1.4 : Fixed --info output.
54
-# Generate random directory name when extracting files to . to avoid problems. (Jason Trent)
55
-# Better handling of errors with wrong permissions for the directory containing the files. (Jason Trent)
56
-# Avoid some race conditions (Ludwig Nussel)
57
-# Unset the $CDPATH variable to avoid problems if it is set. (Debian)
58
-# Better handling of dot files in the archive directory.
59
-# - 2.1.5 : Made the md5sum detection consistent with the header code.
60
-# Check for the presence of the archive directory
61
-# Added --encrypt for symmetric encryption through gpg (Eric Windisch)
62
-# Added support for the digest command on Solaris 10 for MD5 checksums
63
-# Check for available disk space before extracting to the target directory (Andreas Schweitzer)
64
-# Allow extraction to run asynchronously (patch by Peter Hatch)
65
-# Use file descriptors internally to avoid error messages (patch by Kay Tiong Khoo)
66
-# - 2.1.6 : Replaced one dot per file progress with a realtime progress percentage and a spinning cursor (Guy Baconniere)
67
-# Added --noprogress to prevent showing the progress during the decompression (Guy Baconniere)
68
-# Added --target dir to allow extracting directly to a target directory (Guy Baconniere)
69
-# - 2.2.0 : Many bugfixes, updates and contributions from users. Check out the project page on Github for the details.
70
-# - 2.3.0 : Option to specify packaging date to enable byte-for-byte reproducibility. (Marc Pawlowsky)
71
-#
72
-# (C) 1998-2017 by Stephane Peter <megastep@megastep.org>
17
+# (C) 1998-2023 by Stephane Peter <megastep@megastep.org>
18
#
19
# This software is released under the terms of the GNU GPL version 2 and above
20
# Please read the license at http://www.gnu.org/copyleft/gpl.html
21
+# Self-extracting archives created with this script are explictly NOT released under the term of the GPL
22
#
23
78
-MS_VERSION=2.3.1
24
+MS_VERSION=2.5.0
25
MS_COMMAND="$0"
26
unset CDPATH
27
82
-for f in "${1+"$@"}"; do
28
+for f in ${1+"$@"}; do
29
MS_COMMAND="$MS_COMMAND \\\\
30
\\\"$f\\\""
31
done
@@ -94,30 +40,46 @@ fi
40
41
MS_Usage()
42
{
97
- echo "Usage: $0 [params] archive_dir file_name label startup_script [args]"
98
- echo "params can be one or more of the following :"
43
+ echo "Usage: $0 [args] archive_dir file_name label startup_script [script_args]"
44
+ echo "args can be one or more of the following :"
45
echo " --version | -v : Print out Makeself version number and exit"
46
echo " --help | -h : Print out this help message"
47
echo " --tar-quietly : Suppress verbose output from the tar command"
48
echo " --quiet | -q : Do not print any messages other than errors."
49
echo " --gzip : Compress using gzip (default if detected)"
50
echo " --pigz : Compress with pigz"
51
+ echo " --zstd : Compress with zstd"
52
echo " --bzip2 : Compress using bzip2 instead of gzip"
53
echo " --pbzip2 : Compress using pbzip2 instead of gzip"
54
+ echo " --bzip3 : Compress using bzip3 instead of gzip"
55
echo " --xz : Compress using xz instead of gzip"
56
echo " --lzo : Compress using lzop instead of gzip"
57
echo " --lz4 : Compress using lz4 instead of gzip"
58
echo " --compress : Compress using the UNIX 'compress' command"
111
- echo " --complevel lvl : Compression level for gzip pigz xz lzo lz4 bzip2 and pbzip2 (default 9)"
59
+ echo " --complevel lvl : Compression level for gzip pigz zstd xz lzo lz4 bzip2 pbzip2 and bzip3 (default 9)"
60
+ echo " --threads thds : Number of threads to be used by compressors that support parallelization."
61
+ echo " Omit to use compressor's default. Most useful (and required) for opting"
62
+ echo " into xz's threading, usually with '--threads=0' for all available cores."
63
+ echo " pbzip2 and pigz are parallel by default, and setting this value allows"
64
+ echo " limiting the number of threads they use."
65
echo " --base64 : Instead of compressing, encode the data using base64"
66
echo " --gpg-encrypt : Instead of compressing, encrypt the data using GPG"
67
echo " --gpg-asymmetric-encrypt-sign"
68
echo " : Instead of compressing, asymmetrically encrypt and sign the data using GPG"
69
echo " --gpg-extra opt : Append more options to the gpg command line"
70
echo " --ssl-encrypt : Instead of compressing, encrypt the data using OpenSSL"
71
+ echo " --ssl-passwd pass : Use the given password to encrypt the data using OpenSSL"
72
+ echo " --ssl-pass-src src : Use the given src as the source of password to encrypt the data"
73
+ echo " using OpenSSL. See \"PASS PHRASE ARGUMENTS\" in man openssl."
74
+ echo " If this option is not supplied, the user will be asked to enter"
75
+ echo " encryption password on the current terminal."
76
+ echo " --ssl-no-md : Do not use \"-md\" option not supported by older OpenSSL."
77
+ echo " --nochown : Do not give the target folder to the current user (default)"
78
+ echo " --chown : Give the target folder to the current user recursively"
79
echo " --nocomp : Do not compress the data"
119
- echo " --notemp : The archive will create archive_dir in the"
120
- echo " current directory and uncompress in ./archive_dir"
80
+ echo " --notemp : The archive will create archive_dir in the current directory"
81
+ echo " and uncompress in ./archive_dir"
82
+ echo " Note: persistent archives do not strictly require a startup_script"
83
echo " --needroot : Check that the root user is extracting the archive before proceeding"
84
echo " --copy : Upon extraction, the archive will first copy itself to"
85
echo " a temporary directory"
@@ -125,19 +87,23 @@ MS_Usage()
87
echo " The label and startup scripts will then be ignored"
88
echo " --target dir : Extract directly to a target directory"
89
echo " directory path can be either absolute or relative"
128
- echo " --nooverwrite : Do not extract the archive if the specified target directory exists"
90
echo " --current : Files will be extracted to the current directory"
130
- echo " Both --current and --target imply --notemp"
91
+ echo " Both --current and --target imply --notemp, and do not require a startup_script"
92
+ echo " --nooverwrite : Do not extract the archive if the specified target directory exists"
93
+ echo " --tar-format opt : Specify a tar archive format (default is ustar)"
94
echo " --tar-extra opt : Append more options to the tar command line"
95
echo " --untar-extra opt : Append more options to the during the extraction of the tar archive"
96
echo " --nomd5 : Don't calculate an MD5 for archive"
97
echo " --nocrc : Don't calculate a CRC for archive"
98
+ echo " --sha256 : Compute a SHA256 checksum for the archive"
99
echo " --header file : Specify location of the header script"
100
+ echo " --cleanup file : Specify a cleanup script that executes on interrupt and when finished successfully."
101
echo " --follow : Follow the symlinks in the archive"
102
echo " --noprogress : Do not show the progress during the decompression"
103
echo " --nox11 : Disable automatic spawn of a xterm"
104
echo " --nowait : Do not wait for user input after executing embedded"
105
echo " program from an xterm"
106
+ echo " --sign passphrase : Signature private key to sign the package with"
107
echo " --lsm file : LSM file describing the package"
108
echo " --license file : Append a license file"
109
echo " --help-header file : Add a header to the archive's --help output"
@@ -154,12 +120,21 @@ MS_Usage()
120
}
121
122
# Default settings
157
-if type gzip 2>&1 > /dev/null; then
123
+if type gzip >/dev/null 2>&1; then
124
COMPRESS=gzip
125
+elif type compress >/dev/null 2>&1; then
126
+ COMPRESS=compress
127
else
160
- COMPRESS=Unix
128
+ echo "ERROR: missing commands: gzip, compress" >&2
129
+ MS_Usage
130
fi
131
+ENCRYPT=n
132
+PASSWD=""
133
+PASSWD_SRC=""
134
+OPENSSL_NO_MD=n
135
COMPRESS_LEVEL=9
136
+DEFAULT_THREADS=123456 # Sentinel value
137
+THREADS=$DEFAULT_THREADS
138
KEEP=n
139
CURRENT=n
140
NOX11=n
@@ -171,15 +146,21 @@ QUIET=n
146
NOPROGRESS=n
147
COPY=none
148
NEED_ROOT=n
174
-TAR_ARGS=cvf
149
+TAR_ARGS=rvf
150
+TAR_FORMAT=ustar
151
TAR_EXTRA=""
152
GPG_EXTRA=""
153
DU_ARGS=-ks
154
HEADER=`dirname "$0"`/makeself-header.sh
155
+SIGNATURE=""
156
TARGETDIR=""
157
NOOVERWRITE=n
158
DATE=`LC_ALL=C date`
159
EXPORT_CONF=n
160
+SHA256=n
161
+OWNERSHIP=n
162
+SIGN=n
163
+GPG_PASSPHRASE=""
164
165
# LSM file stuff
166
LSM_CMD="echo No LSM. >> \"\$archname\""
@@ -195,6 +176,10 @@ do
176
COMPRESS=pbzip2
177
shift
178
;;
179
+ --bzip3)
180
+ COMPRESS=bzip3
181
+ shift
182
+ ;;
183
--bzip2)
184
COMPRESS=bzip2
185
shift
@@ -204,9 +189,13 @@ do
189
shift
190
;;
191
--pigz)
207
- COMPRESS=pigz
208
- shift
209
- ;;
192
+ COMPRESS=pigz
193
+ shift
194
+ ;;
195
+ --zstd)
196
+ COMPRESS=zstd
197
+ shift
198
+ ;;
199
--xz)
200
COMPRESS=xz
201
shift
@@ -220,7 +209,7 @@ do
209
shift
210
;;
211
--compress)
223
- COMPRESS=Unix
212
+ COMPRESS=compress
213
shift
214
;;
215
--base64)
@@ -232,24 +221,48 @@ do
221
shift
222
;;
223
--gpg-asymmetric-encrypt-sign)
235
- COMPRESS=gpg-asymmetric
236
- shift
237
- ;;
224
+ COMPRESS=gpg-asymmetric
225
+ shift
226
+ ;;
227
--gpg-extra)
239
- GPG_EXTRA="$2"
240
- if ! shift 2; then MS_Help; exit 1; fi
241
- ;;
228
+ GPG_EXTRA="$2"
229
+ shift 2 || { MS_Usage; exit 1; }
230
+ ;;
231
--ssl-encrypt)
243
- COMPRESS=openssl
244
- shift
245
- ;;
232
+ ENCRYPT=openssl
233
+ shift
234
+ ;;
235
+ --ssl-passwd)
236
+ PASSWD=$2
237
+ shift 2 || { MS_Usage; exit 1; }
238
+ ;;
239
+ --ssl-pass-src)
240
+ PASSWD_SRC=$2
241
+ shift 2 || { MS_Usage; exit 1; }
242
+ ;;
243
+ --ssl-no-md)
244
+ OPENSSL_NO_MD=y
245
+ shift
246
+ ;;
247
--nocomp)
248
COMPRESS=none
249
shift
250
;;
251
--complevel)
252
COMPRESS_LEVEL="$2"
252
- if ! shift 2; then MS_Help; exit 1; fi
253
+ shift 2 || { MS_Usage; exit 1; }
254
+ ;;
255
+ --threads)
256
+ THREADS="$2"
257
+ shift 2 || { MS_Usage; exit 1; }
258
+ ;;
259
+ --nochown)
260
+ OWNERSHIP=n
261
+ shift
262
+ ;;
263
+ --chown)
264
+ OWNERSHIP=y
265
+ shift
266
;;
267
--notemp)
268
KEEP=y
@@ -264,19 +277,28 @@ do
277
KEEP=y
278
shift
279
;;
280
+ --tar-format)
281
+ TAR_FORMAT="$2"
282
+ shift 2 || { MS_Usage; exit 1; }
283
+ ;;
284
--tar-extra)
268
- TAR_EXTRA="$2"
269
- if ! shift 2; then MS_Help; exit 1; fi
270
- ;;
285
+ TAR_EXTRA="$2"
286
+ shift 2 || { MS_Usage; exit 1; }
287
+ ;;
288
--untar-extra)
289
UNTAR_EXTRA="$2"
273
- if ! shift 2; then MS_Help; exit 1; fi
290
+ shift 2 || { MS_Usage; exit 1; }
291
;;
292
--target)
276
- TARGETDIR="$2"
277
- KEEP=y
278
- if ! shift 2; then MS_Help; exit 1; fi
279
- ;;
293
+ TARGETDIR="$2"
294
+ KEEP=y
295
+ shift 2 || { MS_Usage; exit 1; }
296
+ ;;
297
+ --sign)
298
+ SIGN=y
299
+ GPG_PASSPHRASE="$2"
300
+ shift 2 || { MS_Usage; exit 1; }
301
+ ;;
302
--nooverwrite)
303
NOOVERWRITE=y
304
shift
@@ -287,14 +309,19 @@ do
309
;;
310
--header)
311
HEADER="$2"
290
- if ! shift 2; then MS_Help; exit 1; fi
312
+ shift 2 || { MS_Usage; exit 1; }
313
;;
314
+ --cleanup)
315
+ CLEANUP_SCRIPT="$2"
316
+ shift 2 || { MS_Usage; exit 1; }
317
+ ;;
318
--license)
293
- LICENSE=`cat $2`
294
- if ! shift 2; then MS_Help; exit 1; fi
319
+ # We need to escape all characters having a special meaning in double quotes
320
+ LICENSE=$(sed 's/\\/\\\\/g; s/"/\\\"/g; s/`/\\\`/g; s/\$/\\\$/g' "$2")
321
+ shift 2 || { MS_Usage; exit 1; }
322
;;
323
--follow)
297
- TAR_ARGS=cvhf
324
+ TAR_ARGS=rvhf
325
DU_ARGS=-ksL
326
shift
327
;;
@@ -314,6 +341,10 @@ do
341
NOMD5=y
342
shift
343
;;
344
+ --sha256)
345
+ SHA256=y
346
+ shift
347
+ ;;
348
--nocrc)
349
NOCRC=y
350
shift
@@ -323,16 +354,16 @@ do
354
shift
355
;;
356
--lsm)
326
- LSM_CMD="cat \"$2\" >> \"\$archname\""
327
- if ! shift 2; then MS_Help; exit 1; fi
357
+ LSM_CMD="awk 1 \"$2\" >> \"\$archname\""
358
+ shift 2 || { MS_Usage; exit 1; }
359
;;
360
--packaging-date)
361
DATE="$2"
331
- if ! shift 2; then MS_Help; exit 1; fi
362
+ shift 2 || { MS_Usage; exit 1; }
363
;;
364
--help-header)
365
HELPHEADER=`sed -e "s/'/'\\\\\''/g" $2`
335
- if ! shift 2; then MS_Help; exit 1; fi
366
+ shift 2 || { MS_Usage; exit 1; }
367
[ -n "$HELPHEADER" ] && HELPHEADER="$HELPHEADER
368
"
369
;;
@@ -378,43 +409,44 @@ fi
409
archname="$2"
410
411
if test "$QUIET" = "y" || test "$TAR_QUIETLY" = "y"; then
381
- if test "$TAR_ARGS" = "cvf"; then
382
- TAR_ARGS="cf"
383
- elif test "$TAR_ARGS" = "cvhf";then
384
- TAR_ARGS="chf"
412
+ if test "$TAR_ARGS" = "rvf"; then
413
+ TAR_ARGS="rf"
414
+ elif test "$TAR_ARGS" = "rvhf"; then
415
+ TAR_ARGS="rhf"
416
fi
417
fi
418
419
if test "$APPEND" = y; then
420
if test $# -lt 2; then
390
- MS_Usage
421
+ MS_Usage
422
fi
423
424
# Gather the info from the original archive
425
OLDENV=`sh "$archname" --dumpconf`
426
if test $? -ne 0; then
396
- echo "Unable to update archive: $archname" >&2
397
- exit 1
427
+ echo "Unable to update archive: $archname" >&2
428
+ exit 1
429
else
399
- eval "$OLDENV"
430
+ eval "$OLDENV"
431
+ OLDSKIP=`expr $SKIP + 1`
432
fi
433
else
434
if test "$KEEP" = n -a $# = 3; then
403
- echo "ERROR: Making a temporary archive with no embedded command does not make sense!" >&2
404
- echo >&2
405
- MS_Usage
435
+ echo "ERROR: Making a temporary archive with no embedded command does not make sense!" >&2
436
+ echo >&2
437
+ MS_Usage
438
fi
439
# We don't want to create an absolute directory unless a target directory is defined
440
if test "$CURRENT" = y; then
409
- archdirname="."
410
- elif test x$TARGETDIR != x; then
411
- archdirname="$TARGETDIR"
441
+ archdirname="."
442
+ elif test x"$TARGETDIR" != x; then
443
+ archdirname="$TARGETDIR"
444
else
413
- archdirname=`basename "$1"`
445
+ archdirname=`basename "$1"`
446
fi
447
448
if test $# -lt 3; then
417
- MS_Usage
449
+ MS_Usage
450
fi
451
452
LABEL="$3"
@@ -434,20 +466,47 @@ gzip)
466
GZIP_CMD="gzip -c$COMPRESS_LEVEL"
467
GUNZIP_CMD="gzip -cd"
468
;;
437
-pigz)
469
+pigz)
470
GZIP_CMD="pigz -$COMPRESS_LEVEL"
471
+ if test $THREADS -ne $DEFAULT_THREADS; then # Leave as the default if threads not indicated
472
+ GZIP_CMD="$GZIP_CMD --processes $THREADS"
473
+ fi
474
GUNZIP_CMD="gzip -cd"
475
;;
476
+zstd)
477
+ GZIP_CMD="zstd -$COMPRESS_LEVEL"
478
+ if test $THREADS -ne $DEFAULT_THREADS; then # Leave as the default if threads not indicated
479
+ GZIP_CMD="$GZIP_CMD --threads=$THREADS"
480
+ fi
481
+ GUNZIP_CMD="zstd -cd"
482
+ ;;
483
pbzip2)
484
GZIP_CMD="pbzip2 -c$COMPRESS_LEVEL"
485
+ if test $THREADS -ne $DEFAULT_THREADS; then # Leave as the default if threads not indicated
486
+ GZIP_CMD="$GZIP_CMD -p$THREADS"
487
+ fi
488
GUNZIP_CMD="bzip2 -d"
489
;;
490
+bzip3)
491
+ # Map the compression level to a block size in MiB as 2^(level-1).
492
+ BZ3_COMPRESS_LEVEL=`echo "2^($COMPRESS_LEVEL-1)" | bc`
493
+ GZIP_CMD="bzip3 -b$BZ3_COMPRESS_LEVEL"
494
+ if test $THREADS -ne $DEFAULT_THREADS; then # Leave as the default if threads not indicated
495
+ GZIP_CMD="$GZIP_CMD -j$THREADS"
496
+ fi
497
+ JOBS=`echo "10-$COMPRESS_LEVEL" | bc`
498
+ GUNZIP_CMD="bzip3 -dj$JOBS"
499
+ ;;
500
bzip2)
501
GZIP_CMD="bzip2 -$COMPRESS_LEVEL"
502
GUNZIP_CMD="bzip2 -d"
503
;;
504
xz)
505
GZIP_CMD="xz -c$COMPRESS_LEVEL"
506
+ # Must opt-in by specifying a value since not all versions of xz support threads
507
+ if test $THREADS -ne $DEFAULT_THREADS; then
508
+ GZIP_CMD="$GZIP_CMD --threads=$THREADS"
509
+ fi
510
GUNZIP_CMD="xz -d"
511
;;
512
lzo)
@@ -460,23 +519,21 @@ lz4)
519
;;
520
base64)
521
GZIP_CMD="base64"
463
- GUNZIP_CMD="base64 -d -i"
522
+ GUNZIP_CMD="base64 --decode -i -"
523
;;
524
gpg)
525
GZIP_CMD="gpg $GPG_EXTRA -ac -z$COMPRESS_LEVEL"
526
GUNZIP_CMD="gpg -d"
527
+ ENCRYPT="gpg"
528
;;
529
gpg-asymmetric)
530
GZIP_CMD="gpg $GPG_EXTRA -z$COMPRESS_LEVEL -es"
531
GUNZIP_CMD="gpg --yes -d"
532
+ ENCRYPT="gpg"
533
;;
473
-openssl)
474
- GZIP_CMD="openssl aes-256-cbc -a -salt -md sha256"
475
- GUNZIP_CMD="openssl aes-256-cbc -d -a -md sha256"
476
- ;;
477
-Unix)
478
- GZIP_CMD="compress -cf"
479
- GUNZIP_CMD="exec 2>&-; uncompress -c || test \\\$? -eq 2 || gzip -cd"
534
+compress)
535
+ GZIP_CMD="compress -fc"
536
+ GUNZIP_CMD="(type compress >/dev/null 2>&1 && compress -fcd || gzip -cd)"
537
;;
538
none)
539
GZIP_CMD="cat"
@@ -484,29 +541,48 @@ none)
541
;;
542
esac
543
487
-tmpfile="${TMPDIR:=/tmp}/mkself$$"
544
+if test x"$ENCRYPT" = x"openssl"; then
545
+ if test x"$APPEND" = x"y"; then
546
+ echo "Appending to existing archive is not compatible with OpenSSL encryption." >&2
547
+ fi
548
+
549
+ ENCRYPT_CMD="openssl enc -aes-256-cbc -salt"
550
+ DECRYPT_CMD="openssl enc -aes-256-cbc -d"
551
+
552
+ if test x"$OPENSSL_NO_MD" != x"y"; then
553
+ ENCRYPT_CMD="$ENCRYPT_CMD -md sha256"
554
+ DECRYPT_CMD="$DECRYPT_CMD -md sha256"
555
+ fi
556
+
557
+ if test -n "$PASSWD_SRC"; then
558
+ ENCRYPT_CMD="$ENCRYPT_CMD -pass $PASSWD_SRC"
559
+ elif test -n "$PASSWD"; then
560
+ ENCRYPT_CMD="$ENCRYPT_CMD -pass pass:$PASSWD"
561
+ fi
562
+fi
563
+
564
+tmpfile="${TMPDIR:-/tmp}/mkself$$"
565
566
if test -f "$HEADER"; then
567
oldarchname="$archname"
568
archname="$tmpfile"
569
# Generate a fake header to count its lines
570
SKIP=0
494
- . "$HEADER"
495
- SKIP=`cat "$tmpfile" |wc -l`
571
+ . "$HEADER"
572
+ SKIP=`cat "$tmpfile" |wc -l`
573
# Get rid of any spaces
574
SKIP=`expr $SKIP`
575
rm -f "$tmpfile"
499
- if test "$QUIET" = "n";then
500
- echo Header is $SKIP lines long >&2
501
- fi
502
-
576
+ if test "$QUIET" = "n"; then
577
+ echo "Header is $SKIP lines long" >&2
578
+ fi
579
archname="$oldarchname"
580
else
581
echo "Unable to open header file: $HEADER" >&2
582
exit 1
583
fi
584
509
-if test "$QUIET" = "n";then
585
+if test "$QUIET" = "n"; then
586
echo
587
fi
588
@@ -525,36 +601,101 @@ if test "." = "$archdirname"; then
601
fi
602
603
test -d "$archdir" || { echo "Error: $archdir does not exist."; rm -f "$tmpfile"; exit 1; }
528
-if test "$QUIET" = "n";then
529
- echo About to compress $USIZE KB of data...
530
- echo Adding files to archive named \"$archname\"...
604
+if test "$QUIET" = "n"; then
605
+ echo "About to compress $USIZE KB of data..."
606
+ echo "Adding files to archive named \"$archname\"..."
607
+fi
608
+
609
+# See if we have GNU tar
610
+TAR=`exec <&- 2>&-; which gtar || command -v gtar || type gtar`
611
+test -x "$TAR" || TAR=`exec <&- 2>&-; which bsdtar || command -v bsdtar || type bsdtar`
612
+test -x "$TAR" || TAR=tar
613
+
614
+tmparch="${TMPDIR:-/tmp}/mkself$$.tar"
615
+(
616
+ if test "$APPEND" = "y"; then
617
+ tail -n "+$OLDSKIP" "$archname" | eval "$GUNZIP_CMD" > "$tmparch"
618
+ fi
619
+ cd "$archdir"
620
+ # "Determining if a directory is empty"
621
+ # https://www.etalabs.net/sh_tricks.html
622
+ find . \
623
+ \( \
624
+ ! -type d \
625
+ -o \
626
+ \( -links 2 -exec sh -c '
627
+ is_empty () (
628
+ cd "$1"
629
+ set -- .[!.]* ; test -f "$1" && return 1
630
+ set -- ..?* ; test -f "$1" && return 1
631
+ set -- * ; test -f "$1" && return 1
632
+ return 0
633
+ )
634
+ is_empty "$0"' {} \; \
635
+ \) \
636
+ \) -print \
637
+ | LC_ALL=C sort \
638
+ | sed 's/./\\&/g' \
639
+ | xargs $TAR $TAR_EXTRA --format $TAR_FORMAT -$TAR_ARGS "$tmparch"
640
+) || {
641
+ echo "ERROR: failed to create temporary archive: $tmparch"
642
+ rm -f "$tmparch" "$tmpfile"
643
+ exit 1
644
+}
645
+
646
+USIZE=`du $DU_ARGS "$tmparch" | awk '{print $1}'`
647
+
648
+eval "$GZIP_CMD" <"$tmparch" >"$tmpfile" || {
649
+ echo "ERROR: failed to create temporary file: $tmpfile"
650
+ rm -f "$tmparch" "$tmpfile"
651
+ exit 1
652
+}
653
+rm -f "$tmparch"
654
+
655
+if test x"$ENCRYPT" = x"openssl"; then
656
+ echo "About to encrypt archive \"$archname\"..."
657
+ { eval "$ENCRYPT_CMD -in $tmpfile -out ${tmpfile}.enc" && mv -f ${tmpfile}.enc $tmpfile; } || \
658
+ { echo Aborting: could not encrypt temporary file: "$tmpfile".; rm -f "$tmpfile"; exit 1; }
659
fi
532
-exec 3<> "$tmpfile"
533
-( cd "$archdir" && ( tar $TAR_EXTRA -$TAR_ARGS - . | eval "$GZIP_CMD" >&3 ) ) || \
534
- { echo Aborting: archive directory not found or temporary file: "$tmpfile" could not be created.; exec 3>&-; rm -f "$tmpfile"; exit 1; }
535
-exec 3>&- # try to close the archive
660
661
fsize=`cat "$tmpfile" | wc -c | tr -d " "`
662
663
# Compute the checksums
664
665
+shasum=0000000000000000000000000000000000000000000000000000000000000000
666
md5sum=00000000000000000000000000000000
667
crcsum=0000000000
668
669
if test "$NOCRC" = y; then
545
- if test "$QUIET" = "n";then
670
+ if test "$QUIET" = "n"; then
671
echo "skipping crc at user request"
672
fi
673
else
549
- crcsum=`cat "$tmpfile" | CMD_ENV=xpg4 cksum | sed -e 's/ /Z/' -e 's/ /Z/' | cut -dZ -f1`
550
- if test "$QUIET" = "n";then
674
+ crcsum=`CMD_ENV=xpg4 cksum < "$tmpfile" | sed -e 's/ /Z/' -e 's/ /Z/' | cut -dZ -f1`
675
+ if test "$QUIET" = "n"; then
676
echo "CRC: $crcsum"
677
fi
678
fi
679
680
+if test "$SHA256" = y; then
681
+ SHA_PATH=`exec <&- 2>&-; which shasum || command -v shasum || type shasum`
682
+ if test -x "$SHA_PATH"; then
683
+ shasum=`eval "$SHA_PATH -a 256" < "$tmpfile" | cut -b-64`
684
+ else
685
+ SHA_PATH=`exec <&- 2>&-; which sha256sum || command -v sha256sum || type sha256sum`
686
+ shasum=`eval "$SHA_PATH" < "$tmpfile" | cut -b-64`
687
+ fi
688
+ if test "$QUIET" = "n"; then
689
+ if test -x "$SHA_PATH"; then
690
+ echo "SHA256: $shasum"
691
+ else
692
+ echo "SHA256: none, SHA command not found"
693
+ fi
694
+ fi
695
+fi
696
if test "$NOMD5" = y; then
556
- if test "$QUIET" = "n";then
557
- echo "skipping md5sum at user request"
697
+ if test "$QUIET" = "n"; then
698
+ echo "Skipping md5sum at user request"
699
fi
700
else
701
# Try to locate a MD5 binary
@@ -569,53 +710,71 @@ else
710
if test `basename ${MD5_PATH}`x = digestx; then
711
MD5_ARG="-a md5"
712
fi
572
- md5sum=`cat "$tmpfile" | eval "$MD5_PATH $MD5_ARG" | cut -b-32`;
573
- if test "$QUIET" = "n";then
713
+ md5sum=`eval "$MD5_PATH $MD5_ARG" < "$tmpfile" | cut -b-32`
714
+ if test "$QUIET" = "n"; then
715
echo "MD5: $md5sum"
716
fi
717
else
577
- if test "$QUIET" = "n";then
718
+ if test "$QUIET" = "n"; then
719
echo "MD5: none, MD5 command not found"
720
fi
721
fi
722
fi
723
+if test "$SIGN" = y; then
724
+ GPG_PATH=`exec <&- 2>&-; which gpg || command -v gpg || type gpg`
725
+ if test -x "$GPG_PATH"; then
726
+ SIGNATURE=`$GPG_PATH --pinentry-mode=loopback --batch --yes $GPG_EXTRA --passphrase "$GPG_PASSPHRASE" --output - --detach-sig $tmpfile | base64 | tr -d \\\\n`
727
+ if test "$QUIET" = "n"; then
728
+ echo "Signature: $SIGNATURE"
729
+ fi
730
+ else
731
+ echo "Missing gpg command" >&2
732
+ fi
733
+fi
734
+
735
+totalsize=0
736
+for size in $fsize;
737
+do
738
+ totalsize=`expr $totalsize + $size`
739
+done
740
741
if test "$APPEND" = y; then
742
mv "$archname" "$archname".bak || exit
743
744
# Prepare entry for new archive
587
- filesizes="$filesizes $fsize"
588
- CRCsum="$CRCsum $crcsum"
589
- MD5sum="$MD5sum $md5sum"
590
- USIZE=`expr $USIZE + $OLDUSIZE`
745
+ filesizes="$fsize"
746
+ CRCsum="$crcsum"
747
+ MD5sum="$md5sum"
748
+ SHAsum="$shasum"
749
+ Signature="$SIGNATURE"
750
# Generate the header
751
. "$HEADER"
593
- # Append the original data
594
- tail -n +$OLDSKIP "$archname".bak >> "$archname"
752
# Append the new data
753
cat "$tmpfile" >> "$archname"
754
755
chmod +x "$archname"
756
rm -f "$archname".bak
600
- if test "$QUIET" = "n";then
601
- echo Self-extractable archive \"$archname\" successfully updated.
757
+ if test "$QUIET" = "n"; then
758
+ echo "Self-extractable archive \"$archname\" successfully updated."
759
fi
760
else
761
filesizes="$fsize"
762
CRCsum="$crcsum"
763
MD5sum="$md5sum"
764
+ SHAsum="$shasum"
765
+ Signature="$SIGNATURE"
766
767
# Generate the header
768
. "$HEADER"
769
770
# Append the compressed tar data after the stub
612
- if test "$QUIET" = "n";then
613
- echo
771
+ if test "$QUIET" = "n"; then
772
+ echo
773
fi
774
cat "$tmpfile" >> "$archname"
775
chmod +x "$archname"
617
- if test "$QUIET" = "n";then
618
- echo Self-extractable archive \"$archname\" successfully created.
776
+ if test "$QUIET" = "n"; then
777
+ echo Self-extractable archive \"$archname\" successfully created.
778
fi
779
fi
780
rm -f "$tmpfile"