[arch-projects] [mkinitcpio] [PATCH 1/3] lsinitcpio: add support for lz4 compressed image
Note that this requires a very recent version of lz4 utilities as it uses lz4, and not the original lz4c tool, in order to be command line API compliant with other compression tools. See upstream discussions: https://code.google.com/p/lz4/issues/detail?id=83 Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- community/lz4-104-1 has this now. PKGBUILD | 1 + lsinitcpio | 7 ++++++- mkinitcpio.conf | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/PKGBUILD b/PKGBUILD index 440e691..89613a4 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -14,6 +14,7 @@ makedepends=('asciidoc' 'git' 'sed') optdepends=('xz: Use lzma or xz compression for the initramfs image' 'bzip2: Use bzip2 compression for the initramfs image' 'lzop: Use lzo compression for the initramfs image' + 'lz4: Use lz4 compression for the initramfs image' 'mkinitcpio-nfs-utils: Support for root filesystem on NFS') backup=(etc/mkinitcpio.conf) diff --git a/lsinitcpio b/lsinitcpio index c1c5e21..5f19326 100755 --- a/lsinitcpio +++ b/lsinitcpio @@ -69,7 +69,7 @@ size_to_human() { } detect_filetype() { - case $(hexdump -n 6 -e '"%c"' "$1") in + case $(hexdump -n 6 -e '"%c"' "$1") in '070701') # no compression return @@ -90,6 +90,11 @@ detect_filetype() { return fi + if [[ $(hexdump -n 4 -e '"%x"' "$1") == '184d2204' ]]; then + echo 'lz4' + return + fi + if [[ $(hexdump -n 3 -e '"%c"' "$1") == 'BZh' ]]; then echo 'bzip2' return diff --git a/mkinitcpio.conf b/mkinitcpio.conf index 7616809..c4d5e06 100644 --- a/mkinitcpio.conf +++ b/mkinitcpio.conf @@ -59,6 +59,7 @@ HOOKS="base udev autodetect modconf block filesystems keyboard fsck" #COMPRESSION="lzma" #COMPRESSION="xz" #COMPRESSION="lzop" +#COMPRESSION="lz4" # COMPRESSION_OPTIONS # Additional options for the compressor -- 1.8.4
The impetus for doing this was a bug in util-linux's hexdump which never saw a release. For uniformity, simply echo an empty line here. Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- lsinitcpio | 1 + 1 file changed, 1 insertion(+) diff --git a/lsinitcpio b/lsinitcpio index 5f19326..0c9d05d 100755 --- a/lsinitcpio +++ b/lsinitcpio @@ -72,6 +72,7 @@ detect_filetype() { case $(hexdump -n 6 -e '"%c"' "$1") in '070701') # no compression + echo return ;; $'\xfd7zXZ') -- 1.8.4
It doesn't make any sense that this was added during the final image creation. This fixes a subtle bug that would manifest itself if the user archived the build root manually. Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- functions | 3 +++ mkinitcpio | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/functions b/functions index 532884f..e54f4bf 100644 --- a/functions +++ b/functions @@ -648,6 +648,9 @@ initialize_buildroot() { ;; esac + # mkinitcpio version stamp + printf '%s' "$version" >"$workdir/root/VERSION" + # kernel module dir install -dm755 "$workdir/root/usr/lib/modules/$kernver/kernel" diff --git a/mkinitcpio b/mkinitcpio index 8139ee0..7ce6c5c 100755 --- a/mkinitcpio +++ b/mkinitcpio @@ -210,9 +210,6 @@ build_image() { cpio_opts+=('-R' '0:0') fi - # write version stamp - printf '%s' "$version" > "$BUILDROOT/VERSION" - pushd "$BUILDROOT" >/dev/null find . -print0 | LANG=C bsdcpio "${cpio_opts[@]}" | -- 1.8.4
participants (1)
-
Dave Reisner