public inbox for gentoo-catalyst@lists.gentoo.org
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: gentoo-catalyst@gentoo.org
Subject: [gentoo-catalyst] [rfc] laying groundwork for cbuild
Date: Sun, 31 Dec 2006 10:09:09 -0500	[thread overview]
Message-ID: <200612311009.10004.vapier@gentoo.org> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 178 bytes --]

attached patch redoes all of the logic for handling of chost and personality 
builds and inserts cbuild in all the right places

any qualms before i take it further ?
-mike

[-- Attachment #1.2: Type: application/pgp-signature, Size: 827 bytes --]

[-- Attachment #2: catalyst-cbuild.patch --]
[-- Type: text/x-diff, Size: 18811 bytes --]

Index: modules/generic_stage_target.py
===================================================================
--- modules/generic_stage_target.py	(revision 1203)
+++ modules/generic_stage_target.py	(working copy)
@@ -18,40 +18,21 @@
 		
 		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",
@@ -61,8 +42,12 @@
 				"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",
@@ -71,31 +56,38 @@
 				"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:
@@ -104,14 +96,16 @@
 			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()
 		
@@ -205,6 +199,10 @@
 			# 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"]
@@ -832,7 +830,8 @@
 
 	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()	
@@ -869,7 +868,8 @@
 				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()	
@@ -888,6 +888,8 @@
 			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
@@ -1078,7 +1080,7 @@
                         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))
Index: targets/netboot/netboot-combine.sh
===================================================================
--- targets/netboot/netboot-combine.sh	(revision 1203)
+++ targets/netboot/netboot-combine.sh	(working copy)
@@ -15,7 +15,7 @@
 
 # First install the boot package that we need
 booter=""
-case ${clst_mainarch} in
+case ${clst_hostarch} in
 	alpha)
 		booter=""
 	;;
@@ -51,7 +51,7 @@
 	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
@@ -93,10 +93,10 @@
 			;;
 		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 \
Index: targets/support/functions.sh
===================================================================
--- targets/support/functions.sh	(revision 1203)
+++ targets/support/functions.sh	(working copy)
@@ -211,3 +211,7 @@
 		;;
 	esac
 }																												
+
+run_crossdev() {
+	crossdev ${clst_CHOST}
+}
Index: targets/support/netboot2-final.sh
===================================================================
--- targets/support/netboot2-final.sh	(revision 1203)
+++ targets/support/netboot2-final.sh	(working copy)
@@ -21,7 +21,7 @@
 
 # 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
 		;;
Index: targets/support/bootloader-setup.sh
===================================================================
--- targets/support/bootloader-setup.sh	(revision 1203)
+++ targets/support/bootloader-setup.sh	(working copy)
@@ -13,7 +13,7 @@
 
 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
Index: targets/support/create-iso.sh
===================================================================
--- targets/support/create-iso.sh	(revision 1203)
+++ targets/support/create-iso.sh	(working copy)
@@ -7,7 +7,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"
@@ -28,7 +28,7 @@
 then
 	case ${clst_livecd_type} in
 		gentoo-*)
-			case ${clst_mainarch} in
+			case ${clst_hostarch} in
 				alpha)
 					clst_iso_volume_id="Gentoo Linux - Alpha"
 				;;
@@ -76,7 +76,7 @@
 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)
Index: targets/support/pre-kmerge.sh
===================================================================
--- targets/support/pre-kmerge.sh	(revision 1203)
+++ targets/support/pre-kmerge.sh	(working copy)
@@ -13,7 +13,7 @@
 		# 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 @@
 		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
Index: arch/hppa.py
===================================================================
--- arch/hppa.py	(revision 1203)
+++ arch/hppa.py	(working copy)
@@ -7,7 +7,6 @@
 	"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"
Index: arch/mips.py
===================================================================
--- arch/mips.py	(revision 1203)
+++ arch/mips.py	(working copy)
@@ -7,7 +7,6 @@
 	"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"
 
@@ -15,7 +14,6 @@
 	"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"
 
Index: arch/sparc.py
===================================================================
--- arch/sparc.py	(revision 1203)
+++ arch/sparc.py	(working copy)
@@ -7,11 +7,11 @@
 	"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"
 
Index: arch/sh.py
===================================================================
--- arch/sh.py	(revision 1203)
+++ arch/sh.py	(working copy)
@@ -7,14 +7,12 @@
 	"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):
Index: arch/amd64.py
===================================================================
--- arch/amd64.py	(revision 1203)
+++ arch/amd64.py	(working copy)
@@ -6,7 +6,6 @@
 	"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):
Index: arch/ppc64.py
===================================================================
--- arch/ppc64.py	(revision 1203)
+++ arch/ppc64.py	(working copy)
@@ -6,7 +6,6 @@
 	"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):
Index: arch/s390.py
===================================================================
--- arch/s390.py	(revision 1203)
+++ arch/s390.py	(working copy)
@@ -7,7 +7,6 @@
 	"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):
Index: arch/arm.py
===================================================================
--- arch/arm.py	(revision 1203)
+++ arch/arm.py	(working copy)
@@ -7,7 +7,6 @@
 	"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"
@@ -16,7 +15,6 @@
 	"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"
Index: arch/ppc.py
===================================================================
--- arch/ppc.py	(revision 1203)
+++ arch/ppc.py	(working copy)
@@ -12,12 +12,12 @@
 	"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"
 
Index: arch/sparc64.py
===================================================================
--- arch/sparc64.py	(revision 1203)
+++ arch/sparc64.py	(working copy)
@@ -7,7 +7,6 @@
 	"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):
Index: arch/ia64.py
===================================================================
--- arch/ia64.py	(revision 1203)
+++ arch/ia64.py	(working copy)
@@ -7,7 +7,6 @@
 	"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"
Index: arch/alpha.py
===================================================================
--- arch/alpha.py	(revision 1203)
+++ arch/alpha.py	(working copy)
@@ -7,7 +7,6 @@
 	"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"
 
Index: arch/x86.py
===================================================================
--- arch/x86.py	(revision 1203)
+++ arch/x86.py	(working copy)
@@ -7,11 +7,11 @@
 	"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"
 

             reply	other threads:[~2006-12-31 15:08 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-31 15:09 Mike Frysinger [this message]
2007-01-04 18:15 ` [gentoo-catalyst] [rfc] laying groundwork for cbuild Chris Gianelloni
2007-01-05  9:35   ` Mike Frysinger
2007-01-16 15:56 ` Chris Gianelloni
2007-01-16 22:15   ` Mike Frysinger
2007-01-17 15:07     ` Chris Gianelloni
2007-01-20  5:31       ` Mike Frysinger
2007-01-20 13:26         ` Chris Gianelloni
2007-01-20 13:29         ` Chris Gianelloni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200612311009.10004.vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --cc=gentoo-catalyst@gentoo.org \
    --cc=gentoo-catalyst@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox