. "$BST_LIB" # makeself 2.5.0, part 4 of 5 — the COMPRESSOR and CHECKSUM axes, both proved by # ONE archive and without unpacking it. See part 2's header for the measured # per-boot budget this file is sized against. # # It is numbered 4, ahead of the verify file, because this file's `--list` is the # LAST operation in the whole makeself surface that still has to run tar through # a decompressor, and that is the resource in short supply (part 2's header has # the measurements). Part 5 needs none of it -- --check is dd | md5sum and a # damaged archive is refused at the size comparison -- so it is the file that can # most afford to run last. The rule this encodes: order suites so the one needing # the least budget goes last. # # Reordering alone was not enough, and the sequence is worth recording because it # is what pinned the rule down. With a --list in part 2 as well, this file's # --list was the fourth tar-decompression of the boot and failed with "tar: Cannot # allocate memory" -- at position 5 and again at position 4. Only removing the # redundant --list from part 2 (its run already unpacks the same payload, and # part 3 asserts the nested entry) brought the count to three and this file green. # So the budget is a per-boot COUNT, not a function of where a suite sits. # # makeself bakes its choices into the generated header at CREATE time -- the # decompress command for the compressor, the checksum block for the digests -- so # each axis is a distinct end-to-end path rather than a flag on one code path. # gzip and the default CRC+MD5 pair are covered by parts 2 and 5; this file covers # the other end of each axis with `--bzip2 --sha256`. # # The two axes share one archive deliberately. They are independent in makeself, # so combining them still exercises both baked-in paths, and the alternative -- # one archive each -- would spend a create the surface would rather keep in # reserve. What makes the sharing safe as an assertion is that the two are read # back through DIFFERENT mechanisms: --info reports the compressor from the header # variables, while --check recomputes and compares the SHA256 over the payload. A # silent fallback to gzip would fail the first; a missing SHA256 block would fail # the second. # # Neither case unpacks. `--list` runs the same dd | bunzip2 | tar pipeline a real # extraction does but with `tar t`, so it proves the bzip2 archive round-trips # without writing files out; `--check` is dd | sha256sum. # # Four modes are deliberately NOT exercised, for two different reasons: # * xz and zstd -- NOT PORTED to wasm32-hwjs (the image header records the # lzma/zstd paths disabled), so `makeself --xz` would build an archive this # image cannot unpack. A property of the image, not a makeself defect, so it # is omitted rather than shipped as a red. # * --nocomp (GZIP_CMD/GUNZIP_CMD both `cat`) and --nomd5 --nocrc -- both # MEASURED WORKING on target in isolation: --nocomp creates, lists and runs # correctly, and a no-checksum archive still lists and still exits 0, its # --check reporting "does not contain an embedded MD5 checksum ... All good." # ("no checksum" is not "failed checksum" -- the header skips the comparison # rather than failing it.) They are omitted on BUDGET, not doubt: each needs # its own create, and an earlier layout that included them lost whole suites # to the per-boot ceiling. require makeself.sh makeself/present . "$BST_DATA/makeself-lib.sh" # ms_gate / ms_needle MS=/usr/bin/makeself.sh LC_ALL=C; export LC_ALL W=${TMPDIR:-/tmp}/bst-makeself-axes.$$ rm -rf "$W"; mkdir -p "$W/p" || { bst_notok makeself/axes-setup "cannot create $W"; exit 0; } echo axes-marker > "$W/p/g.txt" printf '#!/bin/sh\necho MS-STARTUP-RAN\nexit 0\n' > "$W/p/s.sh" chmod 755 "$W/p/s.sh" cd "$W" || { bst_notok makeself/axes-setup "cannot cd $W"; exit 0; } A="$W/axes.run" MSC=$("$MS" --bzip2 --sha256 "$W/p" "$A" "BST Axes" ./s.sh 2>&1); MSCRC=$? if [ "$MSCRC" -eq 0 ] && [ -s "$A" ]; then bst_ok makeself/axes-create else bst_notok makeself/axes-create "rc=$MSCRC $(_bst_1line "$MSC")" cd /; rm -rf "$W"; exit 0 fi # --- compressor axis: the header's baked-in decompressor round-trips -------- MSL=$("$A" --noprogress --list 2>&1); MSLRC=$? if [ "$MSLRC" -ne 0 ] || ! printf '%s\n' "$MSL" | grep -q 'g\.txt'; then # A --list that produced no entry has not proved the round trip, whatever its # exit status: the header's --list branch exits 0 unconditionally, so an empty # listing is the failure mode to catch here rather than a nonzero rc. [ "$MSLRC" -eq 0 ] && MSLRC=1 fi ms_gate makeself/bzip2-list "$MSLRC" "$MSL" ms_needle makeself/bzip2-list-entry "g.txt" "$MSL" # --info must report the compressor the create was asked for; a silent fallback # to gzip fails here. MSI=$("$A" --info 2>&1) case "$MSI" in *"Compression: bzip2"*) bst_ok makeself/bzip2-info ;; *) bst_notok makeself/bzip2-info "want:'Compression: bzip2' got:'$(_bst_1line "$MSI")'" ;; esac # --- checksum axis: the SHA256 block is present and recomputes ------------- MSK=$("$A" --noprogress --check 2>&1); MSKRC=$? if [ "$MSKRC" -eq 0 ]; then bst_ok makeself/sha256-check-rc else bst_notok makeself/sha256-check-rc "rc=$MSKRC $(_bst_1line "$MSK")"; fi # With --sha256 the archive DOES carry one, so --check reports it verified rather # than the default's "does not contain an embedded SHA256 checksum". case "$MSK" in *"SHA256 checksums are OK"*) bst_ok makeself/sha256-verified ;; *) bst_notok makeself/sha256-verified "want:'SHA256 checksums are OK' got:'$(_bst_1line "$MSK")'" ;; esac cd / rm -rf "$W"