From 4f514f521209206cda7b3387883b863209a03185 Mon Sep 17 00:00:00 2001 From: Michael Aldridge Date: Mon, 21 Aug 2017 00:04:17 -0700 Subject: [PATCH] Explicitly set number of xz compressor threads --- Makefile | 11 ++++++----- mkimage.sh.in | 6 ++++-- mkplatformfs.sh.in | 6 ++++-- mkrootfs.sh.in | 6 ++++-- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 1388eb8..9ecd6da 100644 --- a/Makefile +++ b/Makefile @@ -23,6 +23,7 @@ ALL_CLOUD_IMAGES=$(foreach cloud,$(CLOUD_IMGS),void-$(cloud)-$(DATE).tar.gz) SUDO := sudo XBPS_REPOSITORY := -r https://lug.utdallas.edu/mirror/void/current -r https://lug.utdallas.edu/mirror/void/current/musl -r https://lug.utdallas.edu/mirror/void/current/aarch64 +COMPRESSOR_THREADS=2 %.sh: %.sh.in sed -e "s|@@MKLIVE_VERSION@@|$(VERSION) $(GITVER)|g" $^ > $@ @@ -45,10 +46,10 @@ rootfs-all-print: echo $(ALL_ROOTFS) void-%-ROOTFS-$(DATE).tar.xz: $(SCRIPTS) - $(SUDO) ./mkrootfs.sh $(XBPS_REPOSITORY) $* + $(SUDO) ./mkrootfs.sh $(XBPS_REPOSITORY) -x $(COMPRESSOR_THREADS) $* void-%-PLATFORMFS-$(DATE).tar.xz: $(SCRIPTS) - $(SUDO) ./mkplatformfs.sh $(XBPS_REPOSITORY) $* void-$(shell ./lib.sh platform2arch $*)-ROOTFS-$(DATE).tar.xz + $(SUDO) ./mkplatformfs.sh $(XBPS_REPOSITORY) -x $(COMPRESSOR_THREADS) $* void-$(shell ./lib.sh platform2arch $*)-ROOTFS-$(DATE).tar.xz platformfs-all: rootfs-all $(ALL_PLATFORMFS) @@ -65,14 +66,14 @@ images-all-print: @echo $(ALL_SBC_IMAGES) $(ALL_CLOUD_IMAGES) void-%-$(DATE).img.xz: - $(SUDO) ./mkimage.sh void-$*-PLATFORMFS-$(DATE).tar.xz + $(SUDO) ./mkimage.sh -x $(COMPRESSOR_THREADS) void-$*-PLATFORMFS-$(DATE).tar.xz # The GCP images are special for $reasons void-GCP-$(DATE).tar.gz: - $(SUDO) ./mkimage.sh void-GCP-PLATFORMFS-$(DATE).tar.xz + $(SUDO) ./mkimage.sh -x $(COMPRESSOR_THREADS) void-GCP-PLATFORMFS-$(DATE).tar.xz void-GCP-musl-$(DATE).tar.gz: - $(SUDO) ./mkimage.sh void-GCP-musl-PLATFORMFS-$(DATE).tar.xz + $(SUDO) ./mkimage.sh -x $(COMPRESSOR_THREADS) void-GCP-musl-PLATFORMFS-$(DATE).tar.xz diff --git a/mkimage.sh.in b/mkimage.sh.in index d6ed34b..28fb99d 100644 --- a/mkimage.sh.in +++ b/mkimage.sh.in @@ -73,6 +73,7 @@ OPTIONS -r Set / filesystem type (defaults to EXT4) -s Set total image size (defaults to 2GB) -o Set image filename (guessed automatically) + -x Use threads to compress the image (dynamic if unset) -h Show this help -V Show version @@ -85,13 +86,14 @@ _EOF # SCRIPT EXECUTION STARTS HERE # ######################################## -while getopts "b:B:o:r:s:hV" opt; do +while getopts "b:B:o:r:s:x:h:V" opt; do case $opt in b) BOOT_FSTYPE="$OPTARG";; B) BOOT_FSSIZE="$OPTARG";; o) FILENAME="$OPTARG";; r) ROOT_FSTYPE="$OPTARG";; s) IMGSIZE="$OPTARG";; + x) COMPRESSOR_THREADS="$OPTARG" ;; V) echo "$PROGNAME @@MKLIVE_VERSION@@"; exit 0;; h) usage;; esac @@ -350,7 +352,7 @@ case "$PLATFORM" in ;; *) info_msg "Compressing $FILENAME with xz (level 9 compression)" - xz -T0 -9 "$FILENAME" + xz "-T${COMPRESSOR_THREADS:-0}" -9 "$FILENAME" info_msg "Successfully created $FILENAME image." ;; esac diff --git a/mkplatformfs.sh.in b/mkplatformfs.sh.in index 049319f..dac0df7 100644 --- a/mkplatformfs.sh.in +++ b/mkplatformfs.sh.in @@ -60,6 +60,7 @@ Options -c Set XBPS cache directory (defaults to \$PWD/xbps-cachedir-) -C Full path to the XBPS configuration file -r Set XBPS repository (may be set multiple times) + -x Use threads to compress the image (dynamic if unset) -h Show this help -V Show version _EOF @@ -71,7 +72,7 @@ _EOF BASEPKG=base-system -while getopts "b:p:k:c:C:r:h:V" opt; do +while getopts "b:p:k:c:C:r:x:h:V" opt; do case $opt in b) BASEPKG="$OPTARG" ;; p) EXTRA_PKGS="$OPTARG" ;; @@ -79,6 +80,7 @@ while getopts "b:p:k:c:C:r:h:V" opt; do c) XBPS_CACHEDIR="--cachedir=$OPTARG" ;; C) XBPS_CONFFILE="-C $OPTARG" ;; r) XBPS_REPOSITORY="$XBPS_REPOSITORY --repository=$OPTARG" ;; + x) COMPRESSOR_THREADS="$OPTARG" ;; h) usage; exit 0 ;; V) echo "$PROGNAME @@MKLIVE_VERSION@@"; exit 0 ;; esac @@ -161,7 +163,7 @@ rm -rf "$ROOTFS/var/cache/*" 2>/dev/null # Finally we can compress the tarball, the name will include the # platform and the date on which the tarball was built. tarball=void-${PLATFORM}-PLATFORMFS-$(date '+%Y%m%d').tar.xz -run_cmd "tar -cp --posix --xattrs -C $ROOTFS . | xz -T0 -9 > $tarball " +run_cmd "tar -cp --posix --xattrs -C $ROOTFS . | xz -T${COMPRESSOR_THREADS:-0} -9 > $tarball " # Now that we have the tarball we don't need the rootfs anymore, so we # can get rid of it. diff --git a/mkrootfs.sh.in b/mkrootfs.sh.in index c900d46..4aa1241 100644 --- a/mkrootfs.sh.in +++ b/mkrootfs.sh.in @@ -61,6 +61,7 @@ Options -C Full path to the XBPS configuration file -h Show this help -r Set XBPS repository (may be set multiple times) + -x Use threads to compress the image (dynamic if unset) -V Show version _EOF } @@ -71,12 +72,13 @@ _EOF # Boilerplate option parsing. This script supports the bare minimum # needed to build an image. -while getopts "C:c:h:r:V" opt; do +while getopts "C:c:h:r:x:V" opt; do case $opt in C) XBPS_CONFFILE="-C $OPTARG";; c) XBPS_CACHEDIR="--cachedir=$OPTARG";; h) usage; exit 0;; r) XBPS_REPOSITORY="$XBPS_REPOSITORY --repository=$OPTARG";; + x) COMPRESSOR_THREADS="$OPTARG" ;; V) echo "$PROGNAME @@MKLIVE_VERSION@@"; exit 0;; esac done @@ -205,7 +207,7 @@ rm -rf "$ROOTFS/var/cache/*" 2>/dev/null # Finally we can compress the tarball, the name will include the # architecture and the date on which the tarball was built. tarball=void-${XBPS_TARGET_ARCH}-ROOTFS-$(date '+%Y%m%d').tar.xz -run_cmd "tar -cp --posix --xattrs -C $ROOTFS . | xz -T0 -9 > $tarball " +run_cmd "tar -cp --posix --xattrs -C $ROOTFS . | xz -T${COMPRESSOR_THREADS:-0} -9 > $tarball " # Now that we have the tarball we don't need the rootfs anymore, so we # can get rid of it.