[yast-commit] r66991 - in /branches/SuSE-Code-11-SP1-Branch/bootloader: VERSION package/yast2-bootloader.changes src/modules/BootELILO.ycp
Author: snwint Date: Tue Dec 6 15:51:05 2011 New Revision: 66991 URL: http://svn.opensuse.org/viewcvs/yast?rev=66991&view=rev Log: - use elilo to handle efi boot menu entries (bnc #717828) Modified: branches/SuSE-Code-11-SP1-Branch/bootloader/VERSION branches/SuSE-Code-11-SP1-Branch/bootloader/package/yast2-bootloader.changes branches/SuSE-Code-11-SP1-Branch/bootloader/src/modules/BootELILO.ycp Modified: branches/SuSE-Code-11-SP1-Branch/bootloader/VERSION URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/bootloader/VERSION?rev=66991&r1=66990&r2=66991&view=diff ============================================================================== --- branches/SuSE-Code-11-SP1-Branch/bootloader/VERSION (original) +++ branches/SuSE-Code-11-SP1-Branch/bootloader/VERSION Tue Dec 6 15:51:05 2011 @@ -1 +1 @@ -2.17.83 +2.17.84 Modified: branches/SuSE-Code-11-SP1-Branch/bootloader/package/yast2-bootloader.changes URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/bootloader/package/yast2-bootloader.changes?rev=66991&r1=66990&r2=66991&view=diff ============================================================================== --- branches/SuSE-Code-11-SP1-Branch/bootloader/package/yast2-bootloader.changes (original) +++ branches/SuSE-Code-11-SP1-Branch/bootloader/package/yast2-bootloader.changes Tue Dec 6 15:51:05 2011 @@ -1,4 +1,9 @@ ------------------------------------------------------------------- +Tue Dec 6 15:49:53 CET 2011 - snwint@suse.de + +- use elilo to handle efi boot menu entries (bnc #717828) + +------------------------------------------------------------------- Mon Nov 14 17:11:14 CET 2011 - snwint@suse.de - ppc: use proper root device link (bnc #726607) Modified: branches/SuSE-Code-11-SP1-Branch/bootloader/src/modules/BootELILO.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-SP1-Branch/bootloader/src/modules/BootELILO.ycp?rev=66991&r1=66990&r2=66991&view=diff ============================================================================== --- branches/SuSE-Code-11-SP1-Branch/bootloader/src/modules/BootELILO.ycp (original) +++ branches/SuSE-Code-11-SP1-Branch/bootloader/src/modules/BootELILO.ycp Tue Dec 6 15:51:05 2011 @@ -470,156 +470,21 @@ return ret; } -/** bnc #438215 - YaST creates efibootloader entry twice - * Function convert number of partition to hexa - * - * @param any number of boot partition (10 or "10") - * @return string number boot partition in hexa ("a") - without "0x" - */ -string tomyhexa(any boot_part) -{ - string ret = "1000"; - - integer int_boot_part = tointeger(boot_part); - if (int_boot_part != nil) - { - string hexa = tohexstring(int_boot_part); - if (search(hexa, "x")!= nil) - { - list <string> hexa_without_0x = splitstring(hexa, "x"); - if (size(hexa_without_0x)>1) - ret = hexa_without_0x[1]:"1000"; - } - } - return ret; -} - -/** bnc #269198 change efi-label - * Function check if there exist same efi-label or different for - * same partition if efi-label is different delete it and create new one - * if it is same nothing to do it. +/** bnc #717828 + * Let elilo do all the efi label work. */ boolean updateEFILabel() { - boolean ret = true; - string cmd = ""; - map mp = Storage::GetMountPoints(); - string boot_dev = mp[getEfiMountPoint (), 0]:"/boot/efi"; - map splited = Storage::GetDiskPartition (boot_dev); - any boot_part = splited["nr"]:0; - any boot_disk = splited["disk"]:""; - - - // command for checking same boot entry in efi bnc #438215 (YaST creates efibootloader entry twice) - cmd = sformat("/usr/sbin/efibootmgr -v | grep -c \"%1.*HD(%2.*File(.\\efi.\\SuSE.\\elilo.efi)\"", - BootCommon::globals["boot_efilabel"]:"", tomyhexa(boot_part)); - - // check how many entries with same label and partition is actually in efi - y2milestone("run command %1", cmd); - map out = (map)SCR::Execute (.target.bash_output, cmd); - y2milestone("output of command %1", out); - - // check number of same boot entries in efi - // if boot entry is added -> don't add it again - if (deletechars(out["stdout"]:"","\n") != "0") - { - if (out["exit"]:0 == 0) - y2milestone("Skip adding new boot entry - EFI Label exist"); - else - y2error("Calling command %1 faild", cmd); - return ret; - - } else { - - cmd = sformat("/usr/sbin/efibootmgr -v | grep -c \"HD(%1.*File(.\\efi.\\SuSE.\\elilo.efi)\"", tomyhexa(boot_part)); - // check how many entries with same label and partition is actually in efi - y2milestone("run command %1", cmd); - map out = (map)SCR::Execute (.target.bash_output, cmd); - y2milestone("output of command %1", out); - - // check how many boot entries have same number of partitions - if (deletechars(out["stdout"]:"","\n") != "0") - { - // delete old boot entry - - cmd = sformat("efibootmgr -v |grep \"HD(%1.*File(.\\efi.\\SuSE.\\elilo.efi)\" | cut -d \" \" -f 1", - tomyhexa(boot_part)); - y2milestone("run command %1", cmd); - out = (map)SCR::Execute (.target.bash_output, cmd); - y2milestone("output of command %1", out); - - string boot_entries = out["stdout"]:""; - y2milestone("EFI boot entries with \"same\" boot partition %1",boot_entries); - - list<string> list_boot_entries = splitstring(boot_entries, "\n"); - - y2milestone("list_boot_entries=%1",list_boot_entries); - - foreach(string entry, list_boot_entries, - { - if ((deletechars(entry, "\n*") != "") && (deletechars(entry, "\n*") != nil)) - { - cmd = sformat("/usr/sbin/efibootmgr --delete-bootnum --bootnum %1 -q;", - substring (deletechars(entry, "\n*"),4, 4)); - y2milestone("run command %1", cmd); - out = (map)SCR::Execute (.target.bash_output, cmd); - y2milestone("output of command %1", out); - } - }); - - } - // add new boot entry - string bl_logfile = "/var/log/YaST2/y2log_bootloader"; - string bl_command = sformat ( "/usr/sbin/efibootmgr -v --create --label \"%1\" " + - "--disk %2 --part %3 " + - "--loader '\\efi\\SuSE\\elilo.efi' --write-signature >> %4 2>&1", - BootCommon::globals["boot_efilabel"]:"", boot_disk, boot_part, bl_logfile - ); - ret = ret && installBootLoader (bl_command, bl_logfile); - } - return ret; -} + // now elilo manages efi boot entries + string cmd = "/sbin/elilo --refresh-EBM"; + y2milestone("running command %1: %2", cmd, (map)SCR::Execute(.target.bash_output, cmd)); -/** FIXME: efibootmgr doesn't provide info about disk! - * bnc #450682 - adding boot entry to EFI - * function delete all existing boot entry with same name and partition number - * @param string name of label - * @param string number of partition - */ - -void deleteSameEFIBootEntry(string name, any part_no) -{ - - boolean still_exist = true; - - string cmd = sformat("efibootmgr -v |grep \"%1.*HD(%2.*File(.\\efi.\\SuSE.\\elilo.efi)\" | cut -d \" \" -f 1", - name, tomyhexa(part_no)); - y2milestone("run command %1", cmd); - map out = (map)SCR::Execute (.target.bash_output, cmd); - y2milestone("output of command %1", out); - - string boot_entries = out["stdout"]:""; - y2milestone("EFI boot entries with \"same\" boot partition %1",boot_entries); - - list<string> list_boot_entries = splitstring(boot_entries, "\n"); - - y2milestone("list_boot_entries=%1",list_boot_entries); - - foreach(string entry, list_boot_entries, - { - if ((deletechars(entry, "\n*") != "") && (deletechars(entry, "\n*") != nil)) - { - cmd = sformat("/usr/sbin/efibootmgr --delete-bootnum --bootnum %1 -q;", - substring (deletechars(entry, "\n*"),4, 4)); - y2milestone("run command %1", cmd); - out = (map)SCR::Execute (.target.bash_output, cmd); - y2milestone("output of command %1", out); - } - }); + return true; } + /** * Write bootloader settings to disk * @return boolean true on success @@ -639,157 +504,8 @@ computer, you need to load ELILO via the EFI shell."), 10); } - if (Mode::normal()) - updateEFILabel(); + if (ret) ret = updateEFILabel(); - if (BootCommon::location_changed || create_efi_entry) - { - map mp = Storage::GetMountPoints(); - string boot_dev = mp[getEfiMountPoint (), 0]:"/boot/efi"; - map splited = Storage::GetDiskPartition (boot_dev); - any boot_part = splited["nr"]:0; - any boot_disk = splited["disk"]:""; - y2milestone ("Disk: %1, Part: %2", boot_disk, boot_part); - - /* - * Create new EFI Bootmgr Label if specified - */ - if (BootCommon::globals["boot_efilabel"]:"" != "") - { - string bl_logfile = "/var/log/YaST2/y2log_bootloader"; - string bl_command = sformat ( - "/usr/sbin/efibootmgr -v --create --label \"%1\" " + - "--disk %2 --part %3 " + - "--loader '\\efi\\SuSE\\elilo.efi' --write-signature >> %4 2>&1", - BootCommon::globals["boot_efilabel"]:"", boot_disk, boot_part, bl_logfile - ); - - // command for checking same boot entry in efi bnc #438215 (YaST creates efibootloader entry twice) - string cmd = sformat("/usr/sbin/efibootmgr -v | grep -c \"%1.*HD(%2.*File(.\\efi.\\SuSE.\\elilo.efi)\"", - BootCommon::globals["boot_efilabel"]:"", tomyhexa(boot_part)); - y2milestone("Command for checking same boot entry: %1", cmd); - - // check how many entries with same label and partition is actually in efi - map out = (map)SCR::Execute (.target.bash_output, cmd); - - // check number of same boot entries in efi - // if boot entry is added -> don't add it again - if (deletechars(out["stdout"]:"","\n") == "0") - { - ret = ret && installBootLoader (bl_command, bl_logfile); - } else { - - if (added_label_to_efi) - { - y2milestone("Skip adding boot entry: %1 to EFI. There already exist and was added: %2 with - same label and partition.", BootCommon::globals["boot_efilabel"]:"", - deletechars(out["stdout"]:"","\n")); - } else { - // delete efi entry with same label name and partition - deleteSameEFIBootEntry(BootCommon::globals["boot_efilabel"]:"", boot_part); - // add new efi boot entry - ret = ret && installBootLoader (bl_command, bl_logfile); - } - - } - } - - - /* - * Remove existing old, obsolete menu entries - * - * FIXME should be handled completly through the library - */ - - // Detect the current default boot entry (e.g. "0007") - map default_entry_map = (map)SCR::Execute (.target.bash_output, - "/usr/sbin/efibootmgr |grep ^BootOrder: | " + - "cut -d ' ' -f 2 | cut -d ',' -f 1" - ); - string new_entry = default_entry_map["stdout"]:""; - - // Check for validity -- returned default_entry has to be 4 chars long - // and be composed of numbers and characters only - if (size (new_entry) != 4 - && regexpmatch (new_entry, "[0-9A-F]") == false) - { - y2error ("BootELILO: Found default boot entry %1 isn't valid", - new_entry); - } - else - { - // Remove newlines and carriage returns in string - new_entry = deletechars (new_entry, "\n\r"); - - // Attach prefix "Boot" for proper matching - new_entry = "Boot" + new_entry; - - // Prepare command for fetching string "HD(...)" - // from efibootmgr output - string command = sformat ( - "set -o pipefail; /usr/sbin/efibootmgr -v | " + - "grep '%1' |sed 's/%1.*\\(HD(.*)File(.*)\\).*/\\1/'", - String::Quote (new_entry) - ); - - map hd_descr_map = (map)SCR::Execute (.target.bash_output, command); - y2milestone ("BootELILO: hd_descr_map = %1", hd_descr_map); - - // Remove newlines and carriage returns in string - string hd_descr = deletechars (hd_descr_map["stdout"]:"", "\n\r"); - - // Prepare command for fetching boot entry number corresponding - // to "HD(...)" string from efibootmgr output - command = sformat ( - "set -o pipefail; /usr/sbin/efibootmgr -v |" + - "grep '%1' |awk '{print $1}'", - String::Quote (hd_descr) - ); - - map entries2remove_map = (map)SCR::Execute (.target.bash_output, command); - y2milestone ("BootELILO: entries2remove_map = %1", entries2remove_map); - string entries2remove_string = entries2remove_map["stdout"]:""; - - // Convert the string containing the entries to be removed to a list - list<string> entries2remove_list = splitstring (entries2remove_string, "\n"); - - // Check if there are entries to remove, thus if listsize is greater than 0 - integer listsize = size (entries2remove_list); - if (listsize > 0) - { - // Rermove the last entry of the list (because it's an empty one) - integer lastentry = listsize - 1; - entries2remove_list = remove (entries2remove_list, lastentry); - y2milestone ("BootELILO: entries2remove_list = %1", entries2remove_list); - - // Filter the bootnumbers from strings for further usage - entries2remove_list = maplist (string entry2remove, entries2remove_list, { - if (issubstring (entry2remove, new_entry) == false) - { - entry2remove = substring (entry2remove, 4, 4); - return entry2remove; - } - }); - - // Delete obsolete bootentries by bootnumbers - foreach (string entry2remove, entries2remove_list, { - string command = sformat ( - "/usr/sbin/efibootmgr --delete-bootnum --bootnum %1 -q;", - entry2remove - ); - - y2milestone ("Running command %1", command); - map ret_map = (map)SCR::Execute (.target.bash_output, command); - y2milestone ("BootELILO: ret_map = %1", ret_map); - ret = (ret_map["exit"]:1 == 0); - }); - } - else - { - y2milestone ("BootELILO: No obsolete entry to remove"); - } - } - } return ret; } -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
snwint@svn2.opensuse.org