#!/usr/bin/python import os,sys,imp,string def usage(): print "usage: meep!" if len(sys.argv)==1 or sys.argv[1] in ["-h","--help"]: usage() 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.") myspec={} myconf={} if os.path.exists("/etc/catalyst.conf"): try: execfile("/etc/catalyst.conf",myconf,myconf) except: print "catalyst: Unable to /etc/catalyst.conf config file (syntax error)" sys.exit(1) confdefaults={ "storedir":"/var/tmp/catalyst","sharedir":"/usr/share/catalyst","distdir":"/usr/portage/distfiles", "portdir":"/usr/portage","options":"ccache"} for x in confdefaults.keys(): if myconf.has_key(x): print "Setting",x,"to config file value \""+myconf[x]+"\"" myspec[x]=myconf[x] else: print "Setting",x,"to default value \""+confdefaults[x]+"\"" myspec[x]=confdefaults[x] #This allows plugins (and this code) to import modules in the /modules dir sys.path.append(myspec["sharedir"]+"/modules") try: from catalyst_support import * import targets except ImportError: print "catalyst: python modules not found in "+myspec["sharedir"]+"/modules; exiting." sys.exit(1) targetmap={} targets.register(targetmap) if "ccache" in string.split(myspec["options"]): if not os.path.exists("/root/.ccache"): os.makedirs("/root/.ccache") print "Compiler cache support enabled." myspec["CCACHE"]="1" 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: addlargs={} arg_parse(myspec,addlargs) if not targetmap.has_key(myspec["target"]): raise CatalystError,"Target \""+myspec["target"]+"\" not available." mytarget=targetmap[myspec["target"]](myspec,addlargs) 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