catalyst!
[catalyst.git] / catalyst
1 #!/usr/bin/python
2
3 import os,sys,imp,string
4
5 #This allows plugins (and this code) to import modules in the /modules dir
6 sys.path.append(os.getcwd()+"/modules")
7
8 from catalyst_support import *
9
10 def usage():
11         print "usage: meep!"
12
13 if len(sys.argv)==1 or sys.argv[1] in ["-h","--help"]:
14         usage()
15         sys.exit(1)
16
17 import targets
18 targetmap={}
19 targets.register(targetmap)
20
21 if os.getuid()!=0:
22         #non-root callers can't go any further than here. 
23         die("This script requires root privileges to operate.") 
24
25 myspec={}
26 #these would come from /etc/catalyst.conf:
27 myspec["storedir"]="/var/tmp/catalyst"
28 myspec["sharedir"]="/usr/share/catalyst"
29 #these would come from there too?:
30 myspec["distdir"]="/mnt/misc/distfiles"
31 myspec["portdir"]="/usr/portage"
32 myspec["options"]="ccache pkgcache"
33 if "ccache" in string.split(myspec["options"]):
34         print "Compiler cache support enabled."
35         myspec["CCACHE"]="1"
36 if "pkgcache" in string.split(myspec["options"]):
37         print "Package cache support enabled."
38         myspec["PKGCACHE"]="1"
39 #determine target, call target constructor and hand it the rest of the arguments
40
41 try:
42         addlargs={}
43         arg_parse(myspec,addlargs)
44         if not targetmap.has_key(myspec["target"]):
45                 raise CatalystError,"Target \""+myspec["target"]+"\" not available."
46         mytarget=targetmap[myspec["target"]](myspec,addlargs)
47         
48         mytarget.run()
49 except CatalystError:
50         sys.exit(1)
51 # Examples:
52 # ./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
53 # ./catalyst target=snapshot version_stamp=20031028