Compare commits
28 Commits
v2.2.3
...
v2.3-alpha
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fb04800d4a | ||
|
|
108b83cfd7 | ||
|
|
017aa1ec86 | ||
|
|
31106629cb | ||
|
|
db63109539 | ||
|
|
43ae4eac80 | ||
|
|
db9454d199 | ||
|
|
beb16a77f0 | ||
|
|
5ddd0f523b | ||
|
|
0b9c9022dd | ||
|
|
f861c13dad | ||
|
|
c83e67b421 | ||
|
|
cd304b7a6f | ||
|
|
e1ee6e181a | ||
|
|
b792ea0216 | ||
|
|
b6c2e0f4d7 | ||
|
|
a0350bbaaa | ||
|
|
dd7cd42118 | ||
|
|
282f1f9135 | ||
|
|
105c8990eb | ||
|
|
cc792d03a6 | ||
|
|
0bc33645fa | ||
|
|
f5f73fbd4d | ||
|
|
126ad300ae | ||
|
|
759ccae9f6 | ||
|
|
0cc9560a99 | ||
|
|
0dfe627d52 | ||
|
|
6e92a04320 |
@@ -101,7 +101,7 @@ set( CALAMARES_TRANSLATION_LANGUAGES ar ast bg ca cs_CZ da de el en en_GB es_MX
|
|||||||
|
|
||||||
set( CALAMARES_VERSION_MAJOR 2 )
|
set( CALAMARES_VERSION_MAJOR 2 )
|
||||||
set( CALAMARES_VERSION_MINOR 2 )
|
set( CALAMARES_VERSION_MINOR 2 )
|
||||||
set( CALAMARES_VERSION_PATCH 3 )
|
set( CALAMARES_VERSION_PATCH 90 )
|
||||||
set( CALAMARES_VERSION_RC 0 )
|
set( CALAMARES_VERSION_RC 0 )
|
||||||
|
|
||||||
set( CALAMARES_VERSION ${CALAMARES_VERSION_MAJOR}.${CALAMARES_VERSION_MINOR}.${CALAMARES_VERSION_PATCH} )
|
set( CALAMARES_VERSION ${CALAMARES_VERSION_MAJOR}.${CALAMARES_VERSION_MINOR}.${CALAMARES_VERSION_PATCH} )
|
||||||
|
|||||||
@@ -8,5 +8,5 @@ Exec=pkexec /usr/bin/calamares
|
|||||||
Comment=Calamares — System Installer
|
Comment=Calamares — System Installer
|
||||||
Icon=calamares
|
Icon=calamares
|
||||||
Terminal=false
|
Terminal=false
|
||||||
StartupNotify=true
|
StartupNotify=false
|
||||||
Categories=Qt;System;
|
Categories=Qt;System;
|
||||||
|
|||||||
@@ -86,11 +86,7 @@ CalamaresApplication::init()
|
|||||||
setWindowIcon( QIcon( Calamares::Branding::instance()->
|
setWindowIcon( QIcon( Calamares::Branding::instance()->
|
||||||
imagePath( Calamares::Branding::ProductIcon ) ) );
|
imagePath( Calamares::Branding::ProductIcon ) ) );
|
||||||
|
|
||||||
cDebug() << "STARTUP: initQmlPath, initSettings, initBranding done";
|
|
||||||
|
|
||||||
initModuleManager(); //also shows main window
|
initModuleManager(); //also shows main window
|
||||||
|
|
||||||
cDebug() << "STARTUP: initModuleManager: module init started";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -332,9 +328,7 @@ CalamaresApplication::initModuleManager()
|
|||||||
void
|
void
|
||||||
CalamaresApplication::initView()
|
CalamaresApplication::initView()
|
||||||
{
|
{
|
||||||
cDebug() << "STARTUP: initModuleManager: all modules init done";
|
|
||||||
initJobQueue();
|
initJobQueue();
|
||||||
cDebug() << "STARTUP: initJobQueue done";
|
|
||||||
|
|
||||||
m_mainwindow = new CalamaresWindow(); //also creates ViewManager
|
m_mainwindow = new CalamaresWindow(); //also creates ViewManager
|
||||||
|
|
||||||
@@ -346,19 +340,15 @@ CalamaresApplication::initView()
|
|||||||
m_mainwindow->move(
|
m_mainwindow->move(
|
||||||
this->desktop()->availableGeometry().center() -
|
this->desktop()->availableGeometry().center() -
|
||||||
m_mainwindow->rect().center() );
|
m_mainwindow->rect().center() );
|
||||||
|
|
||||||
cDebug() << "STARTUP: CalamaresWindow created; loadModules started";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CalamaresApplication::initViewSteps()
|
CalamaresApplication::initViewSteps()
|
||||||
{
|
{
|
||||||
cDebug() << "STARTUP: loadModules for all modules done";
|
|
||||||
m_mainwindow->show();
|
m_mainwindow->show();
|
||||||
ProgressTreeModel* m = new ProgressTreeModel( this );
|
ProgressTreeModel* m = new ProgressTreeModel( this );
|
||||||
ProgressTreeView::instance()->setModel( m );
|
ProgressTreeView::instance()->setModel( m );
|
||||||
cDebug() << "STARTUP: Window now visible and ProgressTreeView populated";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -89,12 +89,31 @@ def create_systemd_boot_conf(uuid, conf_path, kernel_line):
|
|||||||
distribution = get_bootloader_entry_name()
|
distribution = get_bootloader_entry_name()
|
||||||
kernel = libcalamares.job.configuration["kernel"]
|
kernel = libcalamares.job.configuration["kernel"]
|
||||||
img = libcalamares.job.configuration["img"]
|
img = libcalamares.job.configuration["img"]
|
||||||
|
kernel_params = ["quiet"]
|
||||||
|
|
||||||
partitions = libcalamares.globalstorage.value("partitions")
|
partitions = libcalamares.globalstorage.value("partitions")
|
||||||
swap = ""
|
swap_uuid = ""
|
||||||
|
|
||||||
|
cryptdevice_params = []
|
||||||
|
|
||||||
for partition in partitions:
|
for partition in partitions:
|
||||||
if partition["fs"] == "linuxswap":
|
if partition["fs"] == "linuxswap":
|
||||||
swap = partition["uuid"]
|
swap_uuid = partition["uuid"]
|
||||||
|
|
||||||
|
if partition["mountPoint"] == "/" and "luksMapperName" in partition:
|
||||||
|
cryptdevice_params = [
|
||||||
|
"cryptdevice=UUID={!s}:{!s}".format(partition["luksUuid"],
|
||||||
|
partition["luksMapperName"]),
|
||||||
|
"root=/dev/mapper/{!s}".format(partition["luksMapperName"])
|
||||||
|
]
|
||||||
|
|
||||||
|
if cryptdevice_params:
|
||||||
|
kernel_params.extend(cryptdevice_params)
|
||||||
|
else:
|
||||||
|
kernel_params.append("root=UUID={!s}".format(uuid))
|
||||||
|
|
||||||
|
if swap_uuid:
|
||||||
|
kernel_params.append("resume=UUID={!s}".format(swap_uuid))
|
||||||
|
|
||||||
lines = [
|
lines = [
|
||||||
'## This is just an example config file.\n',
|
'## This is just an example config file.\n',
|
||||||
@@ -103,12 +122,12 @@ def create_systemd_boot_conf(uuid, conf_path, kernel_line):
|
|||||||
"title {!s}{!s}\n".format(distribution, kernel_line),
|
"title {!s}{!s}\n".format(distribution, kernel_line),
|
||||||
"linux {!s}\n".format(kernel),
|
"linux {!s}\n".format(kernel),
|
||||||
"initrd {!s}\n".format(img),
|
"initrd {!s}\n".format(img),
|
||||||
"options root=UUID={!s} quiet resume=UUID={!s} rw\n".format(uuid, swap),
|
"options {!s} rw\n".format(" ".join(kernel_params)),
|
||||||
]
|
]
|
||||||
|
|
||||||
with open(conf_path, 'w') as f:
|
with open(conf_path, 'w') as conf_file:
|
||||||
for l in lines:
|
for line in lines:
|
||||||
f.write(l)
|
conf_file.write(line)
|
||||||
|
|
||||||
|
|
||||||
def create_loader(loader_path):
|
def create_loader(loader_path):
|
||||||
@@ -125,9 +144,9 @@ def create_loader(loader_path):
|
|||||||
"default {!s}\n".format(distribution_translated),
|
"default {!s}\n".format(distribution_translated),
|
||||||
]
|
]
|
||||||
|
|
||||||
with open(loader_path, 'w') as f:
|
with open(loader_path, 'w') as loader_file:
|
||||||
for l in lines:
|
for line in lines:
|
||||||
f.write(l)
|
loader_file.write(line)
|
||||||
|
|
||||||
|
|
||||||
def install_systemd_boot(efi_directory):
|
def install_systemd_boot(efi_directory):
|
||||||
@@ -138,17 +157,24 @@ def install_systemd_boot(efi_directory):
|
|||||||
print("Bootloader: systemd-boot")
|
print("Bootloader: systemd-boot")
|
||||||
install_path = libcalamares.globalstorage.value("rootMountPoint")
|
install_path = libcalamares.globalstorage.value("rootMountPoint")
|
||||||
install_efi_directory = install_path + efi_directory
|
install_efi_directory = install_path + efi_directory
|
||||||
fallback_kernel_line = libcalamares.job.configuration["fallbackKernelLine"]
|
|
||||||
uuid = get_uuid()
|
uuid = get_uuid()
|
||||||
distribution = get_bootloader_entry_name()
|
distribution = get_bootloader_entry_name()
|
||||||
file_name_sanitizer = str.maketrans(" /", "_-")
|
file_name_sanitizer = str.maketrans(" /", "_-")
|
||||||
distribution_translated = distribution.translate(file_name_sanitizer)
|
distribution_translated = distribution.translate(file_name_sanitizer)
|
||||||
conf_path = os.path.join(install_efi_directory, "loader", "entries",
|
conf_path = os.path.join(install_efi_directory,
|
||||||
|
"loader",
|
||||||
|
"entries",
|
||||||
"{!s}.conf".format(distribution_translated))
|
"{!s}.conf".format(distribution_translated))
|
||||||
fallback_path = os.path.join(install_efi_directory, "loader", "entries",
|
fallback_path = os.path.join(install_efi_directory,
|
||||||
|
"loader",
|
||||||
|
"entries",
|
||||||
"{!s}-fallback.conf".format(distribution_translated))
|
"{!s}-fallback.conf".format(distribution_translated))
|
||||||
loader_path = os.path.join(install_efi_directory, "loader", "loader.conf")
|
loader_path = os.path.join(install_efi_directory,
|
||||||
subprocess.call(["bootctl", "--path={!s}".format(install_efi_directory), "install"])
|
"loader",
|
||||||
|
"loader.conf")
|
||||||
|
subprocess.call(["bootctl",
|
||||||
|
"--path={!s}".format(install_efi_directory),
|
||||||
|
"install"])
|
||||||
kernel_line = get_kernel_line("default")
|
kernel_line = get_kernel_line("default")
|
||||||
print("Configure: \"{!s}\"".format(kernel_line))
|
print("Configure: \"{!s}\"".format(kernel_line))
|
||||||
create_systemd_boot_conf(uuid, conf_path, kernel_line)
|
create_systemd_boot_conf(uuid, conf_path, kernel_line)
|
||||||
@@ -178,29 +204,37 @@ def install_grub(efi_directory, fw_type):
|
|||||||
efi_bootloader_id = distribution.translate(file_name_sanitizer)
|
efi_bootloader_id = distribution.translate(file_name_sanitizer)
|
||||||
# get bitness of the underlying UEFI
|
# get bitness of the underlying UEFI
|
||||||
try:
|
try:
|
||||||
f = open("/sys/firmware/efi/fw_platform_size", "r")
|
sysfile = open("/sys/firmware/efi/fw_platform_size", "r")
|
||||||
efi_bitness = f.read(2)
|
efi_bitness = sysfile.read(2)
|
||||||
except:
|
except Exception:
|
||||||
# if the kernel is older than 4.0, the UEFI bitness likely isn't exposed to the userspace
|
# if the kernel is older than 4.0, the UEFI bitness likely isn't
|
||||||
# so we assume a 64 bit UEFI here
|
# exposed to the userspace so we assume a 64 bit UEFI here
|
||||||
efi_bitness = "64"
|
efi_bitness = "64"
|
||||||
bitness_translate = {"32": "--target=i386-efi", "64": "--target=x86_64-efi"}
|
bitness_translate = {"32": "--target=i386-efi", "64": "--target=x86_64-efi"}
|
||||||
check_target_env_call([libcalamares.job.configuration["grubInstall"], bitness_translate[efi_bitness],
|
check_target_env_call([libcalamares.job.configuration["grubInstall"],
|
||||||
"--efi-directory={!s}".format(efi_directory),
|
bitness_translate[efi_bitness],
|
||||||
"--bootloader-id={!s}".format(efi_bootloader_id),
|
"--efi-directory={!s}".format(efi_directory),
|
||||||
"--force"])
|
"--bootloader-id={!s}".format(efi_bootloader_id),
|
||||||
|
"--force"])
|
||||||
# Workaround for some UEFI firmwares
|
# Workaround for some UEFI firmwares
|
||||||
check_target_env_call(["mkdir", "-p", "{!s}/boot".format(efi_directory_firmware)])
|
check_target_env_call(["mkdir", "-p", "{!s}/boot".format(efi_directory_firmware)])
|
||||||
check_target_env_call(["cp", "{!s}/{!s}/grubx64.efi".format(efi_directory_firmware, efi_bootloader_id),
|
check_target_env_call(["cp", "{!s}/{!s}/grubx64.efi".format(efi_directory_firmware,
|
||||||
"{!s}/boot/bootx64.efi".format(efi_directory_firmware)])
|
efi_bootloader_id),
|
||||||
|
"{!s}/boot/bootx64.efi".format(efi_directory_firmware)])
|
||||||
else:
|
else:
|
||||||
print("Bootloader: grub (bios)")
|
print("Bootloader: grub (bios)")
|
||||||
boot_loader = libcalamares.globalstorage.value("bootLoader")
|
boot_loader = libcalamares.globalstorage.value("bootLoader")
|
||||||
check_target_env_call([libcalamares.job.configuration["grubInstall"], "--target=i386-pc",
|
check_target_env_call([libcalamares.job.configuration["grubInstall"],
|
||||||
"--recheck", "--force", boot_loader["installPath"]])
|
"--target=i386-pc",
|
||||||
|
"--recheck",
|
||||||
|
"--force",
|
||||||
|
boot_loader["installPath"]])
|
||||||
|
|
||||||
check_target_env_call([libcalamares.job.configuration["grubMkconfig"], "-o",
|
# The file specified in grubCfg should already be filled out
|
||||||
libcalamares.job.configuration["grubCfg"]])
|
# by the grubcfg job module.
|
||||||
|
check_target_env_call([libcalamares.job.configuration["grubMkconfig"],
|
||||||
|
"-o",
|
||||||
|
libcalamares.job.configuration["grubCfg"]])
|
||||||
|
|
||||||
|
|
||||||
def prepare_bootloader(fw_type):
|
def prepare_bootloader(fw_type):
|
||||||
|
|||||||
@@ -44,12 +44,24 @@ def modify_grub_default(partitions, root_mount_point, distributor):
|
|||||||
if plymouth_bin == 0:
|
if plymouth_bin == 0:
|
||||||
use_splash = "splash"
|
use_splash = "splash"
|
||||||
|
|
||||||
|
cryptdevice_params = []
|
||||||
|
|
||||||
for partition in partitions:
|
for partition in partitions:
|
||||||
if partition["fs"] == "linuxswap":
|
if partition["fs"] == "linuxswap":
|
||||||
swap_uuid = partition["uuid"]
|
swap_uuid = partition["uuid"]
|
||||||
|
|
||||||
|
if partition["mountPoint"] == "/" and "luksMapperName" in partition:
|
||||||
|
cryptdevice_params = [
|
||||||
|
"cryptdevice=UUID={!s}:{!s}".format(partition["luksUuid"],
|
||||||
|
partition["luksMapperName"]),
|
||||||
|
"root=/dev/mapper/{!s}".format(partition["luksMapperName"])
|
||||||
|
]
|
||||||
|
|
||||||
kernel_params = ["quiet"]
|
kernel_params = ["quiet"]
|
||||||
|
|
||||||
|
if cryptdevice_params:
|
||||||
|
kernel_params.extend(cryptdevice_params)
|
||||||
|
|
||||||
if use_splash:
|
if use_splash:
|
||||||
kernel_params.append(use_splash)
|
kernel_params.append(use_splash)
|
||||||
|
|
||||||
@@ -123,6 +135,9 @@ def modify_grub_default(partitions, root_mount_point, distributor):
|
|||||||
if not have_distributor_line:
|
if not have_distributor_line:
|
||||||
lines.append(distributor_line)
|
lines.append(distributor_line)
|
||||||
|
|
||||||
|
if cryptdevice_params:
|
||||||
|
lines.append("GRUB_ENABLE_CRYPTODISK=y")
|
||||||
|
|
||||||
with open(default_grub, 'w') as grub_file:
|
with open(default_grub, 'w') as grub_file:
|
||||||
grub_file.write("\n".join(lines) + "\n")
|
grub_file.write("\n".join(lines) + "\n")
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,6 @@
|
|||||||
import libcalamares
|
import libcalamares
|
||||||
import os
|
import os
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from libcalamares.utils import check_target_env_call
|
|
||||||
|
|
||||||
|
|
||||||
def cpuinfo():
|
def cpuinfo():
|
||||||
@@ -36,8 +35,8 @@ def cpuinfo():
|
|||||||
|
|
||||||
nprocs = 0
|
nprocs = 0
|
||||||
|
|
||||||
with open('/proc/cpuinfo') as f:
|
with open('/proc/cpuinfo') as cpuinfo_file:
|
||||||
for line in f:
|
for line in cpuinfo_file:
|
||||||
if not line.strip():
|
if not line.strip():
|
||||||
# end of one processor
|
# end of one processor
|
||||||
cpu_info["proc{!s}".format(nprocs)] = procinfo
|
cpu_info["proc{!s}".format(nprocs)] = procinfo
|
||||||
@@ -53,11 +52,12 @@ def cpuinfo():
|
|||||||
return cpu_info
|
return cpu_info
|
||||||
|
|
||||||
|
|
||||||
def set_mkinitcpio_hooks_and_modules(hooks, modules, root_mount_point):
|
def write_mkinitcpio_lines(hooks, modules, files, root_mount_point):
|
||||||
""" Set up mkinitcpio.conf.
|
""" Set up mkinitcpio.conf.
|
||||||
|
|
||||||
:param hooks:
|
:param hooks:
|
||||||
:param modules:
|
:param modules:
|
||||||
|
:param files:
|
||||||
:param root_mount_point:
|
:param root_mount_point:
|
||||||
"""
|
"""
|
||||||
with open("/etc/mkinitcpio.conf", "r") as mkinitcpio_file:
|
with open("/etc/mkinitcpio.conf", "r") as mkinitcpio_file:
|
||||||
@@ -70,6 +70,9 @@ def set_mkinitcpio_hooks_and_modules(hooks, modules, root_mount_point):
|
|||||||
elif mklins[i].startswith("MODULES"):
|
elif mklins[i].startswith("MODULES"):
|
||||||
joined_modules = ' '.join(modules)
|
joined_modules = ' '.join(modules)
|
||||||
mklins[i] = "MODULES=\"{!s}\"".format(joined_modules)
|
mklins[i] = "MODULES=\"{!s}\"".format(joined_modules)
|
||||||
|
elif mklins[i].startswith("FILES"):
|
||||||
|
joined_files = ' '.join(files)
|
||||||
|
mklins[i] = "FILES=\"{!s}\"".format(joined_files)
|
||||||
|
|
||||||
path = os.path.join(root_mount_point, "etc/mkinitcpio.conf")
|
path = os.path.join(root_mount_point, "etc/mkinitcpio.conf")
|
||||||
|
|
||||||
@@ -88,6 +91,8 @@ def modify_mkinitcpio_conf(partitions, root_mount_point):
|
|||||||
btrfs = ""
|
btrfs = ""
|
||||||
hooks = ["base", "udev", "autodetect", "modconf", "block", "keyboard", "keymap"]
|
hooks = ["base", "udev", "autodetect", "modconf", "block", "keyboard", "keymap"]
|
||||||
modules = []
|
modules = []
|
||||||
|
files = []
|
||||||
|
encrypt_hook = False
|
||||||
|
|
||||||
# It is important that the plymouth hook comes before any encrypt hook
|
# It is important that the plymouth hook comes before any encrypt hook
|
||||||
plymouth_bin = os.path.join(root_mount_point, "usr/bin/plymouth")
|
plymouth_bin = os.path.join(root_mount_point, "usr/bin/plymouth")
|
||||||
@@ -101,6 +106,14 @@ def modify_mkinitcpio_conf(partitions, root_mount_point):
|
|||||||
if partition["fs"] == "btrfs":
|
if partition["fs"] == "btrfs":
|
||||||
btrfs = "yes"
|
btrfs = "yes"
|
||||||
|
|
||||||
|
if partition["mountPoint"] == "/" and partition["luksMapperName"]:
|
||||||
|
encrypt_hook = True
|
||||||
|
|
||||||
|
if encrypt_hook:
|
||||||
|
hooks.append("encrypt")
|
||||||
|
if os.path.isfile(os.path.join(root_mount_point, "crypto_keyfile.bin")):
|
||||||
|
files.append("/crypto_keyfile.bin")
|
||||||
|
|
||||||
if swap_uuid is not "":
|
if swap_uuid is not "":
|
||||||
hooks.extend(["resume", "filesystems"])
|
hooks.extend(["resume", "filesystems"])
|
||||||
else:
|
else:
|
||||||
@@ -113,7 +126,7 @@ def modify_mkinitcpio_conf(partitions, root_mount_point):
|
|||||||
else:
|
else:
|
||||||
hooks.append("fsck")
|
hooks.append("fsck")
|
||||||
|
|
||||||
set_mkinitcpio_hooks_and_modules(hooks, modules, root_mount_point)
|
write_mkinitcpio_lines(hooks, modules, files, root_mount_point)
|
||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||||
*
|
*
|
||||||
* Copyright 2014-2016, Teo Mrnjavac <teo@kde.org>
|
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
|
||||||
*
|
*
|
||||||
* Calamares is free software: you can redistribute it and/or modify
|
* Calamares is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -225,60 +225,41 @@ LocalePage::init( const QString& initialRegion,
|
|||||||
}
|
}
|
||||||
emit m_tzWidget->locationChanged( m_tzWidget->getCurrentLocation() );
|
emit m_tzWidget->locationChanged( m_tzWidget->getCurrentLocation() );
|
||||||
|
|
||||||
// Some distros come with a meaningfully commented and easy to parse locale.gen,
|
// Fill in meaningful locale/charset lines from locale.gen
|
||||||
// and others ship a separate file /usr/share/i18n/SUPPORTED with a clean list of
|
|
||||||
// supported locales. We first try that one, and if it doesn't exist, we fall back
|
|
||||||
// to parsing the lines from locale.gen
|
|
||||||
m_localeGenLines.clear();
|
m_localeGenLines.clear();
|
||||||
QFile supported( "/usr/share/i18n/SUPPORTED" );
|
QFile localeGen( localeGenPath );
|
||||||
QByteArray ba;
|
QByteArray ba;
|
||||||
|
if ( localeGen.open( QIODevice::ReadOnly | QIODevice::Text ) )
|
||||||
if ( supported.exists() &&
|
|
||||||
supported.open( QIODevice::ReadOnly | QIODevice::Text ) )
|
|
||||||
{
|
{
|
||||||
ba = supported.readAll();
|
ba = localeGen.readAll();
|
||||||
supported.close();
|
localeGen.close();
|
||||||
|
|
||||||
foreach ( QByteArray line, ba.split( '\n' ) )
|
|
||||||
{
|
|
||||||
m_localeGenLines.append( QString::fromLatin1( line.simplified() ) );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QFile localeGen( localeGenPath );
|
cDebug() << "Cannot open file" << localeGenPath
|
||||||
if ( localeGen.open( QIODevice::ReadOnly | QIODevice::Text ) )
|
<< ". Assuming the supported languages are already built into "
|
||||||
{
|
"the locale archive.";
|
||||||
ba = localeGen.readAll();
|
QProcess localeA;
|
||||||
localeGen.close();
|
localeA.start( "locale", QStringList() << "-a" );
|
||||||
}
|
localeA.waitForFinished();
|
||||||
else
|
ba = localeA.readAllStandardOutput();
|
||||||
{
|
}
|
||||||
cDebug() << "Cannot open file" << localeGenPath
|
foreach ( QByteArray line, ba.split( '\n' ) )
|
||||||
<< ". Assuming the supported languages are already built into "
|
{
|
||||||
"the locale archive.";
|
if ( line.startsWith( "## " ) ||
|
||||||
QProcess localeA;
|
line.startsWith( "# " ) ||
|
||||||
localeA.start( "locale", QStringList() << "-a" );
|
line.simplified() == "#" )
|
||||||
localeA.waitForFinished();
|
continue;
|
||||||
ba = localeA.readAllStandardOutput();
|
|
||||||
}
|
|
||||||
foreach ( QByteArray line, ba.split( '\n' ) )
|
|
||||||
{
|
|
||||||
if ( line.startsWith( "## " ) ||
|
|
||||||
line.startsWith( "# " ) ||
|
|
||||||
line.simplified() == "#" )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
QString lineString = QString::fromLatin1( line.simplified() );
|
QString lineString = QString::fromLatin1( line.simplified() );
|
||||||
if ( lineString.startsWith( "#" ) )
|
if ( lineString.startsWith( "#" ) )
|
||||||
lineString.remove( '#' );
|
lineString.remove( '#' );
|
||||||
lineString = lineString.simplified();
|
lineString = lineString.simplified();
|
||||||
|
|
||||||
if ( lineString.isEmpty() )
|
if ( lineString.isEmpty() )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
m_localeGenLines.append( lineString );
|
m_localeGenLines.append( lineString );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import libcalamares
|
|||||||
|
|
||||||
def run():
|
def run():
|
||||||
""" Create locale """
|
""" Create locale """
|
||||||
en_us_locale = '#en_US'
|
us = '#en_US'
|
||||||
locale = libcalamares.globalstorage.value("lcLocale")
|
locale = libcalamares.globalstorage.value("lcLocale")
|
||||||
|
|
||||||
if not locale:
|
if not locale:
|
||||||
@@ -50,30 +50,23 @@ def run():
|
|||||||
# always enable en_US
|
# always enable en_US
|
||||||
with open("{!s}/etc/locale.gen".format(install_path), "w") as gen:
|
with open("{!s}/etc/locale.gen".format(install_path), "w") as gen:
|
||||||
for line in text:
|
for line in text:
|
||||||
if en_us_locale in line and line[0] == "#":
|
if us in line and line[0] == "#":
|
||||||
# uncomment line
|
# uncomment line
|
||||||
line = line[1:].lstrip()
|
line = line[1:]
|
||||||
|
|
||||||
if locale in line and line[0] == "#":
|
if locale in line and line[0] == "#":
|
||||||
# uncomment line
|
# uncomment line
|
||||||
line = line[1:].lstrip()
|
line = line[1:]
|
||||||
|
|
||||||
gen.write(line)
|
gen.write(line)
|
||||||
|
|
||||||
libcalamares.utils.target_env_call(['locale-gen'])
|
libcalamares.utils.target_env_call(['locale-gen'])
|
||||||
print('locale.gen done')
|
print('locale.gen done')
|
||||||
|
|
||||||
# write /etc/locale.conf
|
|
||||||
locale_conf_path = os.path.join(install_path, "etc/locale.conf")
|
locale_conf_path = os.path.join(install_path, "etc/locale.conf")
|
||||||
|
|
||||||
with open(locale_conf_path, "w") as locale_conf:
|
with open(locale_conf_path, "w") as locale_conf:
|
||||||
locale_split = locale.split(' ')[0]
|
locale_split = locale.split(' ')[0]
|
||||||
locale_conf.write("LANG={!s}\n".format(locale_split))
|
locale_conf.write("LANG={!s}\n".format(locale_split))
|
||||||
|
|
||||||
# write /etc/default/locale if /etc/default exists and is a dir
|
|
||||||
etc_default_path = os.path.join(install_path, "etc/default")
|
|
||||||
if os.path.isdir(etc_default_path):
|
|
||||||
with open(os.path.join(etc_default_path, "locale"), "w") as etc_default_locale:
|
|
||||||
locale_split = locale.split(' ')[0]
|
|
||||||
etc_default_locale.write("LANG={!s}\n".format(locale_split))
|
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|||||||
67
src/modules/luksbootkeyfile/main.py
Normal file
67
src/modules/luksbootkeyfile/main.py
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
#
|
||||||
|
# === This file is part of Calamares - <http://github.com/calamares> ===
|
||||||
|
#
|
||||||
|
# Copyright 2016, Teo Mrnjavac <teo@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 libcalamares
|
||||||
|
|
||||||
|
from libcalamares.utils import check_target_env_call
|
||||||
|
|
||||||
|
|
||||||
|
def run():
|
||||||
|
"""
|
||||||
|
This module sets up a file crypto_keyfile.bin on the rootfs, assuming the rootfs
|
||||||
|
is LUKS encrypted and a passphrase is provided. This file is then included in the
|
||||||
|
initramfs and used for unlocking the rootfs from a previously unlocked GRUB2
|
||||||
|
session.
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
|
||||||
|
partitions = libcalamares.globalstorage.value("partitions")
|
||||||
|
|
||||||
|
luks_device = ""
|
||||||
|
luks_passphrase = ""
|
||||||
|
|
||||||
|
for partition in partitions:
|
||||||
|
if partition["mountPoint"] == "/" and "luksMapperName" in partition:
|
||||||
|
luks_device = partition["device"]
|
||||||
|
luks_passphrase = partition["luksPassphrase"]
|
||||||
|
|
||||||
|
if not luks_device:
|
||||||
|
return None
|
||||||
|
|
||||||
|
if not luks_passphrase:
|
||||||
|
return ("Encrypted rootfs setup error",
|
||||||
|
"Rootfs partition {!s} is LUKS but no passphrase found.".format(luks_device))
|
||||||
|
|
||||||
|
# Generate random keyfile
|
||||||
|
check_target_env_call(["dd",
|
||||||
|
"bs=512",
|
||||||
|
"count=4",
|
||||||
|
"if=/dev/urandom",
|
||||||
|
"of=/crypto_keyfile.bin"])
|
||||||
|
check_target_env_call(["cryptsetup",
|
||||||
|
"luksAddKey",
|
||||||
|
luks_device,
|
||||||
|
"/crypto_keyfile.bin"],
|
||||||
|
luks_passphrase)
|
||||||
|
check_target_env_call(["chmod",
|
||||||
|
"g-rwx,o-rwx",
|
||||||
|
"/crypto_keyfile.bin"])
|
||||||
|
|
||||||
|
return None
|
||||||
5
src/modules/luksbootkeyfile/module.desc
Normal file
5
src/modules/luksbootkeyfile/module.desc
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
type: "job"
|
||||||
|
name: "luksbootkeyfile"
|
||||||
|
interface: "python"
|
||||||
|
script: "main.py"
|
||||||
@@ -30,7 +30,7 @@ def mount_partitions(root_mount_point, partitions):
|
|||||||
:param partitions:
|
:param partitions:
|
||||||
"""
|
"""
|
||||||
for partition in partitions:
|
for partition in partitions:
|
||||||
if not partition["mountPoint"]:
|
if "mountPoint" not in partition or not partition["mountPoint"]:
|
||||||
continue
|
continue
|
||||||
# Create mount point with `+` rather than `os.path.join()` because
|
# Create mount point with `+` rather than `os.path.join()` because
|
||||||
# `partition["mountPoint"]` starts with a '/'.
|
# `partition["mountPoint"]` starts with a '/'.
|
||||||
@@ -40,11 +40,20 @@ def mount_partitions(root_mount_point, partitions):
|
|||||||
if fstype == "fat16" or fstype == "fat32":
|
if fstype == "fat16" or fstype == "fat32":
|
||||||
fstype = "vfat"
|
fstype = "vfat"
|
||||||
|
|
||||||
libcalamares.utils.mount(partition["device"],
|
if "luksMapperName" in partition:
|
||||||
mount_point,
|
libcalamares.utils.debug("about to mount {!s}".format(partition["luksMapperName"]))
|
||||||
fstype,
|
libcalamares.utils.mount("/dev/mapper/{!s}".format(partition["luksMapperName"]),
|
||||||
partition.get("options", ""),
|
mount_point,
|
||||||
)
|
fstype,
|
||||||
|
partition.get("options", ""),
|
||||||
|
)
|
||||||
|
|
||||||
|
else:
|
||||||
|
libcalamares.utils.mount(partition["device"],
|
||||||
|
mount_point,
|
||||||
|
fstype,
|
||||||
|
partition.get("options", ""),
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
|
|||||||
@@ -31,11 +31,12 @@ calamares_add_plugin( partition
|
|||||||
core/PartitionIterator.cpp
|
core/PartitionIterator.cpp
|
||||||
core/PartitionModel.cpp
|
core/PartitionModel.cpp
|
||||||
core/PartUtils.cpp
|
core/PartUtils.cpp
|
||||||
|
gui/BootInfoWidget.cpp
|
||||||
gui/ChoicePage.cpp
|
gui/ChoicePage.cpp
|
||||||
gui/CreatePartitionDialog.cpp
|
gui/CreatePartitionDialog.cpp
|
||||||
gui/EditExistingPartitionDialog.cpp
|
|
||||||
gui/BootInfoWidget.cpp
|
|
||||||
gui/DeviceInfoWidget.cpp
|
gui/DeviceInfoWidget.cpp
|
||||||
|
gui/EditExistingPartitionDialog.cpp
|
||||||
|
gui/EncryptWidget.cpp
|
||||||
gui/PartitionPage.cpp
|
gui/PartitionPage.cpp
|
||||||
gui/PartitionBarsView.cpp
|
gui/PartitionBarsView.cpp
|
||||||
gui/PartitionLabelsView.cpp
|
gui/PartitionLabelsView.cpp
|
||||||
@@ -62,6 +63,7 @@ calamares_add_plugin( partition
|
|||||||
gui/CreatePartitionDialog.ui
|
gui/CreatePartitionDialog.ui
|
||||||
gui/CreatePartitionTableDialog.ui
|
gui/CreatePartitionTableDialog.ui
|
||||||
gui/EditExistingPartitionDialog.ui
|
gui/EditExistingPartitionDialog.ui
|
||||||
|
gui/EncryptWidget.ui
|
||||||
gui/PartitionPage.ui
|
gui/PartitionPage.ui
|
||||||
gui/ReplaceWidget.ui
|
gui/ReplaceWidget.ui
|
||||||
LINK_LIBRARIES
|
LINK_LIBRARIES
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#include <kpmcore/core/partition.h>
|
#include <kpmcore/core/partition.h>
|
||||||
#include <kpmcore/fs/filesystemfactory.h>
|
#include <kpmcore/fs/filesystemfactory.h>
|
||||||
#include <kpmcore/backend/corebackendmanager.h>
|
#include <kpmcore/backend/corebackendmanager.h>
|
||||||
|
#include <kpmcore/fs/luks.h>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
@@ -132,6 +133,40 @@ createNewPartition( PartitionNode* parent,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Partition*
|
||||||
|
createNewEncryptedPartition( PartitionNode* parent,
|
||||||
|
const Device& device,
|
||||||
|
const PartitionRole& role,
|
||||||
|
FileSystem::Type fsType,
|
||||||
|
qint64 firstSector,
|
||||||
|
qint64 lastSector,
|
||||||
|
const QString& passphrase,
|
||||||
|
PartitionTable::Flags flags )
|
||||||
|
{
|
||||||
|
PartitionRole::Roles newRoles = role.roles();
|
||||||
|
if ( !role.has( PartitionRole::Luks ) )
|
||||||
|
newRoles |= PartitionRole::Luks;
|
||||||
|
|
||||||
|
FS::luks* fs = dynamic_cast< FS::luks* >(
|
||||||
|
FileSystemFactory::create( FileSystem::Luks,
|
||||||
|
firstSector,
|
||||||
|
lastSector ) );
|
||||||
|
fs->createInnerFileSystem( fsType );
|
||||||
|
fs->setPassphrase( passphrase );
|
||||||
|
Partition* p = new Partition( parent,
|
||||||
|
device,
|
||||||
|
PartitionRole( newRoles ),
|
||||||
|
fs, fs->firstSector(), fs->lastSector(),
|
||||||
|
QString() /* path */,
|
||||||
|
PartitionTable::FlagNone /* availableFlags */,
|
||||||
|
QString() /* mountPoint */,
|
||||||
|
false /* mounted */,
|
||||||
|
flags /* activeFlags */,
|
||||||
|
Partition::StateNew );
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Partition*
|
Partition*
|
||||||
clonePartition( Device* device, Partition* partition )
|
clonePartition( Device* device, Partition* partition )
|
||||||
{
|
{
|
||||||
@@ -163,7 +198,7 @@ prettyNameForFileSystemType( FileSystem::Type t )
|
|||||||
case FileSystem::Unformatted:
|
case FileSystem::Unformatted:
|
||||||
return QObject::tr( "unformatted" );
|
return QObject::tr( "unformatted" );
|
||||||
case FileSystem::LinuxSwap:
|
case FileSystem::LinuxSwap:
|
||||||
return "swap";
|
return QObject::tr( "swap" );
|
||||||
case FileSystem::Fat16:
|
case FileSystem::Fat16:
|
||||||
case FileSystem::Fat32:
|
case FileSystem::Fat32:
|
||||||
case FileSystem::Ntfs:
|
case FileSystem::Ntfs:
|
||||||
|
|||||||
@@ -91,6 +91,15 @@ Partition* createNewPartition( PartitionNode* parent,
|
|||||||
qint64 lastSector,
|
qint64 lastSector,
|
||||||
PartitionTable::Flags flags = PartitionTable::FlagNone );
|
PartitionTable::Flags flags = PartitionTable::FlagNone );
|
||||||
|
|
||||||
|
Partition* createNewEncryptedPartition( PartitionNode* parent,
|
||||||
|
const Device& device,
|
||||||
|
const PartitionRole& role,
|
||||||
|
FileSystem::Type fsType,
|
||||||
|
qint64 firstSector,
|
||||||
|
qint64 lastSector,
|
||||||
|
const QString& passphrase,
|
||||||
|
PartitionTable::Flags flags = PartitionTable::FlagNone );
|
||||||
|
|
||||||
Partition* clonePartition( Device* device, Partition* partition );
|
Partition* clonePartition( Device* device, Partition* partition );
|
||||||
|
|
||||||
QString prettyNameForFileSystemType( FileSystem::Type t );
|
QString prettyNameForFileSystemType( FileSystem::Type t );
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ swapSuggestion( const qint64 availableSpaceB )
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
doAutopartition( PartitionCoreModule* core, Device* dev )
|
doAutopartition( PartitionCoreModule* core, Device* dev, const QString& luksPassphrase )
|
||||||
{
|
{
|
||||||
bool isEfi = false;
|
bool isEfi = false;
|
||||||
if ( QDir( "/sys/firmware/efi/efivars" ).exists() )
|
if ( QDir( "/sys/firmware/efi/efivars" ).exists() )
|
||||||
@@ -167,28 +167,60 @@ doAutopartition( PartitionCoreModule* core, Device* dev )
|
|||||||
lastSectorForRoot -= suggestedSwapSizeB / dev->logicalSectorSize() + 1;
|
lastSectorForRoot -= suggestedSwapSizeB / dev->logicalSectorSize() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Partition* rootPartition = KPMHelpers::createNewPartition(
|
Partition* rootPartition = nullptr;
|
||||||
dev->partitionTable(),
|
if ( luksPassphrase.isEmpty() )
|
||||||
*dev,
|
{
|
||||||
PartitionRole( PartitionRole::Primary ),
|
rootPartition = KPMHelpers::createNewPartition(
|
||||||
FileSystem::Ext4,
|
dev->partitionTable(),
|
||||||
firstFreeSector,
|
*dev,
|
||||||
lastSectorForRoot
|
PartitionRole( PartitionRole::Primary ),
|
||||||
);
|
FileSystem::Ext4,
|
||||||
|
firstFreeSector,
|
||||||
|
lastSectorForRoot
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rootPartition = KPMHelpers::createNewEncryptedPartition(
|
||||||
|
dev->partitionTable(),
|
||||||
|
*dev,
|
||||||
|
PartitionRole( PartitionRole::Primary ),
|
||||||
|
FileSystem::Ext4,
|
||||||
|
firstFreeSector,
|
||||||
|
lastSectorForRoot,
|
||||||
|
luksPassphrase
|
||||||
|
);
|
||||||
|
}
|
||||||
PartitionInfo::setFormat( rootPartition, true );
|
PartitionInfo::setFormat( rootPartition, true );
|
||||||
PartitionInfo::setMountPoint( rootPartition, "/" );
|
PartitionInfo::setMountPoint( rootPartition, "/" );
|
||||||
core->createPartition( dev, rootPartition );
|
core->createPartition( dev, rootPartition );
|
||||||
|
|
||||||
if ( shouldCreateSwap )
|
if ( shouldCreateSwap )
|
||||||
{
|
{
|
||||||
Partition* swapPartition = KPMHelpers::createNewPartition(
|
Partition* swapPartition = nullptr;
|
||||||
dev->partitionTable(),
|
if ( luksPassphrase.isEmpty() )
|
||||||
*dev,
|
{
|
||||||
PartitionRole( PartitionRole::Primary ),
|
swapPartition = KPMHelpers::createNewPartition(
|
||||||
FileSystem::LinuxSwap,
|
dev->partitionTable(),
|
||||||
lastSectorForRoot + 1,
|
*dev,
|
||||||
dev->totalSectors() - 1
|
PartitionRole( PartitionRole::Primary ),
|
||||||
);
|
FileSystem::LinuxSwap,
|
||||||
|
lastSectorForRoot + 1,
|
||||||
|
dev->totalSectors() - 1
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
swapPartition = KPMHelpers::createNewEncryptedPartition(
|
||||||
|
dev->partitionTable(),
|
||||||
|
*dev,
|
||||||
|
PartitionRole( PartitionRole::Primary ),
|
||||||
|
FileSystem::LinuxSwap,
|
||||||
|
lastSectorForRoot + 1,
|
||||||
|
dev->totalSectors() - 1,
|
||||||
|
luksPassphrase
|
||||||
|
);
|
||||||
|
}
|
||||||
PartitionInfo::setFormat( swapPartition, true );
|
PartitionInfo::setFormat( swapPartition, true );
|
||||||
core->createPartition( dev, swapPartition );
|
core->createPartition( dev, swapPartition );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,14 +19,21 @@
|
|||||||
#ifndef PARTITIONACTIONS_H
|
#ifndef PARTITIONACTIONS_H
|
||||||
#define PARTITIONACTIONS_H
|
#define PARTITIONACTIONS_H
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
class PartitionCoreModule;
|
class PartitionCoreModule;
|
||||||
class Device;
|
class Device;
|
||||||
class Partition;
|
class Partition;
|
||||||
|
|
||||||
namespace PartitionActions
|
namespace PartitionActions
|
||||||
{
|
{
|
||||||
void doAutopartition( PartitionCoreModule* core, Device* dev );
|
void doAutopartition( PartitionCoreModule* core,
|
||||||
void doReplacePartition( PartitionCoreModule* core, Device* dev, Partition* partition );
|
Device* dev,
|
||||||
|
const QString& luksPassphrase = QString() );
|
||||||
|
|
||||||
|
void doReplacePartition( PartitionCoreModule* core,
|
||||||
|
Device* dev,
|
||||||
|
Partition* partition );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // PARTITIONACTIONS_H
|
#endif // PARTITIONACTIONS_H
|
||||||
|
|||||||
@@ -112,12 +112,11 @@ void
|
|||||||
PartitionCoreModule::init()
|
PartitionCoreModule::init()
|
||||||
{
|
{
|
||||||
CoreBackend* backend = CoreBackendManager::self()->backend();
|
CoreBackend* backend = CoreBackendManager::self()->backend();
|
||||||
QList< Device* > devices = backend->scanDevices( true );
|
auto devices = backend->scanDevices( true );
|
||||||
|
|
||||||
// Remove the device which contains / from the list
|
// Remove the device which contains / from the list
|
||||||
for ( QList< Device* >::iterator it = devices.begin(); it != devices.end(); )
|
for ( auto it = devices.begin(); it != devices.end(); )
|
||||||
if ( hasRootPartition( *it ) ||
|
if ( hasRootPartition( *it ) )
|
||||||
(*it)->deviceNode().startsWith( "/dev/zram") )
|
|
||||||
it = devices.erase( it );
|
it = devices.erase( it );
|
||||||
else
|
else
|
||||||
++it;
|
++it;
|
||||||
|
|||||||
@@ -121,6 +121,7 @@ ChoicePage::ChoicePage( QWidget* parent )
|
|||||||
m_previewAfterFrame->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding );
|
m_previewAfterFrame->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Expanding );
|
||||||
m_previewAfterLabel->hide();
|
m_previewAfterLabel->hide();
|
||||||
m_previewAfterFrame->hide();
|
m_previewAfterFrame->hide();
|
||||||
|
m_encryptWidget->hide();
|
||||||
// end
|
// end
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,6 +158,9 @@ ChoicePage::init( PartitionCoreModule* core )
|
|||||||
static_cast< void ( QComboBox::* )( int ) >( &QComboBox::currentIndexChanged ),
|
static_cast< void ( QComboBox::* )( int ) >( &QComboBox::currentIndexChanged ),
|
||||||
this, &ChoicePage::applyDeviceChoice );
|
this, &ChoicePage::applyDeviceChoice );
|
||||||
|
|
||||||
|
connect( m_encryptWidget, &EncryptWidget::stateChanged,
|
||||||
|
this, &ChoicePage::onEncryptWidgetStateChanged );
|
||||||
|
|
||||||
ChoicePage::applyDeviceChoice();
|
ChoicePage::applyDeviceChoice();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,14 +242,8 @@ ChoicePage::setupChoices()
|
|||||||
if ( checked ) // An action was picked.
|
if ( checked ) // An action was picked.
|
||||||
{
|
{
|
||||||
m_choice = static_cast< Choice >( id );
|
m_choice = static_cast< Choice >( id );
|
||||||
if ( m_choice == Replace )
|
updateNextEnabled();
|
||||||
{
|
|
||||||
setNextEnabled( false );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
setNextEnabled( true );
|
|
||||||
}
|
|
||||||
emit actionChosen();
|
emit actionChosen();
|
||||||
}
|
}
|
||||||
else // An action was unpicked, either on its own or because of another selection.
|
else // An action was unpicked, either on its own or because of another selection.
|
||||||
@@ -253,7 +251,8 @@ ChoicePage::setupChoices()
|
|||||||
if ( m_grp->checkedButton() == nullptr ) // If no other action is chosen, we must
|
if ( m_grp->checkedButton() == nullptr ) // If no other action is chosen, we must
|
||||||
{ // set m_choice to NoChoice and reset previews.
|
{ // set m_choice to NoChoice and reset previews.
|
||||||
m_choice = NoChoice;
|
m_choice = NoChoice;
|
||||||
setNextEnabled( false );
|
updateNextEnabled();
|
||||||
|
|
||||||
emit actionChosen();
|
emit actionChosen();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -369,14 +368,14 @@ ChoicePage::applyActionChoice( ChoicePage::Choice choice )
|
|||||||
} ),
|
} ),
|
||||||
[ = ]
|
[ = ]
|
||||||
{
|
{
|
||||||
PartitionActions::doAutopartition( m_core, selectedDevice() );
|
PartitionActions::doAutopartition( m_core, selectedDevice(), m_encryptWidget->passphrase() );
|
||||||
emit deviceChosen();
|
emit deviceChosen();
|
||||||
},
|
},
|
||||||
this );
|
this );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PartitionActions::doAutopartition( m_core, selectedDevice() );
|
PartitionActions::doAutopartition( m_core, selectedDevice(), m_encryptWidget->passphrase() );
|
||||||
emit deviceChosen();
|
emit deviceChosen();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -392,7 +391,7 @@ ChoicePage::applyActionChoice( ChoicePage::Choice choice )
|
|||||||
[]{},
|
[]{},
|
||||||
this );
|
this );
|
||||||
}
|
}
|
||||||
setNextEnabled( !m_beforePartitionBarsView->selectionModel()->selectedRows().isEmpty() );
|
updateNextEnabled();
|
||||||
|
|
||||||
connect( m_beforePartitionBarsView->selectionModel(), SIGNAL( currentRowChanged( QModelIndex, QModelIndex ) ),
|
connect( m_beforePartitionBarsView->selectionModel(), SIGNAL( currentRowChanged( QModelIndex, QModelIndex ) ),
|
||||||
this, SLOT( doReplaceSelectedPartition( QModelIndex, QModelIndex ) ),
|
this, SLOT( doReplaceSelectedPartition( QModelIndex, QModelIndex ) ),
|
||||||
@@ -415,7 +414,7 @@ ChoicePage::applyActionChoice( ChoicePage::Choice choice )
|
|||||||
},
|
},
|
||||||
this );
|
this );
|
||||||
}
|
}
|
||||||
setNextEnabled( !m_beforePartitionBarsView->selectionModel()->selectedRows().isEmpty() );
|
updateNextEnabled();
|
||||||
|
|
||||||
connect( m_beforePartitionBarsView->selectionModel(), SIGNAL( currentRowChanged( QModelIndex, QModelIndex ) ),
|
connect( m_beforePartitionBarsView->selectionModel(), SIGNAL( currentRowChanged( QModelIndex, QModelIndex ) ),
|
||||||
this, SLOT( doAlongsideSetupSplitter( QModelIndex, QModelIndex ) ),
|
this, SLOT( doAlongsideSetupSplitter( QModelIndex, QModelIndex ) ),
|
||||||
@@ -466,7 +465,7 @@ ChoicePage::doAlongsideSetupSplitter( const QModelIndex& current,
|
|||||||
Calamares::Branding::instance()->
|
Calamares::Branding::instance()->
|
||||||
string( Calamares::Branding::ProductName ) );
|
string( Calamares::Branding::ProductName ) );
|
||||||
|
|
||||||
setNextEnabled( m_beforePartitionBarsView->selectionModel()->currentIndex().isValid() );
|
updateNextEnabled();
|
||||||
|
|
||||||
if ( m_isEfi )
|
if ( m_isEfi )
|
||||||
setupEfiSystemPartitionSelector();
|
setupEfiSystemPartitionSelector();
|
||||||
@@ -475,6 +474,20 @@ ChoicePage::doAlongsideSetupSplitter( const QModelIndex& current,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
ChoicePage::onEncryptWidgetStateChanged()
|
||||||
|
{
|
||||||
|
EncryptWidget::State state = m_encryptWidget->state();
|
||||||
|
if ( m_choice == Erase )
|
||||||
|
{
|
||||||
|
if ( state == EncryptWidget::EncryptionConfirmed ||
|
||||||
|
state == EncryptWidget::EncryptionDisabled )
|
||||||
|
applyActionChoice( m_choice );
|
||||||
|
}
|
||||||
|
updateNextEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ChoicePage::onLeave()
|
ChoicePage::onLeave()
|
||||||
{
|
{
|
||||||
@@ -628,7 +641,7 @@ ChoicePage::doReplaceSelectedPartition( const QModelIndex& current,
|
|||||||
if ( m_isEfi )
|
if ( m_isEfi )
|
||||||
setupEfiSystemPartitionSelector();
|
setupEfiSystemPartitionSelector();
|
||||||
|
|
||||||
setNextEnabled( !m_beforePartitionBarsView->selectionModel()->selectedRows().isEmpty() );
|
updateNextEnabled();
|
||||||
if ( !m_bootloaderComboBox.isNull() &&
|
if ( !m_bootloaderComboBox.isNull() &&
|
||||||
m_bootloaderComboBox->currentIndex() < 0 )
|
m_bootloaderComboBox->currentIndex() < 0 )
|
||||||
m_bootloaderComboBox->setCurrentIndex( m_lastSelectedDeviceIndex );
|
m_bootloaderComboBox->setCurrentIndex( m_lastSelectedDeviceIndex );
|
||||||
@@ -770,10 +783,12 @@ ChoicePage::updateActionChoicePreview( ChoicePage::Choice choice )
|
|||||||
};
|
};
|
||||||
m_beforePartitionBarsView->setSelectionFilter( filter );
|
m_beforePartitionBarsView->setSelectionFilter( filter );
|
||||||
m_beforePartitionLabelsView->setSelectionFilter( filter );
|
m_beforePartitionLabelsView->setSelectionFilter( filter );
|
||||||
|
m_encryptWidget->hide();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Erase:
|
case Erase:
|
||||||
|
m_encryptWidget->show();
|
||||||
case Replace:
|
case Replace:
|
||||||
{
|
{
|
||||||
m_previewBeforeLabel->setText( tr( "Current:" ) );
|
m_previewBeforeLabel->setText( tr( "Current:" ) );
|
||||||
@@ -854,6 +869,7 @@ ChoicePage::updateActionChoicePreview( ChoicePage::Choice choice )
|
|||||||
m_previewAfterFrame->hide();
|
m_previewAfterFrame->hide();
|
||||||
m_previewBeforeLabel->setText( tr( "Current:" ) );
|
m_previewBeforeLabel->setText( tr( "Current:" ) );
|
||||||
m_previewAfterLabel->hide();
|
m_previewAfterLabel->hide();
|
||||||
|
m_encryptWidget->hide();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -903,7 +919,7 @@ ChoicePage::setupEfiSystemPartitionSelector()
|
|||||||
"partitioning to set up %1." )
|
"partitioning to set up %1." )
|
||||||
.arg( Calamares::Branding::instance()->
|
.arg( Calamares::Branding::instance()->
|
||||||
string( Calamares::Branding::ShortProductName ) ) );
|
string( Calamares::Branding::ShortProductName ) ) );
|
||||||
setNextEnabled( false );
|
updateNextEnabled();
|
||||||
}
|
}
|
||||||
else if ( efiSystemPartitions.count() == 1 ) //probably most usual situation
|
else if ( efiSystemPartitions.count() == 1 ) //probably most usual situation
|
||||||
{
|
{
|
||||||
@@ -1193,8 +1209,42 @@ ChoicePage::currentChoice() const
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ChoicePage::setNextEnabled( bool enabled )
|
ChoicePage::updateNextEnabled()
|
||||||
{
|
{
|
||||||
|
bool enabled = false;
|
||||||
|
|
||||||
|
switch ( m_choice )
|
||||||
|
{
|
||||||
|
case NoChoice:
|
||||||
|
enabled = false;
|
||||||
|
break;
|
||||||
|
case Replace:
|
||||||
|
enabled = !m_beforePartitionBarsView->selectionModel()->
|
||||||
|
selectedRows().isEmpty();
|
||||||
|
break;
|
||||||
|
case Alongside:
|
||||||
|
enabled = !m_beforePartitionBarsView->selectionModel()->
|
||||||
|
selectedRows().isEmpty() &&
|
||||||
|
m_beforePartitionBarsView->selectionModel()->
|
||||||
|
currentIndex().isValid();
|
||||||
|
break;
|
||||||
|
case Erase:
|
||||||
|
case Manual:
|
||||||
|
enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( m_isEfi &&
|
||||||
|
( m_choice == Alongside ||
|
||||||
|
m_choice == Replace ) )
|
||||||
|
{
|
||||||
|
if ( m_core->efiSystemPartitions().count() == 0 )
|
||||||
|
enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( m_encryptWidget->isVisible() &&
|
||||||
|
m_encryptWidget->state() == EncryptWidget::EncryptionUnconfirmed )
|
||||||
|
enabled = false;
|
||||||
|
|
||||||
if ( enabled == m_nextEnabled )
|
if ( enabled == m_nextEnabled )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -74,9 +74,10 @@ signals:
|
|||||||
private slots:
|
private slots:
|
||||||
void doReplaceSelectedPartition( const QModelIndex& current, const QModelIndex& previous );
|
void doReplaceSelectedPartition( const QModelIndex& current, const QModelIndex& previous );
|
||||||
void doAlongsideSetupSplitter( const QModelIndex& current, const QModelIndex& previous );
|
void doAlongsideSetupSplitter( const QModelIndex& current, const QModelIndex& previous );
|
||||||
|
void onEncryptWidgetStateChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setNextEnabled( bool enabled );
|
void updateNextEnabled();
|
||||||
void setupChoices();
|
void setupChoices();
|
||||||
QComboBox* createBootloaderComboBox( QWidget* parentButton );
|
QComboBox* createBootloaderComboBox( QWidget* parentButton );
|
||||||
Device* selectedDevice();
|
Device* selectedDevice();
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="m_rightLayout" stretch="0,1,0,0,0">
|
<layout class="QVBoxLayout" name="m_rightLayout" stretch="0,1,0,0,0,0">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="m_messageLabel">
|
<widget class="QLabel" name="m_messageLabel">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
@@ -63,7 +63,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>729</width>
|
<width>729</width>
|
||||||
<height>327</height>
|
<height>276</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="m_itemsLayout">
|
<layout class="QVBoxLayout" name="m_itemsLayout">
|
||||||
@@ -93,6 +93,9 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="EncryptWidget" name="m_encryptWidget" native="true"/>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="m_selectLabel">
|
<widget class="QLabel" name="m_selectLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -197,6 +200,14 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>EncryptWidget</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>gui/EncryptWidget.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|||||||
150
src/modules/partition/gui/EncryptWidget.cpp
Normal file
150
src/modules/partition/gui/EncryptWidget.cpp
Normal file
@@ -0,0 +1,150 @@
|
|||||||
|
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||||
|
*
|
||||||
|
* Copyright 2016, Teo Mrnjavac <teo@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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#include "EncryptWidget.h"
|
||||||
|
|
||||||
|
#include <utils/CalamaresUtilsGui.h>
|
||||||
|
|
||||||
|
EncryptWidget::EncryptWidget( QWidget* parent )
|
||||||
|
: QWidget( parent )
|
||||||
|
{
|
||||||
|
setupUi( this );
|
||||||
|
|
||||||
|
m_iconLabel->setFixedWidth( m_iconLabel->height() );
|
||||||
|
m_passphraseLineEdit->hide();
|
||||||
|
m_confirmLineEdit->hide();
|
||||||
|
m_iconLabel->hide();
|
||||||
|
|
||||||
|
connect( m_encryptCheckBox, &QCheckBox::stateChanged,
|
||||||
|
this, &EncryptWidget::onCheckBoxStateChanged );
|
||||||
|
connect( m_passphraseLineEdit, &QLineEdit::textEdited,
|
||||||
|
this, &EncryptWidget::onPassphraseEdited );
|
||||||
|
connect( m_confirmLineEdit, &QLineEdit::textEdited,
|
||||||
|
this, &EncryptWidget::onPassphraseEdited );
|
||||||
|
|
||||||
|
updateState();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
EncryptWidget::State
|
||||||
|
EncryptWidget::state() const
|
||||||
|
{
|
||||||
|
return m_state;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString
|
||||||
|
EncryptWidget::passphrase() const
|
||||||
|
{
|
||||||
|
if ( m_state == EncryptionConfirmed )
|
||||||
|
return m_passphraseLineEdit->text();
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
EncryptWidget::changeEvent( QEvent* e )
|
||||||
|
{
|
||||||
|
QWidget::changeEvent( e );
|
||||||
|
switch ( e->type() )
|
||||||
|
{
|
||||||
|
case QEvent::LanguageChange:
|
||||||
|
retranslateUi( this );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
EncryptWidget::updateState()
|
||||||
|
{
|
||||||
|
State newState;
|
||||||
|
if ( m_encryptCheckBox->isChecked() )
|
||||||
|
{
|
||||||
|
if ( !m_passphraseLineEdit->text().isEmpty() &&
|
||||||
|
m_passphraseLineEdit->text() == m_confirmLineEdit->text() )
|
||||||
|
{
|
||||||
|
newState = EncryptionConfirmed;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newState = EncryptionUnconfirmed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newState = EncryptionDisabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( newState != m_state )
|
||||||
|
{
|
||||||
|
m_state = newState;
|
||||||
|
emit stateChanged( m_state );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
EncryptWidget::onPassphraseEdited()
|
||||||
|
{
|
||||||
|
if ( !m_iconLabel->isVisible() )
|
||||||
|
m_iconLabel->show();
|
||||||
|
|
||||||
|
QString p1 = m_passphraseLineEdit->text();
|
||||||
|
QString p2 = m_confirmLineEdit->text();
|
||||||
|
|
||||||
|
m_iconLabel->setToolTip( QString() );
|
||||||
|
if ( p1.isEmpty() && p2.isEmpty() )
|
||||||
|
{
|
||||||
|
m_iconLabel->clear();
|
||||||
|
}
|
||||||
|
else if ( p1 == p2 )
|
||||||
|
{
|
||||||
|
m_iconLabel->setFixedWidth( m_iconLabel->height() );
|
||||||
|
m_iconLabel->setPixmap( CalamaresUtils::defaultPixmap( CalamaresUtils::Yes,
|
||||||
|
CalamaresUtils::Original,
|
||||||
|
m_iconLabel->size() ) );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_iconLabel->setFixedWidth( m_iconLabel->height() );
|
||||||
|
m_iconLabel->setPixmap( CalamaresUtils::defaultPixmap( CalamaresUtils::No,
|
||||||
|
CalamaresUtils::Original,
|
||||||
|
m_iconLabel->size() ) );
|
||||||
|
m_iconLabel->setToolTip( "Please enter the same passphrase in both boxes." );
|
||||||
|
}
|
||||||
|
|
||||||
|
updateState();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
EncryptWidget::onCheckBoxStateChanged( int state )
|
||||||
|
{
|
||||||
|
m_passphraseLineEdit->setVisible( state );
|
||||||
|
m_confirmLineEdit->setVisible( state );
|
||||||
|
m_iconLabel->setVisible( state );
|
||||||
|
m_passphraseLineEdit->clear();
|
||||||
|
m_confirmLineEdit->clear();
|
||||||
|
m_iconLabel->clear();
|
||||||
|
|
||||||
|
updateState();
|
||||||
|
}
|
||||||
57
src/modules/partition/gui/EncryptWidget.h
Normal file
57
src/modules/partition/gui/EncryptWidget.h
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||||
|
*
|
||||||
|
* Copyright 2016, Teo Mrnjavac <teo@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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef ENCRYPTWIDGET_H
|
||||||
|
#define ENCRYPTWIDGET_H
|
||||||
|
|
||||||
|
#include "ui_EncryptWidget.h"
|
||||||
|
|
||||||
|
class EncryptWidget : public QWidget, private Ui::EncryptWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum State : unsigned short
|
||||||
|
{
|
||||||
|
EncryptionDisabled = 0,
|
||||||
|
EncryptionUnconfirmed,
|
||||||
|
EncryptionConfirmed
|
||||||
|
};
|
||||||
|
|
||||||
|
explicit EncryptWidget( QWidget* parent = nullptr );
|
||||||
|
|
||||||
|
State state() const;
|
||||||
|
|
||||||
|
QString passphrase() const;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void stateChanged( State );
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void changeEvent( QEvent* e );
|
||||||
|
|
||||||
|
private:
|
||||||
|
void updateState();
|
||||||
|
void onPassphraseEdited();
|
||||||
|
void onCheckBoxStateChanged( int state );
|
||||||
|
|
||||||
|
State m_state;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // ENCRYPTWIDGET_H
|
||||||
58
src/modules/partition/gui/EncryptWidget.ui
Normal file
58
src/modules/partition/gui/EncryptWidget.ui
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>EncryptWidget</class>
|
||||||
|
<widget class="QWidget" name="EncryptWidget">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>822</width>
|
||||||
|
<height>59</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Form</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="m_encryptCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>En&crypt system</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="m_passphraseLineEdit">
|
||||||
|
<property name="echoMode">
|
||||||
|
<enum>QLineEdit::Password</enum>
|
||||||
|
</property>
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>Passphrase</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLineEdit" name="m_confirmLineEdit">
|
||||||
|
<property name="echoMode">
|
||||||
|
<enum>QLineEdit::Password</enum>
|
||||||
|
</property>
|
||||||
|
<property name="placeholderText">
|
||||||
|
<string>Confirm passphrase</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="m_iconLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
@@ -54,7 +54,6 @@
|
|||||||
PartitionPage::PartitionPage( PartitionCoreModule* core, QWidget* parent )
|
PartitionPage::PartitionPage( PartitionCoreModule* core, QWidget* parent )
|
||||||
: QWidget( parent )
|
: QWidget( parent )
|
||||||
, m_ui( new Ui_PartitionPage )
|
, m_ui( new Ui_PartitionPage )
|
||||||
, m_lastSelectedBootLoaderIndex(-1)
|
|
||||||
, m_core( core )
|
, m_core( core )
|
||||||
{
|
{
|
||||||
m_ui->setupUi( this );
|
m_ui->setupUi( this );
|
||||||
@@ -75,11 +74,6 @@ PartitionPage::PartitionPage( PartitionCoreModule* core, QWidget* parent )
|
|||||||
{
|
{
|
||||||
updateFromCurrentDevice();
|
updateFromCurrentDevice();
|
||||||
} );
|
} );
|
||||||
connect( m_ui->bootLoaderComboBox, static_cast<void(QComboBox::*)(const QString &)>(&QComboBox::activated),
|
|
||||||
[ this ]( const QString& /* text */ )
|
|
||||||
{
|
|
||||||
m_lastSelectedBootLoaderIndex = m_ui->bootLoaderComboBox->currentIndex();
|
|
||||||
} );
|
|
||||||
|
|
||||||
connect( m_ui->bootLoaderComboBox, &QComboBox::currentTextChanged,
|
connect( m_ui->bootLoaderComboBox, &QComboBox::currentTextChanged,
|
||||||
[ this ]( const QString& /* text */ )
|
[ this ]( const QString& /* text */ )
|
||||||
@@ -100,7 +94,7 @@ PartitionPage::PartitionPage( PartitionCoreModule* core, QWidget* parent )
|
|||||||
m_ui->bootLoaderComboBox->hide();
|
m_ui->bootLoaderComboBox->hide();
|
||||||
m_ui->label_3->hide();
|
m_ui->label_3->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
CALAMARES_RETRANSLATE( m_ui->retranslateUi( this ); )
|
CALAMARES_RETRANSLATE( m_ui->retranslateUi( this ); )
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,9 +152,6 @@ PartitionPage::onNewPartitionTableClicked()
|
|||||||
m_core->createPartitionTable( device, type );
|
m_core->createPartitionTable( device, type );
|
||||||
}
|
}
|
||||||
delete dlg;
|
delete dlg;
|
||||||
// PartionModelReset isn't emmited after createPartitionTable, so we have to manually update
|
|
||||||
// the bootLoader index after the reset.
|
|
||||||
updateBootLoaderIndex();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -197,7 +188,6 @@ PartitionPage::onEditClicked()
|
|||||||
updatePartitionToCreate( model->device(), partition );
|
updatePartitionToCreate( model->device(), partition );
|
||||||
else
|
else
|
||||||
editExistingPartition( model->device(), partition );
|
editExistingPartition( model->device(), partition );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -227,12 +217,7 @@ PartitionPage::onRevertClicked()
|
|||||||
m_ui->deviceComboBox->setCurrentIndex( oldIndex );
|
m_ui->deviceComboBox->setCurrentIndex( oldIndex );
|
||||||
updateFromCurrentDevice();
|
updateFromCurrentDevice();
|
||||||
} ),
|
} ),
|
||||||
[ this ]{
|
[]{},
|
||||||
m_lastSelectedBootLoaderIndex = -1;
|
|
||||||
if( m_ui->bootLoaderComboBox->currentIndex() < 0 ) {
|
|
||||||
m_ui->bootLoaderComboBox->setCurrentIndex( 0 );
|
|
||||||
}
|
|
||||||
},
|
|
||||||
this );
|
this );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -351,14 +336,4 @@ PartitionPage::onPartitionModelReset()
|
|||||||
{
|
{
|
||||||
m_ui->partitionTreeView->expandAll();
|
m_ui->partitionTreeView->expandAll();
|
||||||
updateButtons();
|
updateButtons();
|
||||||
updateBootLoaderIndex();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
PartitionPage::updateBootLoaderIndex()
|
|
||||||
{
|
|
||||||
// set bootloader back to user selected index
|
|
||||||
if ( m_lastSelectedBootLoaderIndex >= 0 && m_ui->bootLoaderComboBox->count() ) {
|
|
||||||
m_ui->bootLoaderComboBox->setCurrentIndex( m_lastSelectedBootLoaderIndex );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,10 +60,8 @@ private:
|
|||||||
void editExistingPartition( Device*, Partition* );
|
void editExistingPartition( Device*, Partition* );
|
||||||
void updateBootLoaderInstallPath();
|
void updateBootLoaderInstallPath();
|
||||||
void updateFromCurrentDevice();
|
void updateFromCurrentDevice();
|
||||||
void updateBootLoaderIndex();
|
|
||||||
|
|
||||||
QMutex m_revertMutex;
|
QMutex m_revertMutex;
|
||||||
int m_lastSelectedBootLoaderIndex;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // PARTITIONPAGE_H
|
#endif // PARTITIONPAGE_H
|
||||||
|
|||||||
@@ -52,15 +52,13 @@
|
|||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QStackedWidget>
|
#include <QStackedWidget>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QtConcurrent/QtConcurrent>
|
|
||||||
#include <QFutureWatcher>
|
|
||||||
|
|
||||||
PartitionViewStep::PartitionViewStep( QObject* parent )
|
PartitionViewStep::PartitionViewStep( QObject* parent )
|
||||||
: Calamares::ViewStep( parent )
|
: Calamares::ViewStep( parent )
|
||||||
, m_widget( new QStackedWidget() )
|
, m_widget( new QStackedWidget() )
|
||||||
, m_core( nullptr )
|
, m_core( new PartitionCoreModule( this ) )
|
||||||
, m_choicePage( nullptr )
|
, m_choicePage( nullptr )
|
||||||
, m_manualPartitionPage( nullptr )
|
, m_manualPartitionPage( new PartitionPage( m_core ) )
|
||||||
{
|
{
|
||||||
m_widget->setContentsMargins( 0, 0, 0, 0 );
|
m_widget->setContentsMargins( 0, 0, 0, 0 );
|
||||||
|
|
||||||
@@ -72,21 +70,10 @@ PartitionViewStep::PartitionViewStep( QObject* parent )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
PartitionViewStep::initPartitionCoreModule()
|
|
||||||
{
|
|
||||||
Q_ASSERT( !m_core );
|
|
||||||
m_core = new PartitionCoreModule( this );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PartitionViewStep::continueLoading()
|
PartitionViewStep::continueLoading()
|
||||||
{
|
{
|
||||||
Q_ASSERT( !m_choicePage );
|
Q_ASSERT( !m_choicePage );
|
||||||
Q_ASSERT( !m_manualPartitionPage );
|
|
||||||
|
|
||||||
m_manualPartitionPage = new PartitionPage( m_core );
|
|
||||||
m_choicePage = new ChoicePage();
|
m_choicePage = new ChoicePage();
|
||||||
|
|
||||||
m_choicePage->init( m_core );
|
m_choicePage->init( m_core );
|
||||||
@@ -476,20 +463,7 @@ PartitionViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
|||||||
gs->insert( "drawNestedPartitions", false );
|
gs->insert( "drawNestedPartitions", false );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now that we have the config, we load the PartitionCoreModule in the background
|
QTimer::singleShot( 0, this, &PartitionViewStep::continueLoading );
|
||||||
// because it could take a while. Then when it's done, we can set up the widgets
|
|
||||||
// and remove the spinner.
|
|
||||||
QFutureWatcher< void >* watcher = new QFutureWatcher< void >();
|
|
||||||
connect( watcher, &QFutureWatcher< void >::finished,
|
|
||||||
this, [ this, watcher ]
|
|
||||||
{
|
|
||||||
continueLoading();
|
|
||||||
watcher->deleteLater();
|
|
||||||
} );
|
|
||||||
|
|
||||||
QFuture< void > future =
|
|
||||||
QtConcurrent::run( this, &PartitionViewStep::initPartitionCoreModule );
|
|
||||||
watcher->setFuture( future );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ public:
|
|||||||
explicit PartitionViewStep( QObject* parent = 0 );
|
explicit PartitionViewStep( QObject* parent = 0 );
|
||||||
virtual ~PartitionViewStep();
|
virtual ~PartitionViewStep();
|
||||||
|
|
||||||
|
void continueLoading();
|
||||||
|
|
||||||
QString prettyName() const override;
|
QString prettyName() const override;
|
||||||
QWidget* createSummaryWidget() const override;
|
QWidget* createSummaryWidget() const override;
|
||||||
|
|
||||||
@@ -66,9 +68,6 @@ public:
|
|||||||
QList< Calamares::job_ptr > jobs() const override;
|
QList< Calamares::job_ptr > jobs() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initPartitionCoreModule();
|
|
||||||
void continueLoading();
|
|
||||||
|
|
||||||
PartitionCoreModule* m_core;
|
PartitionCoreModule* m_core;
|
||||||
QStackedWidget* m_widget;
|
QStackedWidget* m_widget;
|
||||||
ChoicePage* m_choicePage;
|
ChoicePage* m_choicePage;
|
||||||
|
|||||||
@@ -31,11 +31,13 @@
|
|||||||
#include <kpmcore/core/device.h>
|
#include <kpmcore/core/device.h>
|
||||||
#include <kpmcore/core/partition.h>
|
#include <kpmcore/core/partition.h>
|
||||||
#include <kpmcore/fs/filesystem.h>
|
#include <kpmcore/fs/filesystem.h>
|
||||||
|
#include <kpmcore/fs/luks.h>
|
||||||
|
|
||||||
// Qt
|
// Qt
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
|
#include <QProcess>
|
||||||
|
|
||||||
typedef QHash<QString, QString> UuidForPartitionHash;
|
typedef QHash<QString, QString> UuidForPartitionHash;
|
||||||
|
|
||||||
@@ -61,6 +63,22 @@ findPartitionUuids( QList < Device* > devices )
|
|||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static QString
|
||||||
|
getLuksUuid( const QString& path )
|
||||||
|
{
|
||||||
|
QProcess process;
|
||||||
|
process.setProgram( "cryptsetup" );
|
||||||
|
process.setArguments( { "luksUUID", path } );
|
||||||
|
process.start();
|
||||||
|
process.waitForFinished();
|
||||||
|
if ( process.exitStatus() != QProcess::NormalExit || process.exitCode() )
|
||||||
|
return QString();
|
||||||
|
QString uuid = QString::fromLocal8Bit( process.readAllStandardOutput() ).trimmed();
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static QVariant
|
static QVariant
|
||||||
mapForPartition( Partition* partition, const QString& uuid )
|
mapForPartition( Partition* partition, const QString& uuid )
|
||||||
{
|
{
|
||||||
@@ -73,6 +91,20 @@ mapForPartition( Partition* partition, const QString& uuid )
|
|||||||
<< "mtpoint:" << PartitionInfo::mountPoint( partition )
|
<< "mtpoint:" << PartitionInfo::mountPoint( partition )
|
||||||
<< "fs:" << partition->fileSystem().name()
|
<< "fs:" << partition->fileSystem().name()
|
||||||
<< uuid;
|
<< uuid;
|
||||||
|
|
||||||
|
if ( partition->roles().has( PartitionRole::Luks ) )
|
||||||
|
{
|
||||||
|
const FileSystem& fsRef = partition->fileSystem();
|
||||||
|
const FS::luks* luksFs = dynamic_cast< const FS::luks* >( &fsRef );
|
||||||
|
if ( luksFs )
|
||||||
|
{
|
||||||
|
map[ "luksMapperName" ] = luksFs->mapperName( partition->partitionPath() ).split( "/" ).last();
|
||||||
|
map[ "luksUuid" ] = getLuksUuid( partition->partitionPath() );
|
||||||
|
map[ "luksPassphrase" ] = luksFs->passphrase();
|
||||||
|
cDebug() << "luksMapperName:" << map[ "luksMapperName" ];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user