From d8a0e13261f8df2b963f0f96085c8ceaad654309 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Andr=C3=A9?= Date: Fri, 16 Oct 2015 11:11:14 +0900 Subject: [PATCH] Fix uniqueness check of initrd in fedora-minimal The check suffered from various flaws. First, due to missing quotes around $initrd, 'wc -l' would always see 1 line no matter how many results the find returned. Second, echo adds a line break making 'wc -l' count 1 even for empty string. We need to add a check for empty string. Change-Id: Ib2c67960f566dbdc471d9585a4cef1beb1cc38ab Closes-Bug: #1506692 --- elements/fedora-minimal/install.d/99-ramdisk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/elements/fedora-minimal/install.d/99-ramdisk b/elements/fedora-minimal/install.d/99-ramdisk index b6eff7c9d..e8d8ba700 100755 --- a/elements/fedora-minimal/install.d/99-ramdisk +++ b/elements/fedora-minimal/install.d/99-ramdisk @@ -9,7 +9,7 @@ set -o pipefail initrd=$(find /boot -name initrd) kernel_version=$(rpm -qa | grep kernel | sort | head -n 1 | cut -d '-' -f 2,3) -if [ "$(echo $initrd | wc -l)" -eq 1 ]; then +if [ -n "$initrd" -a $(echo "$initrd" | wc -l) -eq 1 ]; then cp $initrd /boot/initrd-$kernel_version.img else echo "Zero or multiple initrds found. This should not happen."