[OpenWrt-Devel] [PATCH] build: allow alternative gzip image compression utility
Ian Cooper
iancooper at hotmail.com
Fri Jun 12 12:41:39 EDT 2020
Allow the user to specify an alternative option-compatible gzip
utility such as the parallel pigz gzip utility, which speeds up
compression of target images and archives considerably.
Signed-off-by: Ian Cooper <iancooper at hotmail.com>
---
On my 4-core i7-4790s, it takes a full 10 minutes to build the images
for my x86_64 build as there are lots of packages included in the image.
The largest part of this time is the gzip compression. The pigz utility
is much faster, even on my limited 4 cores. Below is the timing of a
make target/install for the gzip and pigz utilities
using gzip on 4-core i7-4790
real 9m48.480s
user 8m41.578s
sys 0m44.228s
using pigz on 4-core i7-4790
real 3m34.367s
user 11m23.081s
sys 0m49.984s
config/Config-images.in | 10 ++++++++++
include/image-commands.mk | 2 +-
include/image.mk | 10 ++++++----
3 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/config/Config-images.in b/config/Config-images.in
index 4c54ac9399..7c3bc2760e 100644
--- a/config/Config-images.in
+++ b/config/Config-images.in
@@ -287,4 +287,14 @@ menu "Target Images"
it will be mounted by PARTUUID which makes the kernel find the
appropriate disk automatically.
+ config TARGET_IMAGE_COMPRESSION_UTILITY
+ string
+ prompt "Gzip image compression utility"
+ default "gzip"
+ help
+ Specify the name of the image compression binary used to gzip
+ compress images. This utility must be option compatible with
+ gzip. A good alternative would be the parallel gzip utility
+ pigz.
+
endmenu
diff --git a/include/image-commands.mk b/include/image-commands.mk
index e7db7128b4..faba8658c0 100644
--- a/include/image-commands.mk
+++ b/include/image-commands.mk
@@ -174,7 +174,7 @@ define Build/lzma-no-dict
endef
define Build/gzip
- gzip -f -9n -c $@ $(1) > $@.new
+ $(call qstrip,$(CONFIG_TARGET_IMAGE_COMPRESSION_UTILITY)) -f -9n -c $@ $(1) > $@.new
@mv $@.new $@
endef
diff --git a/include/image.mk b/include/image.mk
index 984b64fb9c..61182a22ac 100644
--- a/include/image.mk
+++ b/include/image.mk
@@ -151,7 +151,7 @@ endef
ifdef CONFIG_TARGET_IMAGES_GZIP
define Image/Gzip
rm -f $(1).gz
- gzip -9n $(1)
+ $(call qstrip,$(CONFIG_TARGET_IMAGE_COMPRESSION_UTILITY)) -9n $(1)
endef
endif
@@ -317,13 +317,15 @@ ifdef CONFIG_TARGET_ROOTFS_TARGZ
define Image/Build/targz
$(TAR) -cp --numeric-owner --owner=0 --group=0 --mode=a-s --sort=name \
$(if $(SOURCE_DATE_EPOCH),--mtime="@$(SOURCE_DATE_EPOCH)") \
- -C $(TARGET_DIR)/ . | gzip -9n > $(BIN_DIR)/$(IMG_PREFIX)$(if $(PROFILE_SANITIZED),-$(PROFILE_SANITIZED))-rootfs.tar.gz
+ -C $(TARGET_DIR)/ . | $(call qstrip,$(CONFIG_TARGET_IMAGE_COMPRESSION_UTILITY)) \
+ -9n > $(BIN_DIR)/$(IMG_PREFIX)$(if $(PROFILE_SANITIZED),-$(PROFILE_SANITIZED))-rootfs.tar.gz
endef
endif
ifdef CONFIG_TARGET_ROOTFS_CPIOGZ
define Image/Build/cpiogz
- ( cd $(TARGET_DIR); find . | cpio -o -H newc -R root:root | gzip -9n >$(BIN_DIR)/$(IMG_ROOTFS).cpio.gz )
+ ( cd $(TARGET_DIR); find . | cpio -o -H newc -R root:root | \
+ $(call qstrip,$(CONFIG_TARGET_IMAGE_COMPRESSION_UTILITY)) -9n >$(BIN_DIR)/$(IMG_ROOTFS).cpio.gz )
endef
endif
@@ -567,7 +569,7 @@ define Device/Build/image
.IGNORE: $(BIN_DIR)/$(call IMAGE_NAME,$(1),$(2))
$(BIN_DIR)/$(call IMAGE_NAME,$(1),$(2)).gz: $(KDIR)/tmp/$(call IMAGE_NAME,$(1),$(2))
- gzip -c -9n $$^ > $$@
+ $(call qstrip,$(CONFIG_TARGET_IMAGE_COMPRESSION_UTILITY)) -c -9n $$^ > $$@
$(BIN_DIR)/$(call IMAGE_NAME,$(1),$(2)): $(KDIR)/tmp/$(call IMAGE_NAME,$(1),$(2))
cp $$^ $$@
--
2.25.1
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list