3 import os,sys,imp,string
6 print "Usage: catalyst [-f file] [variable=value ...]"
7 print " -h --help print this usage and exit"
8 print " -v --version display version information"
9 print " -f --file read specified file for build instructions"
10 print " variable=value specify a variable/value pair"
13 print "Gentoo catalyst, version "+version
14 print "Copyright 2003-2004 Gentoo Technologies, Inc."
15 print "Distributed under the GNU General Public License version 2"
19 if len(sys.argv)==1 or sys.argv[1] in ["-h","--help"]:
22 elif sys.argv[1] in ["-v","--version"]:
26 #non-root callers can't go any further than here.
27 print "catalyst: This script requires root privileges to operate."
32 if os.path.exists("/etc/catalyst.conf"):
34 execfile("/etc/catalyst.conf",myconf,myconf)
36 print "catalyst: Unable to /etc/catalyst.conf config file (syntax error)"
39 confdefaults={ "storedir":"/var/tmp/catalyst","sharedir":"/usr/share/catalyst","distdir":"/usr/portage/distfiles",
40 "portdir":"/usr/portage","options":"ccache"}
42 for x in confdefaults.keys():
44 print "Setting",x,"to config file value \""+myconf[x]+"\""
47 print "Setting",x,"to default value \""+confdefaults[x]+"\""
48 myspec[x]=confdefaults[x]
50 #This allows plugins (and this code) to import modules in the /modules dir
51 sys.path.append(myspec["sharedir"]+"/modules")
53 from catalyst_support import *
56 print "catalyst: python modules not found in "+myspec["sharedir"]+"/modules; exiting."
60 targets.register(targetmap)
62 if "ccache" in string.split(myspec["options"]):
63 if not os.path.exists("/root/.ccache"):
64 os.makedirs("/root/.ccache")
65 print "Compiler cache support enabled."
67 if "pkgcache" in string.split(myspec["options"]):
68 print "Package cache support enabled."
69 myspec["PKGCACHE"]="1"
71 if sys.argv[1] in ["-f", "--file" ]:
73 addlargs=read_spec(sys.argv[2])
75 raise CatalystError,"Unable to read spec file: "+sys.argv[2]
76 unparsedargs=sys.argv[3:]
79 unparsedargs=sys.argv[1:]
81 arg_parse(myspec,addlargs,unparsedargs)
82 if not targetmap.has_key(myspec["target"]):
83 raise CatalystError,"Target \""+myspec["target"]+"\" not available."
84 mytarget=targetmap[myspec["target"]](myspec,addlargs)