class generic_x86(builder.generic):
"abstract base class for all x86 builders"
- def __init__(self):
+ def __init__(self,myspec):
+ builder.generic.__init__(self,myspec)
self.settings["mainarch"]="x86"
class arch_x86(generic_x86):
"builder class for generic x86 (486+)"
- def __init__(self):
- base_x86.__init__(self)
+ def __init__(self,myspec):
+ generic_x86.__init__(self,myspec)
self.settings["CFLAGS"]="-O2 -mcpu=i686 -fomit-frame-pointer"
class arch_pentium4(generic_x86):
"builder class for Pentium 4"
- def __init__(self):
- base_x86.__init__(self)
- self.settings["CFLAGS"]="-O2 -mcpu=i686 -fomit-frame-pointer"
+ def __init__(self,myspec):
+ generic_x86.__init__(self,myspec)
+ self.settings["CFLAGS"]="-O2 -march=pentium4 -fomit-frame-pointer -finline-functions -finline-limit=800"
self.settings["CHOST"]="i686-pc-linux-gnu"
self.settings["HOSTUSE"]=["mmx","sse"]
if len(sys.argv)==1 or sys.argv[1] in ["-h","--help"]:
usage()
sys.exit(1)
-elif os.getuid()!=0:
- #non-root callers can still get -h and --help to work.
- die("This script requires root privileges to operate.")
+
+def arg_parse(mydict, myvalids):
+ "very wimpy argument parsing, just for the prototype"
+ for x in sys.argv[1:]:
+ foo=string.split(x,"=")
+ if len(foo)!=2:
+ die("Invalid arg syntax: "+x)
+ else:
+ if foo[0] not in myvalids:
+ die("Invalid arg name: "+foo[0])
+ mydict[foo[0]]=foo[1]
+
+def spec_dump(myspec):
+ for x in myspec.keys():
+ print x+": "+repr(myspec[x])
"""
Overview of catalyst operation
import targets
targetmap={}
targets.register(targetmap)
+
print "Available targets:",string.join(targetmap.keys())
+
+if os.getuid()!=0:
+ #non-root callers can't go any further than here.
+ die("This script requires root privileges to operate.")
+
+#the spec begins!
+validspec=["version_stamp","target","subarch","rel_type","rel_version","snapshot","source_subpath"]
+myspec={}
+
+"""
+local variables from spec:
+
+version_stamp 20031016 user (from spec)
+target stage3 user (from spec)
+subarch pentium4 user (from spec)
+rel_type default user (from spec) (was BUILDTYPE)
+rel_version 1.4 user (from spec) (was MAINVERSION)
+snapshot 20031016 user (from spec)
+source_subpath default-x86-1.4/stage2-pentium4-20031016 user (from spec)
+"""
+
+arg_parse(myspec,validspec)
+#need to verify that we have all required args here. Leaving this out for the prototype.
+if myspec["subarch"] not in subarchmap.keys():
+ die("Sub-arch "+myspec["subarch"]+" not available.")
+
+#call builder constructor:
+mybuilder=subarchmap[myspec["subarch"]](myspec)
+if myspec["target"] not in targetmap.keys():
+ die("Target "+myspec["target"]+" not available.")
+
+#these would come from /etc/catalyst.conf:
+myspec["storedir"]="/var/tmp/catalyst"
+myspec["sharedir"]="/usr/share/catalyst"
+#these would come from there too?:
+myspec["distdir"]="/usr/portage/distfiles"
+myspec["portdir"]="/usr/portage"
+
+#call target constructor:
+mytarget=targetmap[myspec["target"]](myspec)
+print
+spec_dump(myspec)
+
+#to test this program, type:
+
+# ./catalyst subarch=pentium4 version_stamp=20031016 target=stage3 rel_type=default rel_version=1.4 snapshot=20031016 source_subpath=default-x86-1.4/stage2-pentium4-20031016
+
class generic:
- def __init__(self):
- self.settings={}
+ def __init__(self,myspec):
+ self.settings=myspec
def mount_safety_check(self):
"""make sure that no bind mounts exist in chrootdir (to use before
cleaning the directory, to make sure we don't wipe the contents of
"""
class generic_target:
- def __init__(self):
+ def __init__(self,myspec):
+ self.settings=myspec
pass
def run_prep(self):
"""copy scripts into location, generate files containing build
"""return list of definitions required from spec"""
class generic_stage_target(generic_target):
- def spec_require(self):
- return ["version_stamp","subarch","rel_type","rel_version","snapshot","source_subpath"]
+ def __init__(self,myspec):
+ generic_target.__init__(self,myspec)
+ #we'd want to make sure we have all the settings we need here
+ self.settings["target_subpath"]=self.settings["rel_type"]+"-"+self.settings["mainarch"]+"-"+self.settings["rel_version"]
+ self.settings["target_subpath"]+="/"+self.settings["target"]+"-"+self.settings["subarch"]+"-"+self.settings["version_stamp"]
+ st=self.settings["storedir"]
+ self.settings["snapshot_path"]=st+"/snapshots/portage-"+self.settings["snapshot"]+".tar.bz2"
+ self.settings["target_path"]=st+"/builds/"+self.settings["target_subpath"]+".tar.bz2"
+ self.settings["source_path"]=st+"/builds/"+self.settings["source_subpath"]+".tar.bz2"
+ self.settings["chroot_path"]=st+"/tmp/"+self.settings["target_subpath"]
+ self.settings["pkgcache_path"]=st+"/packages/"+self.settings["target_subpath"]
class snapshot_target(generic_target):
def __init__(self):
return ["snapshot"]
class stage1_target(generic_stage_target):
- def __init__(self):
- generic_target.__init__(self)
+ def __init__(self,spec):
+ generic_stage_target.__init__(self,spec)
pass
class stage2_target(generic_stage_target):
- def __init__(self):
- generic_target.__init__(self)
+ def __init__(self,spec):
+ generic_stage_target.__init__(self,spec)
pass
class stage3_target(generic_stage_target):
- def __init__(self):
- generic_target.__init__(self)
+ def __init__(self,spec):
+ generic_stage_target.__init__(self,spec)
pass
class grp_target(generic_stage_target):
- def __init__(self):
- generic_target.__init__(self)
+ def __init__(self,spec):
+ generic_target.__init__(self,spec)
pass
class livecd_target(generic_stage_target):