[packages/efi-boot-update] Do not fail on modules with strange names

jajcus jajcus at pld-linux.org
Wed Oct 31 14:16:42 CET 2012


commit fff9d424f76be82e04535e871a20cb4a11bed026
Author: Jacek Konieczny <j.konieczny at eggsoft.pl>
Date:   Wed Oct 31 13:24:02 2012 +0100

    Do not fail on modules with strange names
    
    efi-boot-update would fail on /etc/efi-boot/update.d/grub-installed.conf
    because of the '-'

 efi-boot-update | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/efi-boot-update b/efi-boot-update
index 3acffd8..930e936 100755
--- a/efi-boot-update
+++ b/efi-boot-update
@@ -145,6 +145,10 @@ add_bootmgr_entry () {
     echo -n "$bootnum"
 }
 
+safe_string () {
+    echo -n "$*" | tr -c '[a-zA-Z0-9_]' '_'
+}
+
 FORCE_UPDATES="no"
 MOUNT_EFI_PARTITION="no"
 LABEL_PREFIX=""
@@ -257,7 +261,7 @@ for bootloader_conf in /etc/efi-boot/update.d/*.conf ; do
     install_files
     if [ -n "$BINARY" ] ; then
             bootnum="$(add_bootmgr_entry "$LABEL" "$BINARY" "$ARGS")"
-            eval "_${CONFIG_NAME}_bootnum=\"$bootnum\""
+            eval "_$(safe_string ${CONFIG_NAME})_bootnum=\"$bootnum\""
     fi
 done
 
@@ -266,9 +270,9 @@ if [ -n "$ORDER" -a "$EFIBOOTMGR" != "/bin/true" ] ; then
     tail="$($EFIBOOTMGR | awk '/^BootOrder:/ {gsub(/,/," ",$2); print $2}')"
     head=""
     for config_name in $ORDER ; do
-        eval "bootnum=\$_${config_name}_bootnum"
+        eval "bootnum=\$_$(safe_string ${config_name})_bootnum"
         if [ -z "$bootnum" ] ; then
-            msg "Cannot find '$config_name' config - won't add to boot order."
+            verbose "Cannot find '$config_name' config - won't add to boot order."
             continue
         fi
         tail="$(list_remove "$tail" "$bootnum")"
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/efi-boot-update.git/commitdiff/1ef784d842f20125b8e94b061bf718fdd27a036c



More information about the pld-cvs-commit mailing list