getting closer to working prototype
authorDaniel Robbins <drobbins@gentoo.org>
Mon, 27 Oct 2003 04:57:43 +0000 (04:57 +0000)
committerDaniel Robbins <drobbins@gentoo.org>
Mon, 27 Oct 2003 04:57:43 +0000 (04:57 +0000)
git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/catalyst/trunk@26 d1e1f19c-881f-0410-ab34-b69fee027534

arch/x86.py
catalyst
modules/builder.py
modules/targets.py

index a167f812826bbb9cac37b74808e2d477abd2e72d..538d6e036d25ec3dbefb8a5cb1fd51f9ee9295dd 100644 (file)
@@ -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"]
 
index f2a9128a2023f57763f5d15cae558cc8ae7b643f..7c339483e370738a6ed3e9935786e6744960f4a0 100755 (executable)
--- 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
+
index c6b8e24f1a16e2f3f05c78e15fa822372af42f84..a176b42364677d7bdcdd67ab4c87f8dfa5ef0d59 100644 (file)
@@ -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
index d263a8db042b0b046b89cd14fc1a1b25984fea1a..749b1f018164e02f040902175290bf55a9d62a85 100644 (file)
@@ -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):