rewrote the main catalyst driver script. fixed up arg_parse in catalyst_support.py...
authorJohn P. Davis <zhen@gentoo.org>
Sun, 11 Jul 2004 21:22:07 +0000 (21:22 +0000)
committerJohn P. Davis <zhen@gentoo.org>
Sun, 11 Jul 2004 21:22:07 +0000 (21:22 +0000)
git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/catalyst/trunk@406 d1e1f19c-881f-0410-ab34-b69fee027534

ChangeLog
catalyst [moved from catalyst.new.py with 91% similarity]
modules/catalyst_support.py

index 7148b2739f8f69f87667dc76eb01b342ee8728fa..3dc69acae9cd112942e77af827983500e37a3550 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,14 @@
 # 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.67 2004/07/03 00:33:37 zhen Exp $
+# $Header: /var/cvsroot/gentoo/src/catalyst/ChangeLog,v 1.68 2004/07/11 21:22:07 zhen Exp $
+
+  11 Jul 2004; <zhen@gentoo.org> +catalyst, -catalyst.new.py,
+  modules/catalyst_support.py:
+  completely rewrote the catalyst main script so that it can actually utilize
+  more than one command line flag. new functionality included, but not active
+  yet (--debug and --verbose). arguments can still be passed on the commandline
+  through the use of the -C (--cli) flag. updated the arg_parse function in
+  catalyst_support.py to accomodate my changes.
 
   02 Jul 2004; John Davis <zhen@gentoo.org> modules/generic_stage_target.py,
   modules/generic_target.py, modules/grp_target.py,
similarity index 91%
rename from catalyst.new.py
rename to catalyst
index 6123f05bd8c28cba0f1fc7aace82a77e6277c9ec..4228e84ca96e2ee1dd5d90c82fa89b57a2c7a6e0 100755 (executable)
+++ b/catalyst
@@ -1,7 +1,7 @@
 #!/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/Attic/catalyst.new.py,v 1.1 2004/07/07 01:46:31 zhen Exp $
+# $Header: /var/cvsroot/gentoo/src/catalyst/catalyst,v 1.40 2004/07/11 21:22:07 zhen Exp $
 
 # Maintained in full by John Davis <zhen@gentoo.org>
 
@@ -123,7 +123,7 @@ def import_modules():
                                        conf_values.settings["sharedir"]+"/modules/"
 
        except ImportError:
-               print "!!! catalyst: python modules not found in "+\
+               print "!!! catalyst: Python modules not found in "+\
                        conf_values["sharedir"]+"/modules; exiting."
                sys.exit(1)
 
@@ -135,8 +135,16 @@ def do_spec(myspecfile):
        except:
                sys.exit(1)
                
-       return addlargs 
-               
+       return addlargs
+
+def do_cli(cmdline):
+       try:
+               return arg_parse(cmdline)
+       
+       except CatalystError:
+               print "!!! catalyst: Could not parse commandline, exiting."
+               sys.exit(1)
+       
 def build_target(addlargs, targetmap):
        try:
                if not targetmap.has_key(addlargs["target"]):
@@ -165,7 +173,7 @@ if __name__ == "__main__":
        # parse out the command line arguments
        try:
                opts,args = getopt.getopt(sys.argv[1:], "hvdc:C:f:V", ["help", "version", "debug",\
-                       "config=", "commandline=", "file=", "verbose"])
+                       "config=", "cli=", "file=", "verbose"])
        
        except getopt.GetoptError:
                usage()
@@ -193,13 +201,12 @@ if __name__ == "__main__":
                if o in ("-c", "--config"):
                        myconfig=a
 
-               # needs some work
                if o in ("-C", "--cli"):
-                       if type(a)==types.StringType:
-                               mycmdline=[a]
-                       else:
-                               mycmdline=a
-               
+                       x=sys.argv.index(o)+1
+                       while x < len(sys.argv):
+                               mycmdline.append(sys.argv[x])
+                               x=x+1
+                       
                if o in ("-f", "--file"):
                        myspecfile=a
                        
@@ -216,6 +223,9 @@ if __name__ == "__main__":
 
        if myspecfile:
                addlargs=do_spec(myspecfile)
+       
+       if mycmdline:
+               addlargs=do_cli(mycmdline)
 
        # everything is setup, so the build is a go
        try:
index ae0fa88a44bb9a1cbe962db867a58d73980631be..df5c392e512e834722543ff3603251172233c279 100644 (file)
@@ -1,6 +1,6 @@
 # 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.24 2004/06/18 18:06:21 zhen Exp $
+# $Header: /var/cvsroot/gentoo/src/catalyst/modules/catalyst_support.py,v 1.25 2004/07/11 21:22:07 zhen Exp $
 
 import sys,string,os,types
 
@@ -210,21 +210,22 @@ def ismount(path):
                        return 1
        return 0
 
-def arg_parse(mydict,remaining,argv):
-       "grab settings from argv, storing 'target' in mydict, and everything in remaining for later parsing"
-       global required_config_file_values
-       for x in argv:
+def arg_parse(cmdline):
+       #global required_config_file_values
+       mydict={}
+       for x in cmdline:
                foo=string.split(x,"=")
                if len(foo)!=2:
                        raise CatalystError, "Invalid arg syntax: "+x
-               remaining[foo[0]]=foo[1]
-       if not remaining.has_key("target"):
-               raise CatalystError, "Required value \"target\" not specified."
-       mydict["target"]=remaining["target"]
-       for x in required_config_file_values:
-               if not mydict.has_key(x):
-                       raise CatalystError, "Required config file value \""+x+"\" not found."
 
+               else:
+                       mydict[foo[0]]=foo[1]
+       
+       if not mydict.has_key("target"):
+               raise CatalystError, "Required value \"target\" not specified."
+       
+       # if all is well, we should return (we should have bailed before here if not)
+       return mydict
                
 def addl_arg_parse(myspec,addlargs,requiredspec,validspec):
        "helper function to help targets parse additional arguments"