From: Andrew Gaffney Date: Sun, 11 Jan 2009 22:06:13 +0000 (-0600) Subject: Move ismount() and pathcompare() from catalyst.support to catalyst.util X-Git-Tag: CATALYST-2.0.10~3^2~201 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=fb80c18d98d0e72500b874c6eeed25c75120ea06;p=catalyst.git Move ismount() and pathcompare() from catalyst.support to catalyst.util --- diff --git a/ChangeLog b/ChangeLog index 415567aa..0fad171f 100644 --- 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 + 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 modules/catalyst/support.py: Remove unused function hexify() diff --git a/modules/catalyst/support.py b/modules/catalyst/support.py index b584a408..1656471a 100644 --- a/modules/catalyst/support.py +++ b/modules/catalyst/support.py @@ -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 diff --git a/modules/catalyst/target/generic_stage.py b/modules/catalyst/target/generic_stage.py index 80469487..c8350eb8 100644 --- a/modules/catalyst/target/generic_stage.py +++ b/modules/catalyst/target/generic_stage.py @@ -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 "+\ diff --git a/modules/catalyst/util.py b/modules/catalyst/util.py index dd3eab37..371c1bfa 100644 --- a/modules/catalyst/util.py +++ b/modules/catalyst/util.py @@ -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 +