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.environ.has_key["CCACHE_DIR"]:
64 print "Compiler cache support disabled (no CCACHE_DIR defined)"
65 elif not os.path.exists(os.environ["CCACHE_DIR"]):
66 print "Compiler cache support disabled (no cache found at CCACHE_DIR)"
69 print "Compiler cache support enabled."
70 if "pkgcache" in string.split(myspec["options"]):
71 print "Package cache support enabled."
72 myspec["PKGCACHE"]="1"
74 if "distcc" in string.split(myspec["options"]):
75 print "Distcc support enabled."
78 if sys.argv[1] in ["-f", "--file" ]:
80 addlargs=read_spec(sys.argv[2])
82 raise CatalystError,"Unable to read spec file: "+sys.argv[2]
83 unparsedargs=sys.argv[3:]
86 unparsedargs=sys.argv[1:]
88 arg_parse(myspec,addlargs,unparsedargs)
89 if not targetmap.has_key(myspec["target"]):
90 raise CatalystError,"Target \""+myspec["target"]+"\" not available."
91 mytarget=targetmap[myspec["target"]](myspec,addlargs)