3 import os,sys,imp,string
11 print "catalyst: "+msg
16 if len(sys.argv)==1 or sys.argv[1] in ["-h","--help"]:
20 #non-root callers can still get -h and --help to work.
21 die("This script requires root privileges to operate.")
24 Overview of catalyst operation
25 ==============================
27 * The program starts, and the local machine type is detected.
29 * Based on this information, catalyst determines what kind of machine types
30 it can build for (amd64 and ia64 can build for x86 as well, for example.)
31 The appropriate arch plugins are loaded, which contain builder classes
32 for each supported sub-arch.
34 * Command-line arguments are parsed. If specified, a spec file is read.
36 * These build variables are stored in an internal "spec" object, which will
37 be a standard python dictionary. This spec dictionary contains all relevant
38 build-related information.
40 * The spec object is passed to the appropriate subarch builder constructor.
41 The subarch builder constructor updates the spec object with variables
42 relevant to the sub-arch (pentium4, g3, etc.)
44 * The spec object is passed to the appropriate target constructor.
45 The target constructor updates the spec object to contain data relevant
46 to the particular target (stage1, stage3, grp, etc.)
48 * The full data of the spec object is written to disc, so there is a complete
49 record of all variables that will be used to build what we're building.
50 This will allow for another person to re-use this information to
51 replicate our work (it should be possible to distribute a spec file
52 along with a portage snapshot and a starter tarball, and our build can
53 be replicated exactly on any machine.) The spec object contains data like
54 CFLAGS, CHOST, subarch, mainarch, the profile used to build, and for GRP
55 and LiveCDs the complete package build list. This is important to allow
56 work to be replicated. It's possible that the stage1/2/3.sh scripts should
57 be distributed as well, to allow proper replication of work.
59 * The build process begins by calling the appropriate method of the builder
60 instance. This includes cleanup, setup of chroot, entering the chroot,
61 running the appropriate bash build script, checking for error conditions,
64 * The catalyst process is now complete :)
69 #This allows plugins to import modules in the /modules dir
70 sys.path.append(os.getcwd()+"/modules")
72 #map current machine information from uname() to the mainarch we are running
75 machinemap={ "i386" : "x86",
82 # map the mainarch we are running under to the mainarches we support for
83 # building stages and LiveCDs. (for example, on amd64, we can build stages for
86 targetmap={ "x86" : ["x86"],
87 "amd64" : ["x86","amd64"]
90 mymachine=os.uname()[4]
91 if not machinemap.has_key(mymachine):
92 print "Unknown machine type:",mymachine
94 hostarch=machinemap[mymachine]
95 print "Host architecture:",hostarch
96 print "Supported architectures for targets:",string.join(targetmap[hostarch])
97 print "Loading plugins:",
100 for x in targetmap[hostarch]:
101 fh=open("arch/"+x+".py")
102 #this next line loads the plugin as a module and assigns it to archmap[x]
103 archmap[x]=imp.load_module(x,fh,"arch/"+x+".py",(".py","r",imp.PY_SOURCE))
104 #this next line registers all the subarches supported in the plugin
105 archmap[x].register(subarchmap)
109 print "Available subarches:",string.join(subarchmap.keys())
113 targets.register(targetmap)
114 print "Available targets:",string.join(targetmap.keys())