beta config file support
authorDaniel Robbins <drobbins@gentoo.org>
Thu, 6 Nov 2003 01:50:47 +0000 (01:50 +0000)
committerDaniel Robbins <drobbins@gentoo.org>
Thu, 6 Nov 2003 01:50:47 +0000 (01:50 +0000)
git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/catalyst/trunk@48 d1e1f19c-881f-0410-ab34-b69fee027534

catalyst

index aac11c42f54a3ee7afef28230073296e478c1860..a2221aa93e250cdd610fff78926b9fdaa49fbb7c 100755 (executable)
--- a/catalyst
+++ b/catalyst
@@ -23,14 +23,24 @@ if os.getuid()!=0:
        die("This script requires root privileges to operate.") 
 
 myspec={}
-#these would come from /etc/catalyst.conf:
-myspec["storedir"]="/var/tmp/catalyst"
-#myspec["sharedir"]="/usr/share/catalyst"
-myspec["sharedir"]=os.getcwd()
-#these would come from there too?:
-myspec["distdir"]="/mnt/misc/distfiles"
-myspec["portdir"]="/usr/portage"
-myspec["options"]="ccache pkgcache"
+myconf={}
+if os.path.exists("/etc/catalyst.conf"):
+       try:
+               execfile("/etc/catalyst.conf",myconf,myconf)
+       except:
+               raise CatalystError, "Unable to read config file (syntax error)"
+
+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]
+
 if "ccache" in string.split(myspec["options"]):
        print "Compiler cache support enabled."
        myspec["CCACHE"]="1"