initrd/bin/unpack_initramfs.sh: add xz to unpack logic (add commented: bzip2, lzma, lzo and lz4)

xz: tested working with tails test build and 6.8.1's initrd
latest ubuntu 24.10: switched back to zstd, works as expected (tested)

Magic numbers referred at:
- 28eb75e178/scripts/extract-vmlinux (L52C1-L58C43)
- https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/lib/decompress.c#n51

Signed-off-by: Thierry Laurion <insurgo@riseup.net>
This commit is contained in:
Thierry Laurion 2024-11-22 16:43:12 -05:00
parent 71a8075125
commit 95c6eb5c49
No known key found for this signature in database
GPG Key ID: 9A53E1BB3FF00461

View File

@ -90,6 +90,10 @@ unpack_first_segment() {
# walking all the compressed blocks.
gunzip | unpack_cpio
;;
fd37*) # xz
DEBUG "archive segment $magic: xz"
unxz | unpack_cpio
;;
28b5*) # zstd
DEBUG "archive segment $magic: zstd"
# Like gunzip, this will not stop when reaching the end of the
@ -99,6 +103,26 @@ unpack_first_segment() {
;;
*) # unknown
die "Can't decompress initramfs archive, unknown type: $magic"
# The following are magic values for other compression formats
# but not added because not tested.
# TODO: open an issue for unsupported magic number reported on die.
#
#425a*) # bzip2
# DEBUG "archive segment $magic: bzip2"
# bunzip2 | unpack_cpio
#;;
#5d00*) # lzma
# DEBUG "archive segment $magic: lzma"
# unlzma | unpack_cpio
#;;
#894c*) # lzo
# DEBUG "archive segment $magic: lzo"
# lzop -d | unpack_cpio
#;;
#0221*) # lz4
# DEBUG "archive segment $magic: lz4"
# lz4 -d | unpack_cpio
# ;;
;;
esac
) <"$unpack_archive" >"$rest_archive"