unmkinitramfs: Add support for lzma compression

The kernel and mkinitramfs support lzma compression, but for some
reason this was not included in unmkinitramfs.

- Add a format code, magic entry, and decompression command for lzma
  to unmkinitramfs
- Add lzma to the compression commands in the test case

Signed-off-by: Ben Hutchings <benh@debian.org>
This commit is contained in:
Ben Hutchings 2025-05-31 17:49:19 +02:00
parent e28d365867
commit 02bd63ab71
2 changed files with 4 additions and 1 deletions

View File

@ -57,7 +57,7 @@ for n_early in 0 1 2; do
continue
fi
for compressor in no_compressor gzip bzip2 xz lzop 'lz4 -l' zstd; do
for compressor in no_compressor gzip bzip2 lzma xz lzop 'lz4 -l' zstd; do
# If last archive is early, it can't be compressed
if [ $n_main -eq 0 ] && [ "$compressor" != no_compressor ]; then
continue

View File

@ -65,6 +65,7 @@ enum format {
FORMAT_CPIO_NEW,
FORMAT_GZIP,
FORMAT_BZIP2,
FORMAT_LZMA,
FORMAT_XZ,
FORMAT_LZO,
FORMAT_LZ4,
@ -86,6 +87,7 @@ static const struct magic_entry magic_table[] = {
MAGIC_ENTRY(CPIO_NEW_CRC_MAGIC, FORMAT_CPIO_NEW),
MAGIC_ENTRY("\x1f\x8b\x08", FORMAT_GZIP),
MAGIC_ENTRY("BZh", FORMAT_BZIP2),
MAGIC_ENTRY("\x5d\0\0", FORMAT_LZMA),
MAGIC_ENTRY("\xfd""7zXZ\0", FORMAT_XZ),
MAGIC_ENTRY("\x89LZO\0\r\n\x1a\n", FORMAT_LZO),
/* lz4 "legacy" format, the only version that the kernel supports */
@ -97,6 +99,7 @@ static const struct magic_entry magic_table[] = {
static const char *const decomp_table[][2] = {
[FORMAT_GZIP] = { "gzip", "-cd" },
[FORMAT_BZIP2] = { "bzip2", "-cd" },
[FORMAT_LZMA] = { "lzma", "-cd" },
[FORMAT_XZ] = { "xzcat" },
[FORMAT_LZO] = { "lzop", "-cd" },
[FORMAT_LZ4] = { "lz4cat" },