The util-linux package has included setarch now for years, so there's
no need to check for the old linux32 program names.

Add a helper for setting up the chroot variable to the right target
that the arch wants.  This can expand in the future for other arch
combos.
---
 catalyst/arch/powerpc.py | 5 +----
 catalyst/arch/sparc.py   | 5 +----
 catalyst/arch/x86.py     | 5 +----
 catalyst/builder.py      | 7 +++++++
 4 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/catalyst/arch/powerpc.py b/catalyst/arch/powerpc.py
index 0c4861f..d799544 100644
--- a/catalyst/arch/powerpc.py
+++ b/catalyst/arch/powerpc.py
@@ -10,10 +10,7 @@ class generic_ppc(builder.generic):
                builder.generic.__init__(self,myspec)
                self.settings["CHOST"]="powerpc-unknown-linux-gnu"
                if self.settings["buildarch"]=="ppc64":
-                       if not os.path.exists("/bin/linux32") and not 
os.path.exists("/usr/bin/linux32"):
-                               raise CatalystError("required executable 
linux32 not found "
-                                       "(\"emerge setarch\" to fix.)", 
print_traceback=True)
-                       self.settings["CHROOT"]="linux32 chroot"
+                       self.setarch('linux32')
                        self.settings["crosscompile"] = False
 
 class generic_ppc64(builder.generic):
diff --git a/catalyst/arch/sparc.py b/catalyst/arch/sparc.py
index 39f50ca..1c4a803 100644
--- a/catalyst/arch/sparc.py
+++ b/catalyst/arch/sparc.py
@@ -9,10 +9,7 @@ class generic_sparc(builder.generic):
        def __init__(self,myspec):
                builder.generic.__init__(self,myspec)
                if self.settings["buildarch"]=="sparc64":
-                       if not os.path.exists("/bin/linux32") and not 
os.path.exists("/usr/bin/linux32"):
-                               raise CatalystError("required executable 
linux32 not found "
-                                       "(\"emerge setarch\" to fix.)", 
print_traceback=True)
-                       self.settings["CHROOT"]="linux32 chroot"
+                       self.setarch('linux32')
                        self.settings["crosscompile"] = False
 
 class generic_sparc64(builder.generic):
diff --git a/catalyst/arch/x86.py b/catalyst/arch/x86.py
index 0d6a9ad..a4b2089 100644
--- a/catalyst/arch/x86.py
+++ b/catalyst/arch/x86.py
@@ -9,10 +9,7 @@ class generic_x86(builder.generic):
        def __init__(self,myspec):
                builder.generic.__init__(self,myspec)
                if self.settings["buildarch"]=="amd64":
-                       if not os.path.exists("/bin/linux32") and not 
os.path.exists("/usr/bin/linux32"):
-                               raise CatalystError("required executable 
linux32 not found "
-                                       "(\"emerge setarch\" to fix.)", 
print_traceback=True)
-                       self.settings["CHROOT"]="linux32 chroot"
+                       self.setarch('linux32')
                        self.settings["crosscompile"] = False
 
 class arch_x86(generic_x86):
diff --git a/catalyst/builder.py b/catalyst/builder.py
index adaea90..7380cac 100644
--- a/catalyst/builder.py
+++ b/catalyst/builder.py
@@ -4,6 +4,13 @@ class generic(object):
                self.settings=myspec
                self.settings.setdefault('CHROOT', 'chroot')
 
+       def setarch(self, arch):
+               """Set the chroot wrapper to run through `setarch |arch|`
+
+               Useful for building x86-on-amd64 and such.
+               """
+               self.settings['CHROOT'] = 'setarch %s %s' % (arch, 
self.settings['CHROOT'])
+
        def mount_safety_check(self):
                """
                Make sure that no bind mounts exist in chrootdir (to use before
-- 
2.5.2


Reply via email to