From ec904175e61e64b6056c6582e11a77e36a262f60 Mon Sep 17 00:00:00 2001 From: James Le Cuirot Date: Wed, 30 Apr 2025 16:39:24 +0100 Subject: [PATCH 1/3] build_library: Fix directory handling in extraction script I thought cpio was always creating the output directory automatically, but it was silently failing. It would only extract the next rootfs when run a subsequent time. Signed-off-by: James Le Cuirot --- build_library/extract-initramfs-from-vmlinuz.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/build_library/extract-initramfs-from-vmlinuz.sh b/build_library/extract-initramfs-from-vmlinuz.sh index 50fbc9fea0..d46d9137de 100755 --- a/build_library/extract-initramfs-from-vmlinuz.sh +++ b/build_library/extract-initramfs-from-vmlinuz.sh @@ -29,8 +29,12 @@ try_extract() { # cpio can do strange things when given garbage, so do a basic check. [[ $(head -c6 "$1") == 070701 ]] || return 0 - # There may be multiple concatenated archives so try cpio till it fails. - while cpio --quiet --extract --make-directories --directory="${out}/rootfs-${ROOTFS_IDX}" --nonmatching 'dev/*' 2>/dev/null; do + while { + # cpio needs the directory to exist first. Fail if it's already there. + { mkdir "${out}/rootfs-${ROOTFS_IDX}" || return $?; } && + # There may be multiple concatenated archives so try cpio till it fails. + cpio --quiet --extract --make-directories --directory="${out}/rootfs-${ROOTFS_IDX}" --nonmatching 'dev/*' 2>/dev/null + }; do ROOTFS_IDX=$(( ROOTFS_IDX + 1 )) done < "$1" From 68def073cfddac35a09c5985c61e43e20d04f13a Mon Sep 17 00:00:00 2001 From: James Le Cuirot Date: Thu, 1 May 2025 12:06:52 +0100 Subject: [PATCH 2/3] build_library: Sort content listings for more consistent output Signed-off-by: James Le Cuirot --- build_library/reports_util.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/build_library/reports_util.sh b/build_library/reports_util.sh index 0873d9e960..b8548a9415 100644 --- a/build_library/reports_util.sh +++ b/build_library/reports_util.sh @@ -33,6 +33,7 @@ write_contents() { # %l - symlink target (empty if not a symlink) sudo TZ=UTC find -printf \ '%M %2n %-7u %-7g %7s %TY-%Tm-%Td %TH:%TM ./%P -> %l\n' \ + | sort --key=8 \ | sed -e 's/ -> $//' >"${output}" popd >/dev/null } @@ -57,7 +58,8 @@ write_contents_with_technical_details() { # %s - size in bytes # %P - file's path sudo find -printf \ - '%M %D %i %n %s ./%P\n' >"${output}" + '%M %D %i %n %s ./%P\n' \ + | sort --key=6 >"${output}" popd >/dev/null } From 10498c29fb401038408f5d6bf56699460a375884 Mon Sep 17 00:00:00 2001 From: James Le Cuirot Date: Fri, 2 May 2025 14:27:25 +0100 Subject: [PATCH 3/3] build_library: Create extraction script temp files in $TMPDIR or /tmp Signed-off-by: James Le Cuirot --- build_library/extract-initramfs-from-vmlinuz.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_library/extract-initramfs-from-vmlinuz.sh b/build_library/extract-initramfs-from-vmlinuz.sh index d46d9137de..83f2137b9d 100755 --- a/build_library/extract-initramfs-from-vmlinuz.sh +++ b/build_library/extract-initramfs-from-vmlinuz.sh @@ -53,7 +53,7 @@ if [[ ! -s "${image}" ]]; then fi mkdir -p "${out}" -tmp=$(mktemp --directory eifv-XXXXXX) +tmp=$(mktemp --directory -t eifv-XXXXXX) trap 'rm -rf -- "${tmp}"' EXIT ROOTFS_IDX=0