Create umount module

This commit is contained in:
Aurélien Gâteau 2014-07-24 13:51:14 +02:00
parent 2a231b3532
commit 92114576ce
3 changed files with 58 additions and 0 deletions

View File

@ -34,6 +34,7 @@ install:
- locale - locale
- keyboard - keyboard
#- users #- users
- umount
# Phase 3 - postinstall. # Phase 3 - postinstall.
# View modules are shown as UI pages, jobs from job modules are executed immediately in # View modules are shown as UI pages, jobs from job modules are executed immediately in

View File

@ -0,0 +1,51 @@
#!/usr/bin/env python3
# encoding: utf-8
# === This file is part of Calamares - <http://github.com/calamares> ===
#
# Copyright 2014, Aurélien Gâteau <agateau@kde.org>
#
# Calamares is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Calamares is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Calamares. If not, see <http://www.gnu.org/licenses/>.
import os
import subprocess
import libcalamares
def listMounts( rootMountPoint ):
lst = []
for line in open( "/etc/mtab" ).readlines():
device, mountPoint, _ = line.split( " ", 2 )
if mountPoint.startswith( rootMountPoint ):
lst.append( ( device, mountPoint ) )
return lst
def calamares_main():
rootMountPoint = libcalamares.global_storage.value( "rootMountPoint" )
if not rootMountPoint:
return "GlobalStorage does not contain a \"rootMountPoint\" key, doing nothing"
if not os.path.exists( rootMountPoint ):
return "GlobalStorage[\"rootMountPoint\"] is \"{}\", which does not exist, doing nothing".format( rootMountPoint )
lst = listMounts( rootMountPoint )
# Sort the list by mount point in decreasing order. This way we can be sure
# we unmount deeper dirs first.
lst.sort( key = lambda x: x[ 1 ], reverse = True )
for device, mountPoint in lst:
subprocess.check_call( [ "umount", mountPoint ] )
os.rmdir( rootMountPoint )
return "All done"

View File

@ -0,0 +1,6 @@
type: "job"
name: "umount"
interface: "python"
requires: []
script: "main.py"
configuration: