# ChangeLog for gentoo/src/catalyst
# Copyright 2002-2004 Gentoo Technologies, Inc.; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo/src/catalyst/ChangeLog,v 1.47 2004/05/12 21:18:50 zhen Exp $
+# $Header: /var/cvsroot/gentoo/src/catalyst/ChangeLog,v 1.48 2004/05/17 01:21:17 zhen Exp $
+
+ 16 May 2004; John Davis <zhen@gentoo.org> catalyst,
+ modules/catalyst_support.py, modules/embedded_target.py,
+ modules/generic_stage_target.py, modules/generic_target.py,
+ modules/grp_target.py, modules/livecd_stage1_target.py,
+ modules/livecd_stage2_target.py, modules/stage1_target.py,
+ modules/stage2_target.py, modules/stage3_target.py,
+ modules/tinderbox_target.py, targets/stage1/stage1-preclean2-chroot.sh:
+ finally parsed out targets.py. fixed gcc-config typo in stage1 the stage1 that
+ caused gcc profile problems.
12 May 2004; John Davis <zhen@gentoo.org>
livecd/runscript/default-runscript.sh, livecd/runscript-support/kmerge.sh,
#!/usr/bin/python
# Copyright 1999-2004 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo/src/catalyst/catalyst,v 1.34 2004/05/11 20:05:20 zhen Exp $
+# $Header: /var/cvsroot/gentoo/src/catalyst/catalyst,v 1.35 2004/05/17 01:21:17 zhen Exp $
import os,sys,imp,string
#This allows plugins (and this code) to import modules in the /modules dir
sys.path.append(myspec["sharedir"]+"/modules")
+targetmap={}
try:
from catalyst_support import *
- import targets
+ for x in required_build_targets:
+ try:
+ fh=open(myspec["sharedir"]+"/modules/"+x+".py")
+ module=imp.load_module(x,fh,"modules/"+x+".py",(".py","r",imp.PY_SOURCE))
+ fh.close()
+ except IOError:
+ msg("Can't find "+x+".py plugin in "+myspec.settings["sharedir"]+"/modules/")
+
+ for x in valid_build_targets:
+ try:
+ fh=open(myspec["sharedir"]+"/modules/"+x+".py")
+ module=imp.load_module(x,fh,"modules/"+x+".py",(".py","r",imp.PY_SOURCE))
+ module.register(targetmap)
+ fh.close()
+ except IOError:
+ msg("Can't find "+x+".py plugin in "+myspec.settings["sharedir"]+"/modules/")
+
except ImportError:
print "catalyst: python modules not found in "+myspec["sharedir"]+"/modules; exiting."
sys.exit(1)
-targetmap={}
-targets.register(targetmap)
-
if "ccache" in string.split(myspec["options"]):
print "Compiler cache support enabled."
myspec["CCACHE"]="1"
# Distributed under the GNU General Public License version 2
# Copyright 2003-2004 Gentoo Technologies, Inc.
-# $Header: /var/cvsroot/gentoo/src/catalyst/modules/catalyst_support.py,v 1.19 2004/05/12 21:18:50 zhen Exp $
+# $Header: /var/cvsroot/gentoo/src/catalyst/modules/catalyst_support.py,v 1.20 2004/05/17 01:21:17 zhen Exp $
import sys,string,os,types
-def list_bashify(mylist):
- if type(mylist)==types.StringType:
- mypack=[mylist]
- else:
- mypack=mylist[:]
- for x in range(0,len(mypack)):
- #surround args with quotes for passing to bash, allows things like "<" to remain intact
- mypack[x]="'"+mypack[x]+"'"
- mypack=string.join(mypack)
- #escape ">" and "<" for the shell (using backslash)
- #mypack=string.replace(mypack,">","\\>")
- #mypack=string.replace(mypack,"<","\\<")
- return mypack
+# these should never be touched
+required_build_targets=["generic_target","generic_stage_target"]
+
+# new build types should be added here
+valid_build_targets=["stage1_target","stage2_target","stage3_target","grp_target",
+ "livecd_stage1_target","livecd_stage2_target","embedded_target",
+ "tinderbox_target"]
required_config_file_values=["storedir","sharedir","distdir","portdir"]
valid_config_file_values=required_config_file_values[:]
verbosity=1
+"""
+# register the build target for catalyst to use here
+# (uses the values from valid_build_targets)
+def register_build_targets(targetlist):
+ targetlist.update({"stage1":stage1_target,"stage2":stage2_target,"stage3":stage3_target,
+ "grp":grp_target,"livecd-stage1":livecd_stage1_target,
+ "livecd-stage2":livecd_stage2_target,
+ "snapshot":snapshot_target,"tinderbox":tinderbox_target,
+ "embedded":embedded_target})
+ return targetlist
+"""
+
+def list_bashify(mylist):
+ if type(mylist)==types.StringType:
+ mypack=[mylist]
+ else:
+ mypack=mylist[:]
+ for x in range(0,len(mypack)):
+ # surround args with quotes for passing to bash,
+ # allows things like "<" to remain intact
+ mypack[x]="'"+mypack[x]+"'"
+ mypack=string.join(mypack)
+ return mypack
+
class CatalystError(Exception):
def __init__(self, message):
if message:
raise CatalystError,myexc
def file_locate(settings,filelist,expand=1):
- #if expand=1, non-absolute paths will be accepted and expanded to os.getcwd()+"/"+localpath if file exists
+ #if expand=1, non-absolute paths will be accepted and
+ # expanded to os.getcwd()+"/"+localpath if file exists
for myfile in filelist:
if not settings.has_key(myfile):
#filenames such as cdtar are optional, so we don't assume the variable is defined.
--- /dev/null
+# Distributed under the GNU General Public License version 2
+# Copyright 2003-2004 Gentoo Technologies, Inc.
+# $Header: /var/cvsroot/gentoo/src/catalyst/modules/embedded_target.py,v 1.1 2004/05/17 01:21:17 zhen Exp $
+
+"""
+This class works like a 'stage3'. A stage2 tarball is unpacked, but instead
+of building a stage3, it emerges a 'system' into another directory
+inside the 'stage2' system. This way we do not have to emerge gcc/portage
+into the staged system.
+
+It sounds real complicated but basically it's a it runs
+ROOT=/tmp/submerge emerge --blahblah foo bar
+"""
+
+import os,string,imp,types,shutil
+from catalyst_support import *
+from generic_stage_target import *
+from stat import *
+
+class embedded_target(generic_stage_target):
+
+ def __init__(self,spec,addlargs):
+ self.required_values=[]
+ self.valid_values=[]
+ #self.required_values.extend(["embedded/packages"]);
+ self.valid_values.extend(["embedded/empty","embedded/rm","embedded/unmerge","embedded/runscript","embedded/mergeroot","embedded/packages","embedded/use"])
+
+ generic_stage_target.__init__(self,spec,addlargs)
+ self.settings["image_path"]=self.settings["storedir"]+"/builds/"+self.settings["target_subpath"]+"/image"
+
+ # taken from livecd-stage3 code
+ def unmerge(self):
+ print "Unmerging packages"
+ if self.settings.has_key("embedded/unmerge"):
+ if type(self.settings["embedded/unmerge"])==types.StringType:
+ self.settings["embedded/unmerge"]=[self.settings["embedded/unmerge"]]
+ myunmerge=self.settings["embedded/unmerge"][:]
+
+ for x in range(0,len(myunmerge)):
+ myunmerge[x]="'"+myunmerge[x]+"'"
+ myunmerge=string.join(myunmerge)
+ # before cleaning unmerge stuff
+ cmd("/bin/bash "+self.settings["sharedir"]+"/targets/"+self.settings["target"]+"/unmerge.sh "+myunmerge,"unmerge script failed.")
+
+ def clean(self):
+ if self.settings.has_key("embedded/rm"):
+ if type(self.settings["embedded/rm"])==types.StringType:
+ self.settings["embedded/rm"]=[self.settings["embedded/rm"]]
+ print "Removing directories from image"
+ for x in self.settings["embedded/rm"]:
+ print "Removing "+x
+ os.system("rm -rf "+self.settings["chroot_path"]+"/tmp/mergeroot"+x)
+ def run_local(self):
+ mypackages=list_bashify(self.settings["embedded/packages"])
+ print "Merging embedded image"
+ try:
+ cmd("/bin/bash "+self.settings["sharedir"]+"/targets/embedded/embedded.sh run")
+ except CatalystError:
+ self.unbind()
+ raise CatalystError, "Embedded build aborted due to error."
+ self.unmerge()
+ self.clean()
+ try:
+ if self.settings.has_key("embedded/runscript"):
+ cmd("/bin/bash "+self.settings["embedded/runscript"]+" run ","runscript failed")
+ except CatalystError:
+ self.unbind()
+ raise CatalystError, "embedded runscript aborting due to error."
+
+def register(foo):
+ foo.update({"embedded":embedded_target})
+ return foo
# Distributed under the GNU General Public License version 2
# Copyright 2003-2004 Gentoo Technologies, Inc.
-# $Header: /var/cvsroot/gentoo/src/catalyst/modules/Attic/targets.py,v 1.103 2004/05/12 21:18:50 zhen Exp $
+# $Header: /var/cvsroot/gentoo/src/catalyst/modules/generic_stage_target.py,v 1.1 2004/05/17 01:21:17 zhen Exp $
+
+"""
+This class does all of the chroot setup, copying of files, etc. It is
+the driver class for pretty much everything that Catalyst does.
+"""
import os,string,imp,types,shutil
from catalyst_support import *
+from generic_target import *
from stat import *
-class generic_target:
-
- def __init__(self,myspec,addlargs):
- addl_arg_parse(myspec,addlargs,self.required_values,self.valid_values)
- self.settings=myspec
- pass
-
class generic_stage_target(generic_target):
def __init__(self,myspec,addlargs):
self.capture()
if self.settings["target"] in ["livecd-stage2"]:
self.cdroot_setup()
-
-class snapshot_target(generic_target):
- def __init__(self,myspec,addlargs):
- self.required_values=["version_stamp","target"]
- self.valid_values=["version_stamp","target"]
- generic_target.__init__(self,myspec,addlargs)
- self.settings=myspec
- self.settings["target_subpath"]="portage-"+self.settings["version_stamp"]
- st=self.settings["storedir"]
- self.settings["snapshot_path"]=st+"/snapshots/"+self.settings["target_subpath"]+".tar.bz2"
- self.settings["tmp_path"]=st+"/tmp/"+self.settings["target_subpath"]
-
- def setup(self):
- x=self.settings["storedir"]+"/snapshots"
- if not os.path.exists(x):
- os.makedirs(x)
-
- def run(self):
- self.setup()
- print "Creating Portage tree snapshot "+self.settings["version_stamp"]+" from "+self.settings["portdir"]+"..."
- mytmp=self.settings["tmp_path"]
- if os.path.exists(mytmp):
- cmd("rm -rf "+mytmp,"Could not remove existing directory: "+mytmp)
- os.makedirs(mytmp)
- cmd("rsync -a --exclude /packages/ --exclude /distfiles/ --exclude CVS/ "+self.settings["portdir"]+"/ "+mytmp+"/portage/","Snapshot failure")
- print "Compressing Portage snapshot tarball..."
- cmd("tar cjf "+self.settings["snapshot_path"]+" -C "+mytmp+" portage","Snapshot creation failure")
- self.cleanup()
-
- def cleanup(self):
- print "Cleaning up temporary snapshot directory..."
- #Be a good citizen and clean up after ourselves
- cmd("rm -rf "+self.settings["tmp_path"],"Snapshot cleanup failure")
-
-class stage1_target(generic_stage_target):
- def __init__(self,spec,addlargs):
- self.required_values=[]
- self.valid_values=[]
- generic_stage_target.__init__(self,spec,addlargs)
-
-class stage2_target(generic_stage_target):
- def __init__(self,spec,addlargs):
- self.required_values=[]
- self.valid_values=[]
- generic_stage_target.__init__(self,spec,addlargs)
-
-class stage3_target(generic_stage_target):
- def __init__(self,spec,addlargs):
- self.required_values=[]
- self.valid_values=[]
- generic_stage_target.__init__(self,spec,addlargs)
-
-class grp_target(generic_stage_target):
- def __init__(self,spec,addlargs):
- self.required_values=["version_stamp","target","subarch","rel_type","profile","snapshot","source_subpath"]
- self.valid_values=self.required_values[:]
- if not addlargs.has_key("grp"):
- raise CatalystError,"Required value \"grp\" not specified in spec."
- self.required_values.extend(["grp","grp/use"])
- if type(addlargs["grp"])==types.StringType:
- addlargs["grp"]=[addlargs["grp"]]
- for x in addlargs["grp"]:
- self.required_values.append("grp/"+x+"/packages")
- self.required_values.append("grp/"+x+"/type")
- generic_stage_target.__init__(self,spec,addlargs)
-
- def run_local(self):
- for pkgset in self.settings["grp"]:
- #example call: "grp.sh run pkgset cd1 xmms vim sys-apps/gleep"
- mypackages=list_bashify(self.settings["grp/"+pkgset+"/packages"])
- try:
- cmd("/bin/bash "+self.settings["sharedir"]+"/targets/grp/grp.sh run "+self.settings["grp/"+pkgset+"/type"]+" "+pkgset+" "+mypackages)
- except CatalystError:
- self.unbind()
- raise CatalystError,"GRP build aborting due to error."
-
-class tinderbox_target(generic_stage_target):
- def __init__(self,spec,addlargs):
- self.required_values=["tinderbox/packages","tinderbox/use"]
- self.valid_values=self.required_values[:]
- generic_stage_target.__init__(self,spec,addlargs)
-
- def run_local(self):
- #tinderbox
- #example call: "grp.sh run xmms vim sys-apps/gleep"
- try:
- cmd("/bin/bash "+self.settings["sharedir"]+"/targets/tinderbox/tinderbox.sh run "+list_bashify(self.settings["tinderbox/packages"]))
- except CatalystError:
- self.unbind()
- raise CatalystError,"Tinderbox aborting due to error."
-
-class livecd_stage1_target(generic_stage_target):
- def __init__(self,spec,addlargs):
- self.required_values=["livecd/packages","livecd/use"]
- self.valid_values=self.required_values[:]
- generic_stage_target.__init__(self,spec,addlargs)
-
- def run_local(self):
- mypack=list_bashify(self.settings["livecd/packages"])
- try:
- cmd("/bin/bash "+self.settings["sharedir"]+"/targets/livecd-stage1/livecd-stage1.sh run "+mypack)
- except CatalystError:
- self.unbind()
- raise CatalystError,"LiveCD stage1 build aborting due to error."
-
-class livecd_stage2_target(generic_stage_target):
- def __init__(self,spec,addlargs):
- self.required_values=["boot/kernel","livecd/cdfstype","livecd/archscript","livecd/runscript"]
- self.valid_values=[]
- if not addlargs.has_key("boot/kernel"):
- raise CatalystError, "Required value boot/kernel not specified."
- if type(addlargs["boot/kernel"]) == types.StringType:
- loopy=[addlargs["boot/kernel"]]
- else:
- loopy=addlargs["boot/kernel"]
- for x in loopy:
- self.required_values.append("boot/kernel/"+x+"/sources")
- self.required_values.append("boot/kernel/"+x+"/config")
- self.valid_values.append("boot/kernel/"+x+"/extraversion")
- self.valid_values.append("boot/kernel/"+x+"/packages")
- self.valid_values.append("boot/kernel/"+x+"/use")
- self.valid_values.extend(self.required_values)
- self.valid_values.extend(["livecd/cdtar","livecd/empty","livecd/rm","livecd/unmerge","livecd/iso"])
- generic_stage_target.__init__(self,spec,addlargs)
- file_locate(self.settings, ["livecd/cdtar","livecd/archscript","livecd/runscript"])
-
- def unpack_and_bind(self):
- if os.path.exists(self.settings["chroot_path"]):
- print "Removing previously-existing livecd-stage2 chroot directory..."
- cmd("rm -rf "+self.settings["chroot_path"],"Error removing livecd-stage2 chroot")
- os.makedirs(self.settings["chroot_path"])
- print "Copying livecd-stage1 result to new livecd-stage2 work directory..."
- cmd("cp -a "+self.settings["source_path"]+"/* "+self.settings["chroot_path"],"Error copying initial livecd-stage2")
- for x in self.mounts:
- if not os.path.exists(self.settings["chroot_path"]+x):
- os.makedirs(self.settings["chroot_path"]+x)
- if not os.path.exists(self.mountmap[x]):
- os.makedirs(self.mountmap[x])
- src=self.mountmap[x]
- retval=os.system("mount --bind "+src+" "+self.settings["chroot_path"]+x)
- if retval!=0:
- self.unbind()
- raise CatalystError,"Couldn't bind mount "+src
- print "Configuring profile link..."
- cmd("rm -f "+self.settings["chroot_path"]+"/etc/make.profile","Error zapping profile link")
- cmd("ln -sf ../usr/portage/profiles/"+self.settings["target_profile"]+" "+self.settings["chroot_path"]+"/etc/make.profile","Error creating profile link")
-
- def unmerge(self):
- if self.settings.has_key("livecd/unmerge"):
- if type(self.settings["livecd/unmerge"])==types.StringType:
- self.settings["livecd/unmerge"]=[self.settings["livecd/unmerge"]]
- myunmerge=self.settings["livecd/unmerge"][:]
- for x in range(0,len(myunmerge)):
- #surround args with quotes for passing to bash, allows things like "<" to remain intact
- myunmerge[x]="'"+myunmerge[x]+"'"
- myunmerge=string.join(myunmerge)
- #before cleaning, unmerge stuff:
- try:
- cmd("/bin/bash "+self.settings["sharedir"]+"/targets/"+self.settings["target"]+"/unmerge.sh "+myunmerge,"unmerge script failed.")
- except CatalystError:
- self.unbind()
- raise
-
- def clean(self):
- generic_stage_target.clean(self)
- try:
- cmd("/bin/bash "+self.settings["livecd/runscript"]+" clean","clean runscript failed.")
- except:
- self.unbind()
- raise
-
- def preclean(self):
- try:
- cmd("/bin/bash "+self.settings["livecd/runscript"]+" preclean","preclean runscript failed.")
- except:
- self.unbind()
- raise
-
- def cdroot_setup(self):
- cmd("/bin/bash "+self.settings["livecd/runscript"]+" cdfs","cdfs runscript failed.")
- if self.settings.has_key("livecd/iso"):
- cmd("/bin/bash "+self.settings["livecd/runscript"]+" iso "+self.settings["livecd/iso"],"iso runscript failed.")
- print "livecd-stage2: complete!"
-
- def run_local(self):
- #first clean up any existing cdroot stuff
- if os.path.exists(self.settings["cdroot_path"]):
- print "cleaning previous livecd-stage2 build"
- cmd("rm -rf "+self.settings["cdroot_path"],"Could not remove existing directory: "+self.settings["cdroot_path"])
- os.makedirs(self.settings["cdroot_path"])
- #now, start building the kernel
- mynames=self.settings["boot/kernel"]
- if type(mynames)==types.StringType:
- mynames=[mynames]
- args=[]
- args.append(`len(mynames)`)
- for kname in mynames:
- args.append(kname)
- args.append(self.settings["boot/kernel/"+kname+"/sources"])
- if not os.path.exists(self.settings["boot/kernel/"+kname+"/config"]):
- self.unbind()
- raise CatalystError, "Can't find kernel config: "+self.settings["boot/kernel/"+kname+"/config"]
-
- # We must support multiple configs for the same kernel, so we must manually edit the
- # EXTRAVERSION on the kernel to allow them to coexist. The extraversion field gets appended
- # to the current EXTRAVERSION in the kernel Makefile. Examples of this usage are UP vs SMP kernels,
- # and on PPC64 we need a seperate pSeries, iSeries, and PPC970 (G5) kernels, all compiled off the
- # same source, without having to release a seperate livecd for each (since other than the kernel,
- # they are all binary compatible)
- if self.settings.has_key("boot/kernel/"+kname+"/extraversion"):
- #extraversion is now an optional parameter, so that don't need to worry about it unless
- #they have to
- args.append(self.settings["boot/kernel/"+kname+"/extraversion"])
- else:
- #this value will be detected on the bash side and indicate that EXTRAVERSION processing
- #should be skipped
- args.append("NULL_VALUE")
- #write out /var/tmp/kname.(use|packages) files, used for kernel USE and extra packages settings
- for extra in ["use","packages"]:
- if self.settings.has_key("boot/kernel/"+kname+"/"+extra):
- myex=self.settings["boot/kernel/"+kname+"/"+extra]
- if type(myex)==types.ListType:
- myex=string.join(myex)
- try:
- myf=open(self.settings["chroot_path"]+"/var/tmp/"+kname+"."+extra,"w")
- except:
- self.unbind()
- raise CatalystError,"Couldn't create file /var/tmp/"+kname+"."+extra+" in chroot."
- if extra=="use":
- myf.write("export USE=\""+myex+"\"\n")
- else:
- myf.write(myex+"\n")
- myf.close()
-
- retval=os.system("cp "+self.settings["boot/kernel/"+kname+"/config"]+" "+self.settings["chroot_path"]+"/var/tmp/"+kname+".config")
- if retval!=0:
- self.unbind()
- raise CatalystError, "Couldn't copy kernel config: "+self.settings["boot/kernel/"+kname+"/config"]
-
- # If we need to pass special options to the bootloader for this kernel
- # put them into the environment.
- if self.settings.has_key("boot/kernel/"+kname+"/kernelopts"):
- myopts=self.settings["boot/kernel/"+kname+"/kernelopts"]
- if type(myopts) != types.StringType:
- myopts = string.join(myopts)
- os.putenv(kname+"_kernelopts", myopts)
- else:
- os.putenv(kname+"_kernelopts", "")
-
- try:
- cmd("/bin/bash "+self.settings["livecd/runscript"]+" kernel "+list_bashify(args),"runscript kernel build failed")
- cmd("/bin/bash "+self.settings["livecd/runscript"]+" bootloader","bootloader runscript failed.")
- except CatalystError:
- self.unbind()
- raise CatalystError,"runscript aborting due to error."
-
-# this class works like a 'stage3'. A stage2 tarball is unpacked, but instead
-# of building a stage3, it emerges a 'system' into another directory
-# inside the 'stage2' system. This way we do not have to emerge gcc/portage
-# into the staged system.
-#
-# it sounds real complicated but basically it's a it runs
-# ROOT=/tmp/submerge emerge --blahblah foo bar
-class embedded_target(generic_stage_target):
-
- def __init__(self,spec,addlargs):
- self.required_values=[]
- self.valid_values=[]
- #self.required_values.extend(["embedded/packages"]);
- self.valid_values.extend(["embedded/empty","embedded/rm","embedded/unmerge","embedded/runscript","embedded/mergeroot","embedded/packages","embedded/use"])
-
- generic_stage_target.__init__(self,spec,addlargs)
- self.settings["image_path"]=self.settings["storedir"]+"/builds/"+self.settings["target_subpath"]+"/image"
-
- # taken from livecd-stage3 code
- def unmerge(self):
- print "Unmerging packages"
- if self.settings.has_key("embedded/unmerge"):
- if type(self.settings["embedded/unmerge"])==types.StringType:
- self.settings["embedded/unmerge"]=[self.settings["embedded/unmerge"]]
- myunmerge=self.settings["embedded/unmerge"][:]
-
- for x in range(0,len(myunmerge)):
- myunmerge[x]="'"+myunmerge[x]+"'"
- myunmerge=string.join(myunmerge)
- # before cleaning unmerge stuff
- cmd("/bin/bash "+self.settings["sharedir"]+"/targets/"+self.settings["target"]+"/unmerge.sh "+myunmerge,"unmerge script failed.")
-
- def clean(self):
- if self.settings.has_key("embedded/rm"):
- if type(self.settings["embedded/rm"])==types.StringType:
- self.settings["embedded/rm"]=[self.settings["embedded/rm"]]
- print "Removing directories from image"
- for x in self.settings["embedded/rm"]:
- print "Removing "+x
- os.system("rm -rf "+self.settings["chroot_path"]+"/tmp/mergeroot"+x)
- def run_local(self):
- mypackages=list_bashify(self.settings["embedded/packages"])
- print "Merging embedded image"
- try:
- cmd("/bin/bash "+self.settings["sharedir"]+"/targets/embedded/embedded.sh run")
- except CatalystError:
- self.unbind()
- raise CatalystError, "Embedded build aborted due to error."
- self.unmerge()
- self.clean()
- try:
- if self.settings.has_key("embedded/runscript"):
- cmd("/bin/bash "+self.settings["embedded/runscript"]+" run ","runscript failed")
- except CatalystError:
- self.unbind()
- raise CatalystError, "embedded runscript aborting due to error."
-
-def register(foo):
- foo.update({"stage1":stage1_target,"stage2":stage2_target,"stage3":stage3_target,
- "grp":grp_target,"livecd-stage1":livecd_stage1_target,
- "livecd-stage2":livecd_stage2_target,
- "snapshot":snapshot_target,"tinderbox":tinderbox_target,
- "embedded":embedded_target})
- return foo
-
--- /dev/null
+# Distributed under the GNU General Public License version 2
+# Copyright 2003-2004 Gentoo Technologies, Inc.
+# $Header: /var/cvsroot/gentoo/src/catalyst/modules/generic_target.py,v 1.1 2004/05/17 01:21:17 zhen Exp $
+
+"""
+The toplevel class for generic_stage_target. This is about as generic as we get.
+"""
+
+import os,string,imp,types,shutil
+from catalyst_support import *
+from stat import *
+
+class generic_target:
+
+ def __init__(self,myspec,addlargs):
+ addl_arg_parse(myspec,addlargs,self.required_values,self.valid_values)
+ self.settings=myspec
+ pass
--- /dev/null
+# Distributed under the GNU General Public License version 2
+# Copyright 2003-2004 Gentoo Technologies, Inc.
+# $Header: /var/cvsroot/gentoo/src/catalyst/modules/grp_target.py,v 1.1 2004/05/17 01:21:17 zhen Exp $
+
+"""
+The builder class for GRP (Gentoo Reference Platform) builds.
+"""
+
+import os,string,imp,types,shutil
+from catalyst_support import *
+from generic_stage_target import *
+from stat import *
+
+
+class grp_target(generic_stage_target):
+ def __init__(self,spec,addlargs):
+ self.required_values=["version_stamp","target","subarch","rel_type","profile","snapshot","source_subpath"]
+ self.valid_values=self.required_values[:]
+ if not addlargs.has_key("grp"):
+ raise CatalystError,"Required value \"grp\" not specified in spec."
+ self.required_values.extend(["grp","grp/use"])
+ if type(addlargs["grp"])==types.StringType:
+ addlargs["grp"]=[addlargs["grp"]]
+ for x in addlargs["grp"]:
+ self.required_values.append("grp/"+x+"/packages")
+ self.required_values.append("grp/"+x+"/type")
+ generic_stage_target.__init__(self,spec,addlargs)
+
+ def run_local(self):
+ for pkgset in self.settings["grp"]:
+ #example call: "grp.sh run pkgset cd1 xmms vim sys-apps/gleep"
+ mypackages=list_bashify(self.settings["grp/"+pkgset+"/packages"])
+ try:
+ cmd("/bin/bash "+self.settings["sharedir"]+"/targets/grp/grp.sh run "+self.settings["grp/"+pkgset+"/type"]+" "+pkgset+" "+mypackages)
+ except CatalystError:
+ self.unbind()
+ raise CatalystError,"GRP build aborting due to error."
+
+def register(foo):
+ foo.update({"grp":grp_target})
+ return foo
--- /dev/null
+# Distributed under the GNU General Public License version 2
+# Copyright 2003-2004 Gentoo Technologies, Inc.
+# $Header: /var/cvsroot/gentoo/src/catalyst/modules/livecd_stage1_target.py,v 1.1 2004/05/17 01:21:17 zhen Exp $
+
+"""
+Builder class for LiveCD stage1.
+"""
+
+import os,string,imp,types,shutil
+from catalyst_support import *
+from generic_stage_target import *
+from stat import *
+
+class livecd_stage1_target(generic_stage_target):
+ def __init__(self,spec,addlargs):
+ self.required_values=["livecd/packages","livecd/use"]
+ self.valid_values=self.required_values[:]
+ generic_stage_target.__init__(self,spec,addlargs)
+
+ def run_local(self):
+ mypack=list_bashify(self.settings["livecd/packages"])
+ try:
+ cmd("/bin/bash "+self.settings["sharedir"]+"/targets/livecd-stage1/livecd-stage1.sh run "+mypack)
+ except CatalystError:
+ self.unbind()
+ raise CatalystError,"LiveCD stage1 build aborting due to error."
+
+def register(foo):
+ foo.update({"livecd-stage1":livecd_stage1_target})
+ return foo
--- /dev/null
+# Distributed under the GNU General Public License version 2
+# Copyright 2003-2004 Gentoo Technologies, Inc.
+# $Header: /var/cvsroot/gentoo/src/catalyst/modules/livecd_stage2_target.py,v 1.1 2004/05/17 01:21:17 zhen Exp $
+
+"""
+Builder class for a LiveCD stage2 build.
+"""
+
+import os,string,imp,types,shutil
+from catalyst_support import *
+from generic_stage_target import *
+from stat import *
+
+class livecd_stage2_target(generic_stage_target):
+ def __init__(self,spec,addlargs):
+ self.required_values=["boot/kernel","livecd/cdfstype","livecd/archscript","livecd/runscript"]
+ self.valid_values=[]
+ if not addlargs.has_key("boot/kernel"):
+ raise CatalystError, "Required value boot/kernel not specified."
+ if type(addlargs["boot/kernel"]) == types.StringType:
+ loopy=[addlargs["boot/kernel"]]
+ else:
+ loopy=addlargs["boot/kernel"]
+ for x in loopy:
+ self.required_values.append("boot/kernel/"+x+"/sources")
+ self.required_values.append("boot/kernel/"+x+"/config")
+ self.valid_values.append("boot/kernel/"+x+"/extraversion")
+ self.valid_values.append("boot/kernel/"+x+"/packages")
+ self.valid_values.append("boot/kernel/"+x+"/use")
+ self.valid_values.extend(self.required_values)
+ self.valid_values.extend(["livecd/cdtar","livecd/empty","livecd/rm","livecd/unmerge","livecd/iso"])
+ generic_stage_target.__init__(self,spec,addlargs)
+ file_locate(self.settings, ["livecd/cdtar","livecd/archscript","livecd/runscript"])
+
+ def unpack_and_bind(self):
+ if os.path.exists(self.settings["chroot_path"]):
+ print "Removing previously-existing livecd-stage2 chroot directory..."
+ cmd("rm -rf "+self.settings["chroot_path"],"Error removing livecd-stage2 chroot")
+ os.makedirs(self.settings["chroot_path"])
+ print "Copying livecd-stage1 result to new livecd-stage2 work directory..."
+ cmd("cp -a "+self.settings["source_path"]+"/* "+self.settings["chroot_path"],"Error copying initial livecd-stage2")
+ for x in self.mounts:
+ if not os.path.exists(self.settings["chroot_path"]+x):
+ os.makedirs(self.settings["chroot_path"]+x)
+ if not os.path.exists(self.mountmap[x]):
+ os.makedirs(self.mountmap[x])
+ src=self.mountmap[x]
+ retval=os.system("mount --bind "+src+" "+self.settings["chroot_path"]+x)
+ if retval!=0:
+ self.unbind()
+ raise CatalystError,"Couldn't bind mount "+src
+ print "Configuring profile link..."
+ cmd("rm -f "+self.settings["chroot_path"]+"/etc/make.profile","Error zapping profile link")
+ cmd("ln -sf ../usr/portage/profiles/"+self.settings["target_profile"]+" "+self.settings["chroot_path"]+"/etc/make.profile","Error creating profile link")
+
+ def unmerge(self):
+ if self.settings.has_key("livecd/unmerge"):
+ if type(self.settings["livecd/unmerge"])==types.StringType:
+ self.settings["livecd/unmerge"]=[self.settings["livecd/unmerge"]]
+ myunmerge=self.settings["livecd/unmerge"][:]
+ for x in range(0,len(myunmerge)):
+ #surround args with quotes for passing to bash, allows things like "<" to remain intact
+ myunmerge[x]="'"+myunmerge[x]+"'"
+ myunmerge=string.join(myunmerge)
+ #before cleaning, unmerge stuff:
+ try:
+ cmd("/bin/bash "+self.settings["sharedir"]+"/targets/"+self.settings["target"]+"/unmerge.sh "+myunmerge,"unmerge script failed.")
+ except CatalystError:
+ self.unbind()
+ raise
+
+ def clean(self):
+ generic_stage_target.clean(self)
+ try:
+ cmd("/bin/bash "+self.settings["livecd/runscript"]+" clean","clean runscript failed.")
+ except:
+ self.unbind()
+ raise
+
+ def preclean(self):
+ try:
+ cmd("/bin/bash "+self.settings["livecd/runscript"]+" preclean","preclean runscript failed.")
+ except:
+ self.unbind()
+ raise
+
+ def cdroot_setup(self):
+ cmd("/bin/bash "+self.settings["livecd/runscript"]+" cdfs","cdfs runscript failed.")
+ if self.settings.has_key("livecd/iso"):
+ cmd("/bin/bash "+self.settings["livecd/runscript"]+" iso "+self.settings["livecd/iso"],"iso runscript failed.")
+ print "livecd-stage2: complete!"
+
+ def run_local(self):
+ #first clean up any existing cdroot stuff
+ if os.path.exists(self.settings["cdroot_path"]):
+ print "cleaning previous livecd-stage2 build"
+ cmd("rm -rf "+self.settings["cdroot_path"],"Could not remove existing directory: "+self.settings["cdroot_path"])
+ os.makedirs(self.settings["cdroot_path"])
+ #now, start building the kernel
+ mynames=self.settings["boot/kernel"]
+ if type(mynames)==types.StringType:
+ mynames=[mynames]
+ args=[]
+ args.append(`len(mynames)`)
+ for kname in mynames:
+ args.append(kname)
+ args.append(self.settings["boot/kernel/"+kname+"/sources"])
+ if not os.path.exists(self.settings["boot/kernel/"+kname+"/config"]):
+ self.unbind()
+ raise CatalystError, "Can't find kernel config: "+self.settings["boot/kernel/"+kname+"/config"]
+
+ # We must support multiple configs for the same kernel, so we must manually edit the
+ # EXTRAVERSION on the kernel to allow them to coexist. The extraversion field gets appended
+ # to the current EXTRAVERSION in the kernel Makefile. Examples of this usage are UP vs SMP kernels,
+ # and on PPC64 we need a seperate pSeries, iSeries, and PPC970 (G5) kernels, all compiled off the
+ # same source, without having to release a seperate livecd for each (since other than the kernel,
+ # they are all binary compatible)
+ if self.settings.has_key("boot/kernel/"+kname+"/extraversion"):
+ #extraversion is now an optional parameter, so that don't need to worry about it unless
+ #they have to
+ args.append(self.settings["boot/kernel/"+kname+"/extraversion"])
+ else:
+ #this value will be detected on the bash side and indicate that EXTRAVERSION processing
+ #should be skipped
+ args.append("NULL_VALUE")
+ #write out /var/tmp/kname.(use|packages) files, used for kernel USE and extra packages settings
+ for extra in ["use","packages"]:
+ if self.settings.has_key("boot/kernel/"+kname+"/"+extra):
+ myex=self.settings["boot/kernel/"+kname+"/"+extra]
+ if type(myex)==types.ListType:
+ myex=string.join(myex)
+ try:
+ myf=open(self.settings["chroot_path"]+"/var/tmp/"+kname+"."+extra,"w")
+ except:
+ self.unbind()
+ raise CatalystError,"Couldn't create file /var/tmp/"+kname+"."+extra+" in chroot."
+ if extra=="use":
+ myf.write("export USE=\""+myex+"\"\n")
+ else:
+ myf.write(myex+"\n")
+ myf.close()
+
+ retval=os.system("cp "+self.settings["boot/kernel/"+kname+"/config"]+" "+self.settings["chroot_path"]+"/var/tmp/"+kname+".config")
+ if retval!=0:
+ self.unbind()
+ raise CatalystError, "Couldn't copy kernel config: "+self.settings["boot/kernel/"+kname+"/config"]
+
+ # If we need to pass special options to the bootloader for this kernel
+ # put them into the environment.
+ if self.settings.has_key("boot/kernel/"+kname+"/kernelopts"):
+ myopts=self.settings["boot/kernel/"+kname+"/kernelopts"]
+ if type(myopts) != types.StringType:
+ myopts = string.join(myopts)
+ os.putenv(kname+"_kernelopts", myopts)
+ else:
+ os.putenv(kname+"_kernelopts", "")
+
+ try:
+ cmd("/bin/bash "+self.settings["livecd/runscript"]+" kernel "+list_bashify(args),"runscript kernel build failed")
+ cmd("/bin/bash "+self.settings["livecd/runscript"]+" bootloader","bootloader runscript failed.")
+ except CatalystError:
+ self.unbind()
+ raise CatalystError,"runscript aborting due to error."
+
+def register(foo):
+ foo.update({"livecd-stage2":livecd_stage2_target})
+ return foo
--- /dev/null
+# Distributed under the GNU General Public License version 2
+# Copyright 2003-2004 Gentoo Technologies, Inc.
+# $Header: /var/cvsroot/gentoo/src/catalyst/modules/stage1_target.py,v 1.1 2004/05/17 01:21:17 zhen Exp $
+
+"""
+Builder class for a stage1 installation tarball build.
+"""
+
+import os,string,imp,types,shutil
+from catalyst_support import *
+from generic_stage_target import *
+from stat import *
+
+class stage1_target(generic_stage_target):
+ def __init__(self,spec,addlargs):
+ self.required_values=[]
+ self.valid_values=[]
+ generic_stage_target.__init__(self,spec,addlargs)
+
+def register(foo):
+ foo.update({"stage1":stage1_target})
+ return foo
--- /dev/null
+# Distributed under the GNU General Public License version 2
+# Copyright 2003-2004 Gentoo Technologies, Inc.
+# $Header: /var/cvsroot/gentoo/src/catalyst/modules/stage2_target.py,v 1.1 2004/05/17 01:21:17 zhen Exp $
+
+"""
+Builder class for a stage2 installation tarball build.
+"""
+
+import os,string,imp,types,shutil
+from catalyst_support import *
+from generic_stage_target import *
+from stat import *
+
+class stage2_target(generic_stage_target):
+ def __init__(self,spec,addlargs):
+ self.required_values=[]
+ self.valid_values=[]
+ generic_stage_target.__init__(self,spec,addlargs)
+
+def register(foo):
+ foo.update({"stage2":stage2_target})
+ return foo
--- /dev/null
+# Distributed under the GNU General Public License version 2
+# Copyright 2003-2004 Gentoo Technologies, Inc.
+# $Header: /var/cvsroot/gentoo/src/catalyst/modules/stage3_target.py,v 1.1 2004/05/17 01:21:17 zhen Exp $
+
+"""
+Builder class for a stage3 installation tarball build.
+"""
+
+import os,string,imp,types,shutil
+from catalyst_support import *
+from generic_stage_target import *
+from stat import *
+
+class stage3_target(generic_stage_target):
+ def __init__(self,spec,addlargs):
+ self.required_values=[]
+ self.valid_values=[]
+ generic_stage_target.__init__(self,spec,addlargs)
+
+def register(foo):
+ foo.update({"stage3":stage3_target})
+ return foo
--- /dev/null
+# Distributed under the GNU General Public License version 2
+# Copyright 2003-2004 Gentoo Technologies, Inc.
+# $Header: /var/cvsroot/gentoo/src/catalyst/modules/tinderbox_target.py,v 1.1 2004/05/17 01:21:17 zhen Exp $
+
+import os,string,imp,types,shutil
+from catalyst_support import *
+from generic_stage_target import *
+from stat import *
+
+class tinderbox_target(generic_stage_target):
+ def __init__(self,spec,addlargs):
+ self.required_values=["tinderbox/packages","tinderbox/use"]
+ self.valid_values=self.required_values[:]
+ generic_stage_target.__init__(self,spec,addlargs)
+
+ def run_local(self):
+ #tinderbox
+ #example call: "grp.sh run xmms vim sys-apps/gleep"
+ try:
+ cmd("/bin/bash "+self.settings["sharedir"]+"/targets/tinderbox/tinderbox.sh run "+list_bashify(self.settings["tinderbox/packages"]))
+ except CatalystError:
+ self.unbind()
+ raise CatalystError,"Tinderbox aborting due to error."
+
+def register(foo):
+ foo.update({"tinderbox":tinderbox_target})
+ return foo
#!/bin/bash
# Copyright 1999-2004 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo/src/catalyst/targets/stage1/Attic/stage1-preclean2-chroot.sh,v 1.1 2004/04/12 14:38:26 zhen Exp $
+# $Header: /var/cvsroot/gentoo/src/catalyst/targets/stage1/Attic/stage1-preclean2-chroot.sh,v 1.2 2004/05/17 01:21:17 zhen Exp $
#now, some finishing touches to initialize gcc-config....
unset ROOT
-if [ -e /usr/sbin/gcc-config ]
+if [ -e /usr/bin/gcc-config ]
then
mythang=$( cd /etc/env.d/gcc; ls ${clst_CHOST}-* )
echo $mythang; sleep 20