should allow pkgcache and ccache to work for stage1 builds
[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 myspec["sharedir"]=os.getcwd()
30 #these would come from there too?:
31 myspec["distdir"]="/mnt/misc/distfiles"
32 myspec["portdir"]="/usr/portage"
33 myspec["options"]="ccache pkgcache"
34 if "ccache" in string.split(myspec["options"]):
35         print "Compiler cache support enabled."
36         myspec["CCACHE"]="1"
37 if "pkgcache" in string.split(myspec["options"]):
38         print "Package cache support enabled."
39         myspec["PKGCACHE"]="1"
40 #determine target, call target constructor and hand it the rest of the arguments
41
42 try:
43         addlargs={}
44         arg_parse(myspec,addlargs)
45         if not targetmap.has_key(myspec["target"]):
46                 raise CatalystError,"Target \""+myspec["target"]+"\" not available."
47         mytarget=targetmap[myspec["target"]](myspec,addlargs)
48         
49         mytarget.run()
50 except CatalystError:
51         sys.exit(1)
52 # Examples:
53 # ./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
54 # ./catalyst target=snapshot version_stamp=20031028