ソースを参照

Speed up initrd compression (closes #25)

Other: Use printf instead of echo for error and warning
Bohan Yang 4 年 前
コミット
1f5d2e07ec
1 ファイル変更9 行追加6 行削除
  1. 9 6
      debi.sh

+ 9 - 6
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