Gentoo Archives: gentoo-catalyst

From: Mike Frysinger <vapier@g.o>
To: gentoo-catalyst@l.g.o
Subject: [gentoo-catalyst] [PATCH 2/2] arch: add helper for working w/setarch
Date: Tue, 06 Oct 2015 17:57:02
Message-Id: 1444154214-3572-2-git-send-email-vapier@gentoo.org
In Reply to: [gentoo-catalyst] [PATCH 1/2] arch: hoist default CHROOT setting up by Mike Frysinger
1 The util-linux package has included setarch now for years, so there's
2 no need to check for the old linux32 program names.
3
4 Add a helper for setting up the chroot variable to the right target
5 that the arch wants. This can expand in the future for other arch
6 combos.
7 ---
8 catalyst/arch/powerpc.py | 5 +----
9 catalyst/arch/sparc.py | 5 +----
10 catalyst/arch/x86.py | 5 +----
11 catalyst/builder.py | 7 +++++++
12 4 files changed, 10 insertions(+), 12 deletions(-)
13
14 diff --git a/catalyst/arch/powerpc.py b/catalyst/arch/powerpc.py
15 index 0c4861f..d799544 100644
16 --- a/catalyst/arch/powerpc.py
17 +++ b/catalyst/arch/powerpc.py
18 @@ -10,10 +10,7 @@ class generic_ppc(builder.generic):
19 builder.generic.__init__(self,myspec)
20 self.settings["CHOST"]="powerpc-unknown-linux-gnu"
21 if self.settings["buildarch"]=="ppc64":
22 - if not os.path.exists("/bin/linux32") and not os.path.exists("/usr/bin/linux32"):
23 - raise CatalystError("required executable linux32 not found "
24 - "(\"emerge setarch\" to fix.)", print_traceback=True)
25 - self.settings["CHROOT"]="linux32 chroot"
26 + self.setarch('linux32')
27 self.settings["crosscompile"] = False
28
29 class generic_ppc64(builder.generic):
30 diff --git a/catalyst/arch/sparc.py b/catalyst/arch/sparc.py
31 index 39f50ca..1c4a803 100644
32 --- a/catalyst/arch/sparc.py
33 +++ b/catalyst/arch/sparc.py
34 @@ -9,10 +9,7 @@ class generic_sparc(builder.generic):
35 def __init__(self,myspec):
36 builder.generic.__init__(self,myspec)
37 if self.settings["buildarch"]=="sparc64":
38 - if not os.path.exists("/bin/linux32") and not os.path.exists("/usr/bin/linux32"):
39 - raise CatalystError("required executable linux32 not found "
40 - "(\"emerge setarch\" to fix.)", print_traceback=True)
41 - self.settings["CHROOT"]="linux32 chroot"
42 + self.setarch('linux32')
43 self.settings["crosscompile"] = False
44
45 class generic_sparc64(builder.generic):
46 diff --git a/catalyst/arch/x86.py b/catalyst/arch/x86.py
47 index 0d6a9ad..a4b2089 100644
48 --- a/catalyst/arch/x86.py
49 +++ b/catalyst/arch/x86.py
50 @@ -9,10 +9,7 @@ class generic_x86(builder.generic):
51 def __init__(self,myspec):
52 builder.generic.__init__(self,myspec)
53 if self.settings["buildarch"]=="amd64":
54 - if not os.path.exists("/bin/linux32") and not os.path.exists("/usr/bin/linux32"):
55 - raise CatalystError("required executable linux32 not found "
56 - "(\"emerge setarch\" to fix.)", print_traceback=True)
57 - self.settings["CHROOT"]="linux32 chroot"
58 + self.setarch('linux32')
59 self.settings["crosscompile"] = False
60
61 class arch_x86(generic_x86):
62 diff --git a/catalyst/builder.py b/catalyst/builder.py
63 index adaea90..7380cac 100644
64 --- a/catalyst/builder.py
65 +++ b/catalyst/builder.py
66 @@ -4,6 +4,13 @@ class generic(object):
67 self.settings=myspec
68 self.settings.setdefault('CHROOT', 'chroot')
69
70 + def setarch(self, arch):
71 + """Set the chroot wrapper to run through `setarch |arch|`
72 +
73 + Useful for building x86-on-amd64 and such.
74 + """
75 + self.settings['CHROOT'] = 'setarch %s %s' % (arch, self.settings['CHROOT'])
76 +
77 def mount_safety_check(self):
78 """
79 Make sure that no bind mounts exist in chrootdir (to use before
80 --
81 2.5.2