From 1f5d2e07ec668970de889f3d683a393de07115a9 Mon Sep 17 00:00:00 2001 From: Bohan Yang Date: Sat, 4 Sep 2021 20:10:28 +0800 Subject: [PATCH] Speed up initrd compression (closes #25) Other: Use printf instead of echo for error and warning --- debi.sh | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/debi.sh b/debi.sh index 5164499..aa67a0a 100755 --- a/debi.sh +++ b/debi.sh @@ -4,10 +4,15 @@ set -eu err() { - echo "\nError: $1.\n" 1>&2 + printf "\nError: %s.\n" "$1" 1>&2 exit 1 } +warn() { + printf "\nWarning: %s.\nContinuing with the default...\n" "$1" 1>&2 + sleep 5 +} + command_exists() { command -v "$1" > /dev/null 2>&1 } @@ -145,8 +150,7 @@ has_cloud_kernel() { esac local tmp; tmp=''; [ "$bpo_kernel" = true ] && tmp='-backports' - echo "\nWarning: No cloud kernel is available for $architecture/$suite$tmp.\nContinuing with the default...\n" 1>&2 - sleep 5 + warn "No cloud kernel is available for $architecture/$suite$tmp" return 1 } @@ -156,8 +160,7 @@ has_backports() { stretch|oldoldstable|buster|oldstable|bullseye|stable|bookworm|testing) return esac - echo "\nWarning: No backports kernel is available for $suite.\nContinuing with the default...\n" 1>&2 - sleep 5 + warn "No backports kernel is available for $suite" return 1 } @@ -715,7 +718,7 @@ save_grub_cfg='cat' gzip -d initrd.gz # cpio reads a list of file names from the standard input echo preseed.cfg | cpio -o -H newc -A -F initrd - gzip -9 initrd + gzip -1 initrd mkdir -p /etc/default/grub.d tee /etc/default/grub.d/zz-debi.cfg 1>&2 << EOF