test fix
[catalyst.git] / catalyst
index b8b8a234c485d83c2a51c786175691f6e44a581e..8337824ece92454a3e340f0b0aa58dacef6008ad 100755 (executable)
--- a/catalyst
+++ b/catalyst
@@ -3,15 +3,29 @@
 import os,sys,imp,string
 
 def usage():
-       print "usage: meep!"
+       print "Usage: catalyst [-f file] [variable=value ...]"
+       print " -h --help               print this usage and exit"
+       print " -v --version            display version information"
+       print " -f --file               read specified file for build instructions"
+       print " variable=value          specify a variable/value pair"
+
+def vers():
+       print "Gentoo catalyst, version "+version
+       print "Copyright 2003-2004 Gentoo Technologies, Inc."
+       print "Distributed under the GNU General Public License version 2"
+
+version="1.0"
 
 if len(sys.argv)==1 or sys.argv[1] in ["-h","--help"]:
        usage()
        sys.exit(1)
-
+elif sys.argv[1] in ["-v","--version"]:
+       vers()
+       sys.exit(1)
 if os.getuid()!=0:
        #non-root callers can't go any further than here. 
-       die("This script requires root privileges to operate.") 
+       print "catalyst: This script requires root privileges to operate."
+       sys.exit(1)
 
 myspec={}
 myconf={}
@@ -53,11 +67,18 @@ if "ccache" in string.split(myspec["options"]):
 if "pkgcache" in string.split(myspec["options"]):
        print "Package cache support enabled."
        myspec["PKGCACHE"]="1"
-#determine target, call target constructor and hand it the rest of the arguments
 
-try:
+if sys.argv[1] in ["-f", "--file" ]:
+       try:
+               addlargs=read_spec(sys.argv[2])
+       except:
+               raise CatalystError,"Unable to read spec file: "+sys.argv[2]
+       unparsedargs=sys.argv[3:]
+else:
        addlargs={}
-       arg_parse(myspec,addlargs)
+       unparsedargs=sys.argv[1:]
+try:
+       arg_parse(myspec,addlargs,unparsedargs)
        if not targetmap.has_key(myspec["target"]):
                raise CatalystError,"Target \""+myspec["target"]+"\" not available."
        mytarget=targetmap[myspec["target"]](myspec,addlargs)
@@ -65,6 +86,3 @@ try:
        mytarget.run()
 except CatalystError:
        sys.exit(1)
-# Examples:
-# ./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
-# ./catalyst target=snapshot version_stamp=20031028