Author: juhliarik Date: Fri Dec 19 10:59:22 2008 New Revision: 54283 URL: http://svn.opensuse.org/viewcvs/yast?rev=54283&view=rev Log: added fix for changing EFI label in running system Modified: branches/SuSE-Code-11-Branch/bootloader/src/modules/BootELILO.ycp Modified: branches/SuSE-Code-11-Branch/bootloader/src/modules/BootELILO.ycp URL: http://svn.opensuse.org/viewcvs/yast/branches/SuSE-Code-11-Branch/bootloader/src/modules/BootELILO.ycp?rev=54283&r1=54282&r2=54283&view=diff ============================================================================== --- branches/SuSE-Code-11-Branch/bootloader/src/modules/BootELILO.ycp (original) +++ branches/SuSE-Code-11-Branch/bootloader/src/modules/BootELILO.ycp Fri Dec 19 10:59:22 2008 @@ -479,6 +479,95 @@ } +/** 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. + */ + +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; +} + + + /** * Write bootloader settings to disk * @return boolean true on success @@ -496,6 +585,9 @@ computer, you need to load ELILO via the EFI shell."), 10); } + if (Mode::normal()) + updateEFILabel(); + if (BootCommon::location_changed || create_efi_entry) { map mp = Storage::GetMountPoints(); -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org