Skip to content

Commit b10387a

Browse files
authored
Merge pull request #2863 from flatcar/chewi/extract-vmlinuz-mkdir
build_library: Fix extraction script and sort content listings
2 parents 9af775b + 10498c2 commit b10387a

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

build_library/extract-initramfs-from-vmlinuz.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@ try_extract() {
2929
# cpio can do strange things when given garbage, so do a basic check.
3030
[[ $(head -c6 "$1") == 070701 ]] || return 0
3131

32-
# There may be multiple concatenated archives so try cpio till it fails.
33-
while cpio --quiet --extract --make-directories --directory="${out}/rootfs-${ROOTFS_IDX}" --nonmatching 'dev/*' 2>/dev/null; do
32+
while {
33+
# cpio needs the directory to exist first. Fail if it's already there.
34+
{ mkdir "${out}/rootfs-${ROOTFS_IDX}" || return $?; } &&
35+
# There may be multiple concatenated archives so try cpio till it fails.
36+
cpio --quiet --extract --make-directories --directory="${out}/rootfs-${ROOTFS_IDX}" --nonmatching 'dev/*' 2>/dev/null
37+
}; do
3438
ROOTFS_IDX=$(( ROOTFS_IDX + 1 ))
3539
done < "$1"
3640

@@ -49,7 +53,7 @@ if [[ ! -s "${image}" ]]; then
4953
fi
5054
mkdir -p "${out}"
5155

52-
tmp=$(mktemp --directory eifv-XXXXXX)
56+
tmp=$(mktemp --directory -t eifv-XXXXXX)
5357
trap 'rm -rf -- "${tmp}"' EXIT
5458
ROOTFS_IDX=0
5559

build_library/reports_util.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ write_contents() {
3333
# %l - symlink target (empty if not a symlink)
3434
sudo TZ=UTC find -printf \
3535
'%M %2n %-7u %-7g %7s %TY-%Tm-%Td %TH:%TM ./%P -> %l\n' \
36+
| sort --key=8 \
3637
| sed -e 's/ -> $//' >"${output}"
3738
popd >/dev/null
3839
}
@@ -57,7 +58,8 @@ write_contents_with_technical_details() {
5758
# %s - size in bytes
5859
# %P - file's path
5960
sudo find -printf \
60-
'%M %D %i %n %s ./%P\n' >"${output}"
61+
'%M %D %i %n %s ./%P\n' \
62+
| sort --key=6 >"${output}"
6163
popd >/dev/null
6264
}
6365

0 commit comments

Comments
 (0)