[PATCH] The boot menu entry should contain the RHEL major release number (#1001960)

Martin Kolman mkolman at redhat.com
Wed Jun 18 09:11:47 UTC 2014


Make Grub and Efi write the menu entry with the major version
suffix and modify the related code to handle entries that contain
the suffix as well as the current entries without the suffix.

Signed-off-by: Martin Kolman <mkolman at redhat.com>
---
 booty/bootloaderInfo.py | 24 ++++++++++++++++++------
 booty/x86.py            |  5 ++---
 product.py              |  4 ++++
 3 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/booty/bootloaderInfo.py b/booty/bootloaderInfo.py
index 5d76733..73fec05 100644
--- a/booty/bootloaderInfo.py
+++ b/booty/bootloaderInfo.py
@@ -287,7 +287,11 @@ class BootImages:
             self.default = storage.rootDevice.name
             (label, longlabel, type) = self.images[self.default]
             if not label:
-                self.images[self.default] = ("linux", productName, type)
+                # use the productNameMajorVersion as distribution name
+                # so that users can discern which major version of RHEL
+                # the given entry is (for example if there is RHEL5 or 7
+                # on the machine and in the boot menu)
+                self.images[self.default] = ("linux", productNameMajorVersion, type)
 
     # Return a list of (storage.Device, string) tuples that are bootable
     # devices.  The string is the type of the device, which is just a string
@@ -661,7 +665,8 @@ class efiBootloaderInfo(bootloaderInfo):
             fields = string.split(line)
             if len(fields) < 2:
                 continue
-            if string.join(fields[1:], " ") == productName:
+            potential_efi_product_name = " ".join(fields[1:])
+            if potential_efi_product_name in (productName, productNameMajorVersion):
                 entry = fields[0][4:8]
                 rc = iutil.execWithRedirect('efibootmgr',
                                             ["-b", entry, "-B"],
@@ -705,7 +710,7 @@ class efiBootloaderInfo(bootloaderInfo):
 
         for d in bootdevlist:
             argv = [ "efibootmgr", "-c" , "-w", "-L",
-                     productName, "-d", "%s" % (d.path,),
+                     productNameMajorVersion, "-d", "%s" % (d.path,),
                      "-p", "%s" % (bootpart,),
                      "-l", "\\EFI\\redhat\\" + self.bootloader ]
             rc = iutil.execWithRedirect(argv[0], argv[1:], root = instRoot,
@@ -715,7 +720,7 @@ class efiBootloaderInfo(bootloaderInfo):
         # return last rc, the API doesn't provide anything better than this
         return rc
 
-    def getEfiProductPath(self, productName, force=False):
+    def getEfiProductPath(self, force=False):
         """ Return the full EFI path of the installed product.
             eg. HD(4,2c8800,64000,902c1655-2677-4455-b2a5-29d0ce835610)
 
@@ -733,8 +738,15 @@ class efiBootloaderInfo(bootloaderInfo):
             line = line.strip()
             if not line:
                 continue
-            if productName in line:
-                efiProductPath = line[line.rfind(productName)+len(productName):].strip()
+            if productNameMajorVersion in line:
+                name_start_index = line.rfind(productNameMajorVersion)
+                name_offset = len(productNameMajorVersion)
+                efiProductPath = line[name_start_index + name_offset:].strip()
+                break
+            elif productName in line:
+                name_start_index = line.rfind(productName)
+                name_offset = len(productName)
+                efiProductPath = line[name_start_index + name_offset:].strip()
                 break
 
         if efiProductPath:
diff --git a/booty/x86.py b/booty/x86.py
index a753201..90540c5 100644
--- a/booty/x86.py
+++ b/booty/x86.py
@@ -279,11 +279,10 @@ class x86BootloaderInfo(efiBootloaderInfo):
         f.write("#boot=/dev/%s\n" % (grubTarget))
 
         if iutil.isEfi():
-            from product import productName
             # Map the target device to the full EFI path
-            if self.getEfiProductPath(productName):
+            if self.getEfiProductPath():
                 (n, pn) = getDiskPart(bootDevs[0], self.storage)
-                f.write("device (%s) %s\n" % (self.grubbyDiskName(n), self.getEfiProductPath(productName)))
+                f.write("device (%s) %s\n" % (self.grubbyDiskName(n), self.getEfiProductPath()))
 
         # get the default image to boot... we have to walk and find it
         # since grub indexes by where it is in the config file
diff --git a/product.py b/product.py
index 3031f96..6702b06 100644
--- a/product.py
+++ b/product.py
@@ -32,6 +32,7 @@ else:
 productStamp = ""
 productName = "anaconda"
 productVersion = "bluesky"
+productNameMajorVersion = "anaconda bluesky"
 productPath = "Packages"
 productArch = None
 bugUrl = "your distribution provided bug reporting tool."
@@ -46,6 +47,9 @@ if path is not None:
         productArch = productStamp[productStamp.index(".")+1:]
         productName = lines[1][:-1]
         productVersion = lines[2][:-1]
+        versionSplit = productVersion.split(".")
+        if len(versionSplit):
+            productNameMajorVersion = "%s %s" % (productName, versionSplit[0])
 
         # set productIsFinal
         isfinal = lines[3].strip().lower()
-- 
1.9.3



More information about the anaconda-patches mailing list