+++ /dev/null
-#!/usr/bin/python
-# Copyright 1999-2004 Gentoo Technologies, Inc.
-# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo/src/catalyst/catalyst,v 1.38 2004/06/18 18:06:21 zhen Exp $
-
-import os,sys,imp,string
-
-def usage():
- print "Usage: catalyst [-f file] [variable=value ...]"
- print " -h --help print this usage and exit"
- print " -v --version display version information"
- print " -f --file read specified file for build instructions"
- print " variable=value specify a variable/value pair"
-
-def vers():
- print "Gentoo catalyst, version "+version
- print "Copyright 2003-2004 Gentoo Technologies, Inc."
- print "Distributed under the GNU General Public License version 2"
-
-version="1.0.8.1"
-
-if len(sys.argv)==1 or sys.argv[1] in ["-h","--help"]:
- usage()
- sys.exit(1)
-elif sys.argv[1] in ["-v","--version"]:
- vers()
- sys.exit(1)
-if os.getuid()!=0:
- #non-root callers can't go any further than here.
- print "catalyst: This script requires root privileges to operate."
- sys.exit(1)
-
-myspec={}
-myconf={}
-myconffile="/etc/catalyst/catalyst.conf"
-if os.environ.has_key("clst_conf"):
- if not os.path.exists(os.environ["clst_conf"]):
- print "catalyst: Unable to find config file specified in env var 'clst_conf'"
- sys.exit(1)
- myconffile=os.environ["clst_conf"]
-
-if os.path.exists(myconffile):
- try:
- execfile(myconffile,myconf,myconf)
- except:
- print "catalyst: Unable to parse "+myconffile+" config file (syntax error)"
- sys.exit(1)
-
-confdefaults={ "storedir":"/var/tmp/catalyst","sharedir":"/usr/share/catalyst","distdir":"/usr/portage/distfiles",
-"portdir":"/usr/portage","options":""}
-
-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")
-targetmap={}
-try:
- from catalyst_support import *
- for x in required_build_targets:
- try:
- fh=open(myspec["sharedir"]+"/modules/"+x+".py")
- module=imp.load_module(x,fh,"modules/"+x+".py",(".py","r",imp.PY_SOURCE))
- fh.close()
- except IOError:
- msg("Can't find "+x+".py plugin in "+myspec.settings["sharedir"]+"/modules/")
-
- for x in valid_build_targets:
- try:
- fh=open(myspec["sharedir"]+"/modules/"+x+".py")
- module=imp.load_module(x,fh,"modules/"+x+".py",(".py","r",imp.PY_SOURCE))
- module.register(targetmap)
- fh.close()
- except IOError:
- msg("Can't find "+x+".py plugin in "+myspec.settings["sharedir"]+"/modules/")
-
-except ImportError:
- print "catalyst: python modules not found in "+myspec["sharedir"]+"/modules; exiting."
- sys.exit(1)
-
-if "ccache" in string.split(myspec["options"]):
- print "Compiler cache support enabled."
- myspec["CCACHE"]="1"
-
-if "pkgcache" in string.split(myspec["options"]):
- print "Package cache support enabled."
- myspec["PKGCACHE"]="1"
-
-if "distcc" in string.split(myspec["options"]):
- print "Distcc support enabled."
- myspec["DISTCC"]="1"
-
-if "autoresume" in string.split(myspec["options"]):
- print "Autoresuming support enabled."
- myspec["AUTORESUME"]="1"
-
-if myconf.has_key("envscript"):
- print "Envscript support enabled."
- myspec["ENVSCRIPT"]=myconf["envscript"]
-
-if sys.argv[1] in ["-f", "--file" ]:
- try:
- addlargs=read_spec(sys.argv[2])
- except:
- sys.exit(1)
- unparsedargs=sys.argv[3:]
-else:
- addlargs={}
- unparsedargs=sys.argv[1:]
-try:
- arg_parse(myspec,addlargs,unparsedargs)
- 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)