From 8d8de79ae8fa307ab5b8af929512c6765bbc69df Mon Sep 17 00:00:00 2001 From: Daniel Robbins Date: Mon, 27 Oct 2003 04:57:43 +0000 Subject: [PATCH] getting closer to working prototype git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/catalyst/trunk@26 d1e1f19c-881f-0410-ab34-b69fee027534 --- arch/x86.py | 13 ++++----- catalyst | 66 +++++++++++++++++++++++++++++++++++++++++++--- modules/builder.py | 4 +-- modules/targets.py | 32 ++++++++++++++-------- 4 files changed, 93 insertions(+), 22 deletions(-) diff --git a/arch/x86.py b/arch/x86.py index a167f812..538d6e03 100644 --- a/arch/x86.py +++ b/arch/x86.py @@ -10,20 +10,21 @@ import builder 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"] diff --git a/catalyst b/catalyst index f2a9128a..7c339483 100755 --- a/catalyst +++ b/catalyst @@ -16,9 +16,21 @@ def usage(): 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 @@ -109,4 +121,52 @@ print "Available subarches:",string.join(subarchmap.keys()) 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 + diff --git a/modules/builder.py b/modules/builder.py index c6b8e24f..a176b423 100644 --- a/modules/builder.py +++ b/modules/builder.py @@ -1,6 +1,6 @@ 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 diff --git a/modules/targets.py b/modules/targets.py index d263a8db..749b1f01 100644 --- a/modules/targets.py +++ b/modules/targets.py @@ -12,7 +12,8 @@ source_subpath default-x86-1.4/stage2-pentium4-20031016 user (from spec) """ 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 @@ -25,8 +26,17 @@ class generic_target: """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): @@ -35,23 +45,23 @@ class snapshot_target(generic_target): 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): -- 2.26.2