Move read_makeconf() and parse_makeconf() from catalyst.support to catalyst.util
authorAndrew Gaffney <agaffney@gentoo.org>
Sun, 11 Jan 2009 23:21:20 +0000 (17:21 -0600)
committerAndrew Gaffney <agaffney@gentoo.org>
Sun, 11 Jan 2009 23:21:20 +0000 (17:21 -0600)
ChangeLog
modules/catalyst/support.py
modules/catalyst/target/generic_stage.py
modules/catalyst/util.py

index 478527d6ecd9625f3ff13ce06d79741238803ebd..97cab638fb2e7cc9440ec790c92843dbb0abedf1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,12 @@
 # Copyright 2002-2009 Gentoo Foundation; 2008-2009 Various authors (see AUTHORS)
 # Distributed under the GPL v2
 
+  11 Jan 2009; Andrew Gaffney <agaffney@gentoo.org>
+  modules/catalyst/support.py, modules/catalyst/target/generic_stage.py,
+  modules/catalyst/util.py:
+  Move read_makeconf() and parse_makeconf() from catalyst.support to
+  catalyst.util
+
   11 Jan 2009; Andrew Gaffney <agaffney@gentoo.org>
   modules/catalyst/support.py, modules/catalyst/target/generic_stage.py,
   modules/catalyst/target/livecd_stage2.py,
index 8d2c0a9c862c576f58cf01005459e949b40bd8c9..6354ac5ef1f9ad8b2e29604014e1c9af2de1255a 100644 (file)
@@ -1,7 +1,5 @@
 
-import sys, os, re, signal
-from catalyst.output import warn
-import catalyst.util
+import os, re
 from catalyst.error import *
 
 required_config_file_values=["storedir","sharedir","distdir","portdir"]
@@ -50,49 +48,6 @@ defined are not preserved. In other words, "foo", "bar", "oni" ordering is prese
 "item2" "item3" ordering is not, as the item strings are stored in a dictionary (hash).
 """
 
-def parse_makeconf(mylines):
-       mymakeconf={}
-       pos=0
-       pat=re.compile("([0-9a-zA-Z_]*)=(.*)")
-       while pos<len(mylines):
-               if len(mylines[pos])<=1:
-                       #skip blanks
-                       pos += 1
-                       continue
-               if mylines[pos][0] in ["#"," ","\t"]:
-                       #skip indented lines, comments
-                       pos += 1
-                       continue
-               else:
-                       myline=mylines[pos]
-                       mobj=pat.match(myline)
-                       pos += 1
-                       if mobj.group(2):
-                           clean_string = re.sub(r"\"",r"",mobj.group(2))
-                           mymakeconf[mobj.group(1)]=clean_string
-       return mymakeconf
-
-def read_makeconf(mymakeconffile):
-       if os.path.exists(mymakeconffile):
-               try:
-                       try:
-                               import snakeoil.fileutils
-                               return snakeoil.fileutils.read_bash_dict(mymakeconffile, sourcing_command="source")
-                       except ImportError:
-                               try:
-                                       import portage_util
-                                       return portage_util.getconfig(mymakeconffile, tolerant=1, allow_sourcing=True)
-                               except ImportError:
-                                       myf=open(mymakeconffile,"r")
-                                       mylines=myf.readlines()
-                                       myf.close()
-                                       return parse_makeconf(mylines)
-               except:
-                       raise CatalystError, "Could not parse make.conf file "+mymakeconffile
-       else:
-               makeconf={}
-               return makeconf
-
 def addl_arg_parse(myspec,addlargs,requiredspec,validspec):
        "helper function to help targets parse additional arguments"
        global valid_config_file_values
index 1d73e858e457ee371c8df1a1e524c13cf7545b68..222f586cedb47ff9c160bbf3d2b36950c22512f5 100644 (file)
@@ -920,7 +920,7 @@ class generic_stage_target(generic_target):
                                "Couldn't umount one or more bind-mounts; aborting for safety."
 
        def chroot_setup(self):
-               self.makeconf=read_makeconf(self.settings["chroot_path"]+\
+               self.makeconf=catalyst.util.read_makeconf(self.settings["chroot_path"]+\
                        "/etc/make.conf")
                self.override_cbuild()
                self.override_chost()
@@ -933,7 +933,7 @@ class generic_stage_target(generic_target):
                else:
                        print "Setting up chroot..."
 
-                       #self.makeconf=read_makeconf(self.settings["chroot_path"]+"/etc/make.conf")
+                       #self.makeconf=catalyst.util.read_makeconf(self.settings["chroot_path"]+"/etc/make.conf")
 
                        cmd("cp /etc/resolv.conf "+self.settings["chroot_path"]+"/etc",\
                                "Could not copy resolv.conf into place.",env=self.env)
index 3bb35fbfc964c77c8859dc16d7b9498188e756c6..d6a71224243ca077bc2b5d0d59d23f089815b56e 100644 (file)
@@ -132,3 +132,47 @@ def file_locate(settings, filelist, expand=True):
                            settings[myfile] = os.getcwd() + "/" + settings[myfile]
                    else:
                            raise CatalystError, "Cannot locate specified " + myfile + ": " + settings[myfile] + " (2nd try)"
+
+def parse_makeconf(mylines):
+       mymakeconf={}
+       pos=0
+       pat=re.compile("([0-9a-zA-Z_]*)=(.*)")
+       while pos<len(mylines):
+               if len(mylines[pos])<=1:
+                       #skip blanks
+                       pos += 1
+                       continue
+               if mylines[pos][0] in ["#"," ","\t"]:
+                       #skip indented lines, comments
+                       pos += 1
+                       continue
+               else:
+                       myline=mylines[pos]
+                       mobj=pat.match(myline)
+                       pos += 1
+                       if mobj.group(2):
+                           clean_string = re.sub(r"\"",r"",mobj.group(2))
+                           mymakeconf[mobj.group(1)]=clean_string
+       return mymakeconf
+
+def read_makeconf(mymakeconffile):
+       if os.path.exists(mymakeconffile):
+               try:
+                       try:
+                               import snakeoil.fileutils
+                               return snakeoil.fileutils.read_bash_dict(mymakeconffile, sourcing_command="source")
+                       except ImportError:
+                               try:
+                                       import portage_util
+                                       return portage_util.getconfig(mymakeconffile, tolerant=1, allow_sourcing=True)
+                               except ImportError:
+                                       myf=open(mymakeconffile,"r")
+                                       mylines=myf.readlines()
+                                       myf.close()
+                                       return parse_makeconf(mylines)
+               except:
+                       raise CatalystError, "Could not parse make.conf file "+mymakeconffile
+       else:
+               makeconf={}
+               return makeconf
+