From ad6e4800b29187f98df4392862976ea8a46261e4 Mon Sep 17 00:00:00 2001 From: Chris Gianelloni Date: Tue, 9 Jan 2007 14:53:52 +0000 Subject: [PATCH] Added a patch from Mike Frysinger to support cbuild. git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/catalyst/trunk@1206 d1e1f19c-881f-0410-ab34-b69fee027534 --- ChangeLog | 9 +++ arch/alpha.py | 1 - arch/amd64.py | 1 - arch/arm.py | 2 - arch/hppa.py | 1 - arch/ia64.py | 1 - arch/mips.py | 2 - arch/ppc.py | 4 +- arch/ppc64.py | 1 - arch/s390.py | 1 - arch/sh.py | 2 - arch/sparc.py | 4 +- arch/sparc64.py | 1 - arch/x86.py | 4 +- modules/generic_stage_target.py | 110 ++++++++++++++-------------- targets/netboot/netboot-combine.sh | 12 +-- targets/support/bootloader-setup.sh | 2 +- targets/support/create-iso.sh | 6 +- targets/support/functions.sh | 4 + targets/support/netboot2-final.sh | 2 +- targets/support/pre-kmerge.sh | 8 +- 21 files changed, 90 insertions(+), 88 deletions(-) diff --git a/ChangeLog b/ChangeLog index edc03fa9..beaa59ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,15 @@ # Copyright 2002-2007 Gentoo Foundation; Distributed under the GPL v2 # $Id: $ + 09 Jan 2007; Chris Gianelloni arch/alpha.py, + arch/amd64.py, arch/arm.py, arch/hppa.py, arch/ia64.py, arch/mips.py, + arch/ppc.py, arch/ppc64.py, arch/s390.py, arch/sh.py, arch/sparc.py, + arch/sparc64.py, arch/x86.py, modules/generic_stage_target.py, + targets/netboot/netboot-combine.sh, targets/support/bootloader-setup.sh, + targets/support/create-iso.sh, targets/support/functions.sh, + targets/support/netboot2-final.sh, targets/support/pre-kmerge.sh: + Added a patch from Mike Frysinger to support cbuild. + 02 Jan 2007; Chris Gianelloni README, arch/alpha.py, arch/amd64.py, arch/arm.py, arch/hppa.py, arch/ia64.py, arch/mips.py, arch/ppc.py, arch/ppc64.py, arch/s390.py, arch/sh.py, arch/sparc.py, diff --git a/arch/alpha.py b/arch/alpha.py index acc38270..49a265d2 100644 --- a/arch/alpha.py +++ b/arch/alpha.py @@ -6,7 +6,6 @@ class generic_alpha(builder.generic): "abstract base class for all alpha builders" def __init__(self,myspec): builder.generic.__init__(self,myspec) - self.settings["mainarch"]="alpha" self.settings["CHROOT"]="chroot" self.settings["CFLAGS"]="-mieee -pipe" diff --git a/arch/amd64.py b/arch/amd64.py index 1b1d08b3..b652df13 100644 --- a/arch/amd64.py +++ b/arch/amd64.py @@ -5,7 +5,6 @@ class generic_amd64(builder.generic): "abstract base class for all amd64 builders" def __init__(self,myspec): builder.generic.__init__(self,myspec) - self.settings["mainarch"]="amd64" self.settings["CHROOT"]="chroot" class arch_amd64(generic_amd64): diff --git a/arch/arm.py b/arch/arm.py index eb96dd6e..96125681 100644 --- a/arch/arm.py +++ b/arch/arm.py @@ -6,7 +6,6 @@ class generic_arm(builder.generic): "Abstract base class for all arm (little endian) builders" def __init__(self,myspec): builder.generic.__init__(self,myspec) - self.settings["mainarch"]="arm" self.settings["CHROOT"]="chroot" self.settings["CFLAGS"]="-O2 -pipe" self.settings["CXXFLAGS"]="-O1 -pipe" @@ -15,7 +14,6 @@ class generic_armeb(builder.generic): "Abstract base class for all arm (big endian) builders" def __init__(self,myspec): builder.generic.__init__(self,myspec) - self.settings["mainarch"]="arm" self.settings["CHROOT"]="chroot" self.settings["CFLAGS"]="-O2 -pipe" self.settings["CXXFLAGS"]="-O1 -pipe" diff --git a/arch/hppa.py b/arch/hppa.py index 0eb2ab6d..32b694bd 100644 --- a/arch/hppa.py +++ b/arch/hppa.py @@ -6,7 +6,6 @@ class generic_hppa(builder.generic): "Abstract base class for all hppa builders" def __init__(self,myspec): builder.generic.__init__(self,myspec) - self.settings["mainarch"]="hppa" self.settings["CHROOT"]="chroot" self.settings["CFLAGS"]="-O2 -pipe" self.settings["CXXFLAGS"]="-O2 -pipe" diff --git a/arch/ia64.py b/arch/ia64.py index 70a028ae..64433209 100644 --- a/arch/ia64.py +++ b/arch/ia64.py @@ -6,7 +6,6 @@ class arch_ia64(builder.generic): "builder class for ia64" def __init__(self,myspec): builder.generic.__init__(self,myspec) - self.settings["mainarch"]="ia64" self.settings["CHROOT"]="chroot" self.settings["CFLAGS"]="-O2 -pipe" self.settings["CFLAGS"]="-O2 -pipe" diff --git a/arch/mips.py b/arch/mips.py index aa72e026..f52d4db0 100644 --- a/arch/mips.py +++ b/arch/mips.py @@ -6,7 +6,6 @@ class generic_mips(builder.generic): "Abstract base class for all mips builders [Big-endian]" def __init__(self,myspec): builder.generic.__init__(self,myspec) - self.settings["mainarch"]="mips" self.settings["CHROOT"]="chroot" self.settings["CHOST"]="mips-unknown-linux-gnu" @@ -14,7 +13,6 @@ class generic_mipsel(builder.generic): "Abstract base class for all mipsel builders [Little-endian]" def __init__(self,myspec): builder.generic.__init__(self,myspec) - self.settings["mainarch"]="mips" self.settings["CHROOT"]="chroot" self.settings["CHOST"]="mipsel-unknown-linux-gnu" diff --git a/arch/ppc.py b/arch/ppc.py index c774434f..3968dd10 100644 --- a/arch/ppc.py +++ b/arch/ppc.py @@ -11,12 +11,12 @@ class generic_ppc(builder.generic): "abstract base class for all ppc builders" def __init__(self,myspec): builder.generic.__init__(self,myspec) - self.settings["mainarch"]="ppc" self.settings["CHOST"]="powerpc-unknown-linux-gnu" - if self.settings["hostarch"]=="ppc64": + if self.settings["buildarch"]=="ppc64": if not os.path.exists("/bin/linux32"): raise CatalystError,"required /bin/linux32 executable not found (\"emerge setarch\" to fix." self.settings["CHROOT"]="linux32 chroot" + self.settings["crosscompile"] = False; else: self.settings["CHROOT"]="chroot" diff --git a/arch/ppc64.py b/arch/ppc64.py index e2cabe38..709ebaa3 100644 --- a/arch/ppc64.py +++ b/arch/ppc64.py @@ -5,7 +5,6 @@ class generic_ppc64(builder.generic): "abstract base class for all ppc64 builders" def __init__(self,myspec): builder.generic.__init__(self,myspec) - self.settings["mainarch"]="ppc64" self.settings["CHROOT"]="chroot" class arch_ppc64(generic_ppc64): diff --git a/arch/s390.py b/arch/s390.py index ee58e3fd..1c218048 100644 --- a/arch/s390.py +++ b/arch/s390.py @@ -6,7 +6,6 @@ class generic_s390(builder.generic): "abstract base class for all s390 builders" def __init__(self,myspec): builder.generic.__init__(self,myspec) - self.settings["mainarch"]="s390" self.settings["CHROOT"]="chroot" class arch_s390(generic_s390): diff --git a/arch/sh.py b/arch/sh.py index 473568b5..dc5fbc18 100644 --- a/arch/sh.py +++ b/arch/sh.py @@ -6,14 +6,12 @@ class generic_sh(builder.generic): "Abstract base class for all sh builders [Little-endian]" def __init__(self,myspec): builder.generic.__init__(self,myspec) - self.settings["mainarch"]="sh" self.settings["CHROOT"]="chroot" class generic_sheb(builder.generic): "Abstract base class for all sheb builders [Big-endian]" def __init__(self,myspec): builder.generic.__init__(self,myspec) - self.settings["mainarch"]="sh" self.settings["CHROOT"]="chroot" class arch_sh(generic_sh): diff --git a/arch/sparc.py b/arch/sparc.py index d0449049..d3f311f9 100644 --- a/arch/sparc.py +++ b/arch/sparc.py @@ -6,11 +6,11 @@ class generic_sparc(builder.generic): "abstract base class for all sparc builders" def __init__(self,myspec): builder.generic.__init__(self,myspec) - self.settings["mainarch"]="sparc" - if self.settings["hostarch"]=="sparc64": + if self.settings["buildarch"]=="sparc64": if not os.path.exists("/bin/linux32"): raise CatalystError,"required /bin/linux32 executable not found (\"emerge setarch\" to fix.)" self.settings["CHROOT"]="linux32 chroot" + self.settings["crosscompile"] = False; else: self.settings["CHROOT"]="chroot" diff --git a/arch/sparc64.py b/arch/sparc64.py index c94b43ee..d72da92a 100644 --- a/arch/sparc64.py +++ b/arch/sparc64.py @@ -6,7 +6,6 @@ class generic_sparc64(builder.generic): "abstract base class for all sparc64 builders" def __init__(self,myspec): builder.generic.__init__(self,myspec) - self.settings["mainarch"]="sparc64" self.settings["CHROOT"]="chroot" class arch_sparc64(generic_sparc64): diff --git a/arch/x86.py b/arch/x86.py index bab9dbe2..4b675e22 100644 --- a/arch/x86.py +++ b/arch/x86.py @@ -6,11 +6,11 @@ class generic_x86(builder.generic): "abstract base class for all x86 builders" def __init__(self,myspec): builder.generic.__init__(self,myspec) - self.settings["mainarch"]="x86" - if self.settings["hostarch"]=="amd64": + if self.settings["buildarch"]=="amd64": if not os.path.exists("/bin/linux32"): raise CatalystError,"required /bin/linux32 executable not found (\"emerge setarch\" to fix.)" self.settings["CHROOT"]="linux32 chroot" + self.settings["crosscompile"] = False; else: self.settings["CHROOT"]="chroot" diff --git a/modules/generic_stage_target.py b/modules/generic_stage_target.py index 01775834..1bd15997 100644 --- a/modules/generic_stage_target.py +++ b/modules/generic_stage_target.py @@ -17,40 +17,21 @@ class generic_stage_target(generic_target): self.valid_values.extend(["version_stamp","target","subarch",\ "rel_type","profile","snapshot","source_subpath","portage_confdir",\ - "cflags","cxxflags","ldflags","chost","hostuse","portage_overlay",\ + "cflags","cxxflags","ldflags","cbuild","chost","hostuse","portage_overlay",\ "distcc_hosts","makeopts","pkgcache_path","kerncache_path"]) self.set_valid_build_kernel_vars(addlargs) generic_target.__init__(self,myspec,addlargs) - # map the mainarch we are running under to the mainarches we support for - # building stages and LiveCDs. (for example, on amd64, we can build - # stages for x86 or amd64. - targetmap={ - "x86" : ["x86"], - "amd64" : ["x86","amd64"], - "sparc64" : ["sparc","sparc64"], - "ia64" : ["ia64"], - "alpha" : ["alpha"], - "sparc" : ["sparc"], - "sh" : ["sh"], - "s390" : ["s390"], - "ppc" : ["ppc"], - "ppc64" : ["ppc","ppc64"], - "hppa" : ["hppa"], - "mips" : ["mips"], - "arm" : ["arm"] - } - - machinemap={ + machinemap={ "i386" : "x86", "i486" : "x86", "i586" : "x86", "i686" : "x86", "x86_64" : "amd64", + "sparc" : "sparc", "sparc64" : "sparc64", "ia64" : "ia64", "alpha" : "alpha", - "sparc" : "sparc", "sh2" : "sh", "sh3" : "sh", "sh4" : "sh", @@ -60,8 +41,12 @@ class generic_stage_target(generic_target): "s390" : "s390", "ppc" : "ppc", "ppc64" : "ppc64", - "parisc" : "hppa", - "parisc64" : "hppa", + "powerpc" : "powerpc", + "powerpc64" : "powerpc64", + "parisc" : "parisc", + "parisc64" : "parisc", + "hppa" : "hppa", + "hppa64" : "hppa", "mips" : "mips", "mips64" : "mips", "arm" : "arm", @@ -70,31 +55,38 @@ class generic_stage_target(generic_target): "armv5b" : "arm" } - mymachine=os.uname()[4] - if not machinemap.has_key(mymachine): - raise CatalystError, "Unknown machine type "+mymachine - - self.settings["hostarch"]=machinemap[mymachine] - self.archmap={} - self.subarchmap={} + if self.settings.has_key("chost"): + hostmachine = self.settings["chost"].split("-")[0] + else: + hostmachine = os.uname()[4] + if not machinemap.has_key(hostmachine): + raise CatalystError, "Unknown host machine type "+hostmachine + self.settings["hostarch"] = machinemap[hostmachine] + if self.settings.has_key("cbuild"): + buildmachine = self.settings["cbuild"].split("-")[0] + else: + buildmachine = os.uname()[4] + if not machinemap.has_key(buildmachine): + raise CatalystError, "Unknown build machine type "+buildmachine + self.settings["buildarch"] = machinemap[buildmachine] + self.settings["crosscompile"] = (self.settings["hostarch"] != self.settings["buildarch"]) + self.archmap = {} + self.subarchmap = {} - for x in targetmap[self.settings["hostarch"]]: - try: - fh=open(self.settings["sharedir"]+"/arch/"+x+".py") - # This next line loads the plugin as a module and assigns it to - # archmap[x] - self.archmap[x]=imp.load_module(x,fh,"arch/"+x+".py",(".py","r",imp.PY_SOURCE)) - # This next line registers all the subarches supported in the - # plugin - self.archmap[x].register(self.subarchmap) - fh.close() - - except IOError: - msg("Can't find "+x+".py plugin in "+self.settings["sharedir"]+"/arch/") + x = self.settings["hostarch"] + try: + fh = open(self.settings["sharedir"]+"/arch/"+x+".py") + # this next line loads the plugin as a module and assigns it to archmap[x] + self.archmap[x] = imp.load_module(x,fh,"arch/"+x+".py",(".py","r",imp.PY_SOURCE)) + # this next line registers all the subarches supported in the plugin + self.archmap[x].register(self.subarchmap) + fh.close() + except IOError: + msg("Can't find "+x+".py plugin in "+self.settings["sharedir"]+"/arch/") # Call arch constructor, pass our settings try: self.arch=self.subarchmap[self.settings["subarch"]](self.settings) - except: + except: print "Invalid subarch: "+self.settings["subarch"] print "Choose one of the following:", for x in self.subarchmap: @@ -103,14 +95,16 @@ class generic_stage_target(generic_target): sys.exit(2) print "Using target:",self.settings["target"] - # self.settings["mainarch"] should now be set by our arch constructor, - # so we print a nice informational message: - if self.settings["mainarch"]==self.settings["hostarch"]: + # print a nice informational message: + if self.settings["buildarch"]==self.settings["hostarch"]: print "Building natively for",self.settings["hostarch"] - + elif self.settings["crosscompile"]: + print "Cross-compiling on",self.settings["buildarch"],"for different machine type",\ + self.settings["hostarch"] else: - print "Building on",self.settings["hostarch"],"for alternate machine type",\ - self.settings["mainarch"] + print "Building on",self.settings["buildarch"],"for alternate personality type",\ + self.settings["hostarch"] + # This should be first to be set as other set_ options depend on this self.set_spec_prefix() @@ -204,6 +198,10 @@ class generic_stage_target(generic_target): # for the chroot: self.env["CCACHE_DIR"]="/var/tmp/ccache" + def override_cbuild(self): + if self.makeconf.has_key("CBUILD"): + self.settings["CBUILD"]=self.makeconf["CBUILD"] + def override_chost(self): if self.makeconf.has_key("CHOST"): self.settings["CHOST"]=self.makeconf["CHOST"] @@ -831,7 +829,8 @@ class generic_stage_target(generic_target): def chroot_setup(self): self.makeconf=read_makeconf(self.settings["chroot_path"]+"/etc/make.conf") - self.override_chost() + self.override_cbuild() + self.override_chost() self.override_cflags() self.override_cxxflags() self.override_ldflags() @@ -868,7 +867,8 @@ class generic_stage_target(generic_target): cmd("mv "+self.settings["chroot_path"]+"/etc/hosts "+self.settings["chroot_path"]+\ "/etc/hosts.bck", "Could not backup /etc/hosts",env=self.env) cmd("cp /etc/hosts "+self.settings["chroot_path"]+"/etc/hosts", "Could not copy /etc/hosts",env=self.env) - #self.override_chost() + #self.override_cbuild() + #self.override_chost() #self.override_cflags() #self.override_cxxflags() #self.override_ldflags() @@ -887,6 +887,8 @@ class generic_stage_target(generic_target): if self.settings.has_key("LDFLAGS"): myf.write('LDFLAGS="'+self.settings["LDFLAGS"]+'"\n') myf.write("# This should not be changed unless you know exactly what you are doing. You\n# should probably be using a different stage, instead.\n") + if self.settings.has_key("CBUILD"): + myf.write('CBUILD="'+self.settings["CBUILD"]+'"\n') myf.write('CHOST="'+self.settings["CHOST"]+'"\n') # Figure out what our USE vars are for building @@ -1077,7 +1079,7 @@ class generic_stage_target(generic_target): self.purge() for x in self.settings["action_sequence"]: - print "Running action sequence: "+x + print "--- Running action sequence: "+x sys.stdout.flush() try: apply(getattr(self,x)) diff --git a/targets/netboot/netboot-combine.sh b/targets/netboot/netboot-combine.sh index 7663f5b8..df5d49b2 100644 --- a/targets/netboot/netboot-combine.sh +++ b/targets/netboot/netboot-combine.sh @@ -14,7 +14,7 @@ export FEATURES="${clst_myfeatures}" # First install the boot package that we need booter="" -case ${clst_mainarch} in +case ${clst_hostarch} in alpha) booter="" ;; @@ -50,7 +50,7 @@ do create_normal_loop ${clst_chroot_path}/tmp/staging/initrd-${kname} ${clst_target_path} initrd-${kname}.igz rm -r ${clst_chroot_path}/tmp/staging/initrd-${kname} - case ${clst_mainarch} in + case ${clst_hostarch} in alpha) # Until aboot is patched this is broken currently. # please use catalyst 1.1.5 or older @@ -92,10 +92,10 @@ do ;; sparc*) #TEST TEST TEST TEST - #elftoaout -o /netboot-${kname}.${clst_mainarch} /usr/src/linux/vmlinux - #elftoaout -o /netboot-${kname}.${clst_mainarch} /${kname} - #piggy=${clst_mainarch/sparc/piggyback} - #${piggy} /netboot-${kname}.${clst_mainarch} /usr/src/linux/System.map /initrd-${kname}.igz + #elftoaout -o /netboot-${kname}.${clst_hostarch} /usr/src/linux/vmlinux + #elftoaout -o /netboot-${kname}.${clst_hostarch} /${kname} + #piggy=${clst_hostarch/sparc/piggyback} + #${piggy} /netboot-${kname}.${clst_hostarch} /usr/src/linux/System.map /initrd-${kname}.igz ;; x86) mknbi-linux \ diff --git a/targets/support/bootloader-setup.sh b/targets/support/bootloader-setup.sh index 028565fa..5377c8c1 100755 --- a/targets/support/bootloader-setup.sh +++ b/targets/support/bootloader-setup.sh @@ -12,7 +12,7 @@ check_filesystem_type default_append_line="root=/dev/ram0 init=/linuxrc ${cmdline_opts} ${custom_kopts} cdroot" -case ${clst_mainarch} in +case ${clst_hostarch} in alpha) # NO SOFTLEVEL SUPPORT YET acfg=$1/etc/aboot.conf diff --git a/targets/support/create-iso.sh b/targets/support/create-iso.sh index 9d2062e3..1999668f 100755 --- a/targets/support/create-iso.sh +++ b/targets/support/create-iso.sh @@ -6,7 +6,7 @@ ## START RUNSCRIPT # Check for our CD ISO creation tools -case ${clst_mainarch} in +case ${clst_hostarch} in mips) cdmaker="sgibootcd" cdmakerpkg="sys-boot/sgibootcd" @@ -27,7 +27,7 @@ if [ -z "${clst_iso_volume_id}" ] then case ${clst_livecd_type} in gentoo-*) - case ${clst_mainarch} in + case ${clst_hostarch} in alpha) clst_iso_volume_id="Gentoo Linux - Alpha" ;; @@ -75,7 +75,7 @@ then fi # Here we actually create the ISO images for each architecture -case ${clst_mainarch} in +case ${clst_hostarch} in alpha) case ${clst_fstype} in zisofs) diff --git a/targets/support/functions.sh b/targets/support/functions.sh index 18984d28..34bd98b4 100755 --- a/targets/support/functions.sh +++ b/targets/support/functions.sh @@ -211,3 +211,7 @@ check_filesystem_type(){ ;; esac } + +run_crossdev() { + crossdev ${clst_CHOST} +} diff --git a/targets/support/netboot2-final.sh b/targets/support/netboot2-final.sh index dbe56f48..48a67472 100755 --- a/targets/support/netboot2-final.sh +++ b/targets/support/netboot2-final.sh @@ -20,7 +20,7 @@ rmdir ${clst_target_path}boot # Any post-processing necessary for each architecture can be done here. This # may include things like sparc's elftoaout, x86's PXE boot, etc. -case ${clst_mainarch} in +case ${clst_hostarch} in alpha) sleep 0 ;; diff --git a/targets/support/pre-kmerge.sh b/targets/support/pre-kmerge.sh index 3503ab49..2b7544ff 100755 --- a/targets/support/pre-kmerge.sh +++ b/targets/support/pre-kmerge.sh @@ -13,7 +13,7 @@ case ${clst_target} in # Setup case structure for livecd_type case ${clst_livecd_type} in gentoo-release-minimal | gentoo-release-universal) - case ${clst_mainarch} in + case ${clst_hostarch} in amd64|x86) sed -i 's/initramfs_data.cpio.gz /initramfs_data.cpio.gz -r 1024x768 /' /usr/share/genkernel/genkernel ;; @@ -32,14 +32,14 @@ case ${clst_target} in sed -e "s/@@MYDATE@@/${clst_netboot2_builddate}/g" \ -e "s/@@RELVER@@/${clst_version_stamp}/g" \ ${clst_root_path}usr/share/genkernel/netboot/linuxrc.x \ - > ${clst_root_path}usr/share/genkernel/${clst_mainarch}/linuxrc + > ${clst_root_path}usr/share/genkernel/${clst_hostarch}/linuxrc echo ">>> Copying support files to ${clst_root_path} ..." cp -pPRf ${clst_root_path}usr/share/genkernel/netboot/misc/* \ ${clst_merge_path} echo ">>> Copying busybox config ..." - cp -f ${clst_root_path}usr/share/genkernel/${clst_mainarch}/nb-busybox.cf \ - ${clst_root_path}usr/share/genkernel/${clst_mainarch}/busy-config + cp -f ${clst_root_path}usr/share/genkernel/${clst_hostarch}/nb-busybox.cf \ + ${clst_root_path}usr/share/genkernel/${clst_hostarch}/busy-config ;; esac -- 2.26.2