[Thincrust-devel] [PATCH] Install grub in chroot to ensure correct ld-linux libs used.

Marc Savy msavy at redhat.com
Fri Aug 3 14:16:15 UTC 2012


Install Grub using chroot so that it uses the ld-linux.so downloaded for
the *appliance* rather than using the *host's* ld-linux.so which may be
invalid (the wrong arch type, etc).

  From ce06bb9c95be57b4a3b4c88442e911d2404e5cee Mon Sep 17 00:00:00 2001
From: Marc Savy <msavy at redhat.com>
Date: Tue, 31 Jul 2012 16:03:18 +0100
Subject: [PATCH] Install grub in chroot to ensure correct ld-linux libs
used.
To: thincrust-devel at redhat.com

---
   appcreate/appliance.py | 9 +++++++--
   1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/appcreate/appliance.py b/appcreate/appliance.py
index f9fc784..1a13182 100644
--- a/appcreate/appliance.py
+++ b/appcreate/appliance.py
@@ -287,7 +287,7 @@ class ApplianceImageCreator(ImageCreator):
           # Ensure all data is flushed to disk before doing grub install
           subprocess.call(["sync"])

-        stage2 = self._instroot + "/boot/grub/stage2"
+        stage2 = "/boot/grub/stage2"
           setup = ""

           i = 0
@@ -301,15 +301,20 @@ class ApplianceImageCreator(ImageCreator):

           logging.debug("Installing grub to %s" % loopdev)

-        grub = subprocess.Popen([self._instroot + "/sbin/grub",
"--batch", "--no-floppy"],
+        subprocess.call(["mount", "--bind", "/dev", self._instroot +
"/dev"])
+
+        grub = subprocess.Popen(["chroot", self._instroot,
"/sbin/grub", "--batch", "--no-floppy"],
                                   stdin=subprocess.PIPE)

           grub.communicate(setup)
           rc = grub.wait()

           if rc != 0:
+            subprocess.call(["umount", self._instroot + "/dev"])
               raise MountError("Unable to install grub bootloader")

+        subprocess.call(["umount", self._instroot + "/dev"])
+
           logging.debug("Grub installed.")

       def _install_grub2(self):
-- 
1.7.11.3




-------------- next part --------------
From ce06bb9c95be57b4a3b4c88442e911d2404e5cee Mon Sep 17 00:00:00 2001
From: Marc Savy <msavy at redhat.com>
Date: Tue, 31 Jul 2012 16:03:18 +0100
Subject: [PATCH] Install grub in chroot to ensure correct ld-linux libs used.
To: thincrust-devel at redhat.com

---
 appcreate/appliance.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/appcreate/appliance.py b/appcreate/appliance.py
index f9fc784..1a13182 100644
--- a/appcreate/appliance.py
+++ b/appcreate/appliance.py
@@ -287,7 +287,7 @@ class ApplianceImageCreator(ImageCreator):
         # Ensure all data is flushed to disk before doing grub install
         subprocess.call(["sync"])
 
-        stage2 = self._instroot + "/boot/grub/stage2"
+        stage2 = "/boot/grub/stage2"
         setup = ""
        
         i = 0
@@ -301,15 +301,20 @@ class ApplianceImageCreator(ImageCreator):
 
         logging.debug("Installing grub to %s" % loopdev)
 
-        grub = subprocess.Popen([self._instroot + "/sbin/grub", "--batch", "--no-floppy"],
+        subprocess.call(["mount", "--bind", "/dev", self._instroot + "/dev"])
+
+        grub = subprocess.Popen(["chroot", self._instroot, "/sbin/grub", "--batch", "--no-floppy"], 
                                 stdin=subprocess.PIPE)
 
         grub.communicate(setup)
         rc = grub.wait()
 
         if rc != 0:
+            subprocess.call(["umount", self._instroot + "/dev"])
             raise MountError("Unable to install grub bootloader")
 
+        subprocess.call(["umount", self._instroot + "/dev"])
+
         logging.debug("Grub installed.")
 
     def _install_grub2(self):
-- 
1.7.11.3




More information about the Thincrust-devel mailing list