logo

bootstrap-initrd

Linux initrd to bootstrap from a small binary seed git clone https://hacktivis.me/git/bootstrap-initrd.git
commit: fa56e5d3d2db185ea459b0164d91e2e5142acd76
parent 1876405595f965455e74605cf77b6fec72ea905f
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Tue, 19 Nov 2024 06:59:18 +0100

make-root.sh: use deblob -j + jq(1)/qjs(1) instead of parsing output with awk

Diffstat:

Mmake-root.sh16+++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/make-root.sh b/make-root.sh @@ -242,6 +242,20 @@ done rm -r awk-*/testdir || die -deblob -n | tee /dev/stderr | awk '/detected: /{ print $2 }' | xargs du -bach | sort -h +deblob -n -j "${WORKDIR}"/make-root-deblob.json || die + +if command -v jq >/dev/null; then + jq --raw-output0 '.[].path' "${WORKDIR}"/make-root-deblob.json \ + | xargs -0 du -bach \ + | sort -h +elif command -v qjs >/dev/null; then + <"${WORKDIR}"/make-root-deblob.json \ + qjs --std \ + -e 'let deblob_raw = std.in.readAsString(); let deblob = JSON.parse(deblob_raw); deblob.forEach((e) => {std.printf("%s\0", e.path);})' \ + | xargs -0 du -bach \ + | sort -h +else + echo "make-root: Command 'jq' and 'qjs' not found. Not going to list sizes of blobs" 1>&2 +fi cd "${WORKDIR}"