# 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()
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
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..."
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 "+\
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
+