Move ismount() and pathcompare() from catalyst.support to catalyst.util
authorAndrew Gaffney <agaffney@gentoo.org>
Sun, 11 Jan 2009 22:06:13 +0000 (16:06 -0600)
committerAndrew Gaffney <agaffney@gentoo.org>
Sun, 11 Jan 2009 22:06:13 +0000 (16:06 -0600)
ChangeLog
modules/catalyst/support.py
modules/catalyst/target/generic_stage.py
modules/catalyst/util.py

index 415567aa904ee0e48946f68edaf3144158033984..0fad171f906a5a24925319fcf5d164284caa0618 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,11 @@
 # 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 ismount() and pathcompare() from catalyst.support to catalyst.util
+
   11 Jan 2009; Andrew Gaffney <agaffney@gentoo.org>
   modules/catalyst/support.py:
   Remove unused function hexify()
index b584a40847145df255c1d8c43daafdb4f4d2ff73..1656471ab32a5c0b585126c3255d60f582e4fea3 100644 (file)
@@ -563,31 +563,6 @@ def read_makeconf(mymakeconffile):
                makeconf={}
                return makeconf
 
-def pathcompare(path1,path2):
-       # Change double slashes to slash
-       path1 = re.sub(r"//",r"/",path1)
-       path2 = re.sub(r"//",r"/",path2)
-       # Removing ending slash
-       path1 = re.sub("/$","",path1)
-       path2 = re.sub("/$","",path2)
-
-       if path1 == path2:
-               return 1
-       return 0
-
-def ismount(path):
-       "enhanced to handle bind mounts"
-       if os.path.ismount(path):
-               return 1
-       a=os.popen("mount")
-       mylines=a.readlines()
-       a.close()
-       for line in mylines:
-               mysplit=line.split()
-               if pathcompare(path,mysplit[2]):
-                       return 1
-       return 0
-
 def addl_arg_parse(myspec,addlargs,requiredspec,validspec):
        "helper function to help targets parse additional arguments"
        global valid_config_file_values
index 80469487f28dac39774f9d9674f598a6bc3a7f80..c8350eb8b2d889a0f312627809feb832f93b81fc 100644 (file)
@@ -582,13 +582,13 @@ class generic_stage_target(generic_target):
                        if not os.path.exists(mypath+x):
                                continue
 
-                       if ismount(mypath+x):
+                       if catalyst.util.ismount(mypath+x):
                                """ Something is still mounted "" """
                                try:
                                        print x+" is still mounted; performing auto-bind-umount...",
                                        """ Try to umount stuff ourselves """
                                        self.unbind()
-                                       if ismount(mypath+x):
+                                       if catalyst.util.ismount(mypath+x):
                                                raise CatalystError, "Auto-unbind failed for "+x
                                        else:
                                                print "Auto-unbind successful..."
@@ -880,7 +880,7 @@ class generic_stage_target(generic_target):
                        if not os.path.exists(mypath+x):
                                continue
 
-                       if not ismount(mypath+x):
+                       if not catalyst.util.ismount(mypath+x):
                                continue
 
                        retval=os.system("umount "+\
index dd3eab373aaf24f09e39192e510d262cea5531a3..371c1bfa6327d9b097c60823fcca134e8a715b78 100644 (file)
@@ -73,3 +73,26 @@ def normpath(mypath):
                newpath = newpath[1:]
        return newpath
 
+def pathcompare(path1, path2):
+       # Change double slashes to slash
+       path1 = re.sub(r"//",r"/",path1)
+       path2 = re.sub(r"//",r"/",path2)
+       # Removing ending slash
+       path1 = re.sub("/$","",path1)
+       path2 = re.sub("/$","",path2)
+       if path1 == path2:
+               return True
+       return False
+
+def ismount(path):
+       "enhanced to handle bind mounts"
+       if os.path.ismount(path):
+               return True
+       a = os.popen("mount")
+       mounts = [line.split()[2] for line in a.readlines()]
+       a.close()
+       for mount in mounts:
+               if pathcompare(path, mount):
+                       return True
+       return False
+