PEPify umount
This commit is contained in:
parent
2ba96d3b6b
commit
2b097e7f3c
@ -23,29 +23,33 @@ import subprocess
|
|||||||
import libcalamares
|
import libcalamares
|
||||||
|
|
||||||
|
|
||||||
def listMounts( rootMountPoint ):
|
def list_mounts(root_mount_point):
|
||||||
lst = []
|
lst = []
|
||||||
for line in open("/etc/mtab").readlines():
|
for line in open("/etc/mtab").readlines():
|
||||||
device, mountPoint, _ = line.split( " ", 2 )
|
device, mount_point, _ = line.split(" ", 2)
|
||||||
if mountPoint.startswith( rootMountPoint ):
|
if mount_point.startswith(root_mount_point):
|
||||||
lst.append( ( device, mountPoint ) )
|
lst.append((device, mount_point))
|
||||||
return lst
|
return lst
|
||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
rootMountPoint = libcalamares.globalStorage.value( "rootMountPoint" )
|
root_mount_point = libcalamares.globalstorage.value("rootMountPoint")
|
||||||
if not rootMountPoint:
|
if not root_mount_point:
|
||||||
return ( "No mount point for root partition in GlobalStorage", "GlobalStorage does not contain a \"rootMountPoint\" key, doing nothing" )
|
return ("No mount point for root partition in globalstorage",
|
||||||
if not os.path.exists( rootMountPoint ):
|
"globalstorage does not contain a \"rootMountPoint\" key, "
|
||||||
return ( "Bad mount point for root partition in GlobalStorage", "GlobalStorage[\"rootMountPoint\"] is \"{}\", which does not exist, doing nothing".format( rootMountPoint ) )
|
"doing nothing")
|
||||||
|
if not os.path.exists(root_mount_point):
|
||||||
|
return ("Bad mount point for root partition in globalstorage",
|
||||||
|
"globalstorage[\"rootMountPoint\"] is \"{}\", which does not "
|
||||||
|
"exist, doing nothing".format(root_mount_point))
|
||||||
|
|
||||||
lst = listMounts( rootMountPoint )
|
lst = list_mounts(root_mount_point)
|
||||||
# Sort the list by mount point in decreasing order. This way we can be sure
|
# Sort the list by mount point in decreasing order. This way we can be sure
|
||||||
# we unmount deeper dirs first.
|
# we unmount deeper dirs first.
|
||||||
lst.sort(key=lambda x: x[1], reverse=True)
|
lst.sort(key=lambda x: x[1], reverse=True)
|
||||||
|
|
||||||
for device, mountPoint in lst:
|
for device, mount_point in lst:
|
||||||
subprocess.check_call( [ "umount", mountPoint ] )
|
subprocess.check_call(["umount", mount_point])
|
||||||
|
|
||||||
os.rmdir( rootMountPoint )
|
os.rmdir(root_mount_point)
|
||||||
return None
|
return None
|
||||||
|
Loading…
Reference in New Issue
Block a user