2014-07-22 17:38:20 +02:00
|
|
|
#!/usr/bin/env python3
|
2015-02-18 15:06:10 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
2014-07-22 17:38:20 +02:00
|
|
|
# === 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/>.
|
|
|
|
|
2014-07-24 10:17:46 +02:00
|
|
|
import tempfile
|
2014-07-22 17:38:20 +02:00
|
|
|
|
2014-07-24 10:17:46 +02:00
|
|
|
import libcalamares
|
2014-07-22 17:38:20 +02:00
|
|
|
|
2014-07-24 17:14:56 +02:00
|
|
|
|
2014-07-29 14:45:58 +02:00
|
|
|
def mount_partitions(root_mount_point, partitions):
|
2015-02-21 10:37:56 +01:00
|
|
|
""" Pass back mount point and filesystem for each partition.
|
2015-02-20 20:54:25 +01:00
|
|
|
|
|
|
|
:param root_mount_point:
|
|
|
|
:param partitions:
|
|
|
|
"""
|
2014-07-22 17:38:20 +02:00
|
|
|
for partition in partitions:
|
2016-05-05 13:35:42 +02:00
|
|
|
if "mountPoint" not in partition or not partition["mountPoint"]:
|
2014-07-22 17:38:20 +02:00
|
|
|
continue
|
2014-07-24 17:14:56 +02:00
|
|
|
# Create mount point with `+` rather than `os.path.join()` because
|
2014-07-24 17:51:51 +02:00
|
|
|
# `partition["mountPoint"]` starts with a '/'.
|
2014-07-29 14:45:58 +02:00
|
|
|
mount_point = root_mount_point + partition["mountPoint"]
|
2014-09-24 18:13:05 +02:00
|
|
|
fstype = partition.get("fs", "")
|
2015-06-14 13:04:52 +02:00
|
|
|
|
2014-09-24 18:25:56 +02:00
|
|
|
if fstype == "fat16" or fstype == "fat32":
|
2014-09-24 18:13:05 +02:00
|
|
|
fstype = "vfat"
|
|
|
|
|
2016-05-05 13:35:42 +02:00
|
|
|
if partition["isLuks"]:
|
2016-05-05 12:49:58 +02:00
|
|
|
libcalamares.utils.debug("about to mount {!s}".format(partition["luksMapperName"]))
|
2016-04-30 16:34:34 +02:00
|
|
|
libcalamares.utils.mount(partition["luksMapperName"],
|
|
|
|
mount_point,
|
|
|
|
fstype,
|
|
|
|
partition.get("options", ""),
|
|
|
|
)
|
|
|
|
|
|
|
|
else:
|
|
|
|
libcalamares.utils.mount(partition["device"],
|
|
|
|
mount_point,
|
|
|
|
fstype,
|
|
|
|
partition.get("options", ""),
|
|
|
|
)
|
2014-07-22 17:38:20 +02:00
|
|
|
|
|
|
|
|
2014-07-25 16:41:21 +02:00
|
|
|
def run():
|
2015-02-21 10:37:56 +01:00
|
|
|
""" Define mountpoints.
|
2015-02-20 20:54:25 +01:00
|
|
|
|
|
|
|
:return:
|
|
|
|
"""
|
2014-07-29 14:45:58 +02:00
|
|
|
root_mount_point = tempfile.mkdtemp(prefix="calamares-root-")
|
|
|
|
partitions = libcalamares.globalstorage.value("partitions")
|
2014-07-30 15:37:11 +02:00
|
|
|
extra_mounts = libcalamares.job.configuration["extraMounts"]
|
2014-10-12 19:45:02 +02:00
|
|
|
extra_mounts_efi = libcalamares.job.configuration["extraMountsEfi"]
|
2014-07-24 17:14:56 +02:00
|
|
|
|
|
|
|
# Sort by mount points to ensure / is mounted before the rest
|
2014-07-29 14:45:58 +02:00
|
|
|
partitions.sort(key=lambda x: x["mountPoint"])
|
2014-07-30 15:37:11 +02:00
|
|
|
mount_partitions(root_mount_point, partitions)
|
|
|
|
mount_partitions(root_mount_point, extra_mounts)
|
2014-12-05 00:17:33 +01:00
|
|
|
fw_type = libcalamares.globalstorage.value("firmwareType")
|
2015-06-14 13:04:52 +02:00
|
|
|
|
2014-12-05 00:17:33 +01:00
|
|
|
if fw_type == 'efi':
|
2014-10-12 19:45:02 +02:00
|
|
|
mount_partitions(root_mount_point, extra_mounts_efi)
|
2014-07-24 17:14:56 +02:00
|
|
|
|
2014-07-29 14:45:58 +02:00
|
|
|
libcalamares.globalstorage.insert("rootMountPoint", root_mount_point)
|
2015-06-14 13:04:52 +02:00
|
|
|
|
2014-12-05 00:17:33 +01:00
|
|
|
# Remember the extra mounts for the unpackfs module
|
|
|
|
if fw_type == 'efi':
|
|
|
|
libcalamares.globalstorage.insert("extraMounts", extra_mounts + extra_mounts_efi)
|
|
|
|
else:
|
|
|
|
libcalamares.globalstorage.insert("extraMounts", extra_mounts)
|
|
|
|
|
2014-07-28 17:03:22 +02:00
|
|
|
return None
|