From 4d5eb90a04a175adb3d2e9493bd754cbdd4411f6 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 14 Sep 2018 07:56:18 -0400 Subject: [PATCH 01/70] [fsresize] Add new module fsresizer - Non-functional as yet, WIP - Intended for use on SBC images and similar, which need to resize the root partition to the size of the SD card they're on. FIXES #921 --- src/modules/fsresizer/CMakeLists.txt | 27 +++++++ src/modules/fsresizer/ResizeFSJob.cpp | 104 ++++++++++++++++++++++++++ src/modules/fsresizer/ResizeFSJob.h | 75 +++++++++++++++++++ src/modules/fsresizer/fsresizer.conf | 30 ++++++++ 4 files changed, 236 insertions(+) create mode 100644 src/modules/fsresizer/CMakeLists.txt create mode 100644 src/modules/fsresizer/ResizeFSJob.cpp create mode 100644 src/modules/fsresizer/ResizeFSJob.h create mode 100644 src/modules/fsresizer/fsresizer.conf diff --git a/src/modules/fsresizer/CMakeLists.txt b/src/modules/fsresizer/CMakeLists.txt new file mode 100644 index 000000000..7d1760cc4 --- /dev/null +++ b/src/modules/fsresizer/CMakeLists.txt @@ -0,0 +1,27 @@ +find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE) + +find_package( KPMcore 3.3 ) +find_package( Qt5 REQUIRED DBus ) # Needed for KPMCore +find_package( KF5 REQUIRED I18n WidgetsAddons ) # Needed for KPMCore + +if ( KPMcore_FOUND ) + if ( KPMcore_VERSION VERSION_GREATER "3.3.0") + add_definitions(-DWITH_KPMCOREGT33) # kpmcore greater than 3.3 + endif() + + include_directories( ${KPMCORE_INCLUDE_DIR} ) + include_directories( ${PROJECT_BINARY_DIR}/src/libcalamares ) + + calamares_add_plugin( fsresizer + TYPE job + EXPORT_MACRO PLUGINDLLEXPORT_PRO + SOURCES + ResizeFSJob.cpp + LINK_PRIVATE_LIBRARIES + kpmcore + calamares + SHARED_LIB + ) +else() + calamares_skip_module( "fsresizer (missing suitable KPMcore)" ) +endif() diff --git a/src/modules/fsresizer/ResizeFSJob.cpp b/src/modules/fsresizer/ResizeFSJob.cpp new file mode 100644 index 000000000..4a7b0da59 --- /dev/null +++ b/src/modules/fsresizer/ResizeFSJob.cpp @@ -0,0 +1,104 @@ +/* === This file is part of Calamares - === + * + * Copyright 2018, Adriaan de Groot + * + * 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 . + */ + +#include "ResizeFSJob.h" + +#include +#include +#include + +#include "CalamaresVersion.h" +#include "JobQueue.h" +#include "GlobalStorage.h" + +#include "utils/Logger.h" + +ResizeFSJob::RelativeSize::RelativeSize() + : m_unit( None ) + , m_value( 0 ) +{ +} + + +ResizeFSJob::RelativeSize::RelativeSize( const QString& s) + : m_unit( None ) + , m_value( 0 ) +{ + QString valuePart; + + if ( s.endsWith( '%' ) ) + { + valuePart = s.left( s.length() - 1 ); + m_unit = Percent; + } + if ( s.endsWith( "MiB" ) ) + { + valuePart = s.left( s.length() - 3 ); + m_unit = Absolute; + } + + if ( ( m_unit != None ) && !valuePart.isEmpty() ) + m_value = valuePart.toInt(); + + if ( !m_value ) + m_unit = None; +} + + +ResizeFSJob::ResizeFSJob( QObject* parent ) + : Calamares::CppJob( parent ) +{ +} + + +ResizeFSJob::~ResizeFSJob() +{ +} + + +QString +ResizeFSJob::prettyName() const +{ + return tr( "Resize Filesystem Job" ); +} + + +Calamares::JobResult +ResizeFSJob::exec() +{ + return Calamares::JobResult::ok(); +} + + +void +ResizeFSJob::setConfigurationMap( const QVariantMap& configurationMap ) +{ + m_fsname = configurationMap["fs"].toString(); + m_devicename = configurationMap["dev"].toString(); + + if ( m_fsname.isEmpty() && m_devicename.isEmpty() ) + { + cWarning() << "No fs or dev configured for resize."; + return; + } + + m_size = RelativeSize( configurationMap["size"].toString() ); + m_atleast = RelativeSize( configurationMap["atleast"].toString() ); +} + +CALAMARES_PLUGIN_FACTORY_DEFINITION( ResizeFSJobFactory, registerPlugin(); ) diff --git a/src/modules/fsresizer/ResizeFSJob.h b/src/modules/fsresizer/ResizeFSJob.h new file mode 100644 index 000000000..681328f81 --- /dev/null +++ b/src/modules/fsresizer/ResizeFSJob.h @@ -0,0 +1,75 @@ +/* === This file is part of Calamares - === + * + * Copyright 2018, Adriaan de Groot + * + * 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 . + */ + +#ifndef RESIZEFSJOB_H +#define RESIZEFSJOB_H + +#include +#include + +#include + +#include + +#include + +class PLUGINDLLEXPORT ResizeFSJob : public Calamares::CppJob +{ + Q_OBJECT + + class RelativeSize + { + public: + RelativeSize(); + RelativeSize( const QString& ); + + enum Unit + { + None, + Percent, + Absolute + }; + + quint64 value() const { return m_value; } + Unit unit() const { return m_unit; } + + private: + quint64 m_value; + Unit m_unit; + } ; + +public: + explicit ResizeFSJob( QObject* parent = nullptr ); + virtual ~ResizeFSJob() override; + + QString prettyName() const override; + + Calamares::JobResult exec() override; + + void setConfigurationMap( const QVariantMap& configurationMap ) override; + +private: + RelativeSize m_size; + RelativeSize m_atleast; + QString m_fsname; // Either this, or devicename, is set, not both + QString m_devicename; +}; + +CALAMARES_PLUGIN_FACTORY_DECLARATION( ResizeFSJobFactory ) + +#endif // RESIZEFSJOB_H diff --git a/src/modules/fsresizer/fsresizer.conf b/src/modules/fsresizer/fsresizer.conf new file mode 100644 index 000000000..1539a7751 --- /dev/null +++ b/src/modules/fsresizer/fsresizer.conf @@ -0,0 +1,30 @@ +# Module that resizes a single FS to fill the entire (rest) of +# a device. This is used in OEM situations where an image is +# flashed onto an SD card (or similar) and used to boot a device, +# after which the FS should expand to fill the SD card. +# +# Example: a distro produces a 6GiB large image that is +# written to an 8GiB SD card; the FS should expand to take +# advantage of the unused 2GiB. The FS should expand much +# more if the same image is written to a 16GiB card. +-- + +# Which FS needs to be grown? Choose one way to identify it: +# - *fs* names a mount point which should already be mounted +# in the system. +# - *dev* names a device +fs: / +# dev: /dev/mmcblk0p1 + +# How much of the total remaining space should the FS use? +# The only sensible amount is "all of it". The value is +# in percent, so set it to 100. Perhaps a fixed size is +# needed (that would be weird though, since you don't know +# how big the card is), use MiB as suffix in that case. +size: 100% + +# Resizing might not be worth it, though. Set the minimum +# that it must grow; if it cannot grow that much, the +# resizing is skipped. Can be in percentage or absolute +# size, as above. +atleast: 1000MiB From fa567f917af80653f4c5aaa35b994590a766f344 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 14 Sep 2018 16:45:24 +0200 Subject: [PATCH 02/70] Changelog: explain new module --- CHANGES | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGES b/CHANGES index 56526aad2..f4d86a0e2 100644 --- a/CHANGES +++ b/CHANGES @@ -11,6 +11,11 @@ This release contains contributions from (alphabetically by first name): ## Modules ## + - New module *fsresizer* can be used to resize filesystems. It is intended + for use in OEM installs where an image of fixed size is created, + and then sized to the actual SD card the user has used. + + # 3.2.2 (2018-09-04) # This release contains contributions from (alphabetically by first name): From cdfb55e5cf70c098c83245761bc79f84b4626f71 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 14 Sep 2018 16:49:07 +0200 Subject: [PATCH 03/70] [fsresizer] Just right now it doesn't need KPMCore - Drop the dependency while developing the configuration parser part of the module and writing initial tests. --- src/modules/fsresizer/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/fsresizer/CMakeLists.txt b/src/modules/fsresizer/CMakeLists.txt index 7d1760cc4..5097c53b0 100644 --- a/src/modules/fsresizer/CMakeLists.txt +++ b/src/modules/fsresizer/CMakeLists.txt @@ -4,7 +4,7 @@ find_package( KPMcore 3.3 ) find_package( Qt5 REQUIRED DBus ) # Needed for KPMCore find_package( KF5 REQUIRED I18n WidgetsAddons ) # Needed for KPMCore -if ( KPMcore_FOUND ) +if ( 1 ) # KPMcore_FOUND ) if ( KPMcore_VERSION VERSION_GREATER "3.3.0") add_definitions(-DWITH_KPMCOREGT33) # kpmcore greater than 3.3 endif() @@ -18,7 +18,7 @@ if ( KPMcore_FOUND ) SOURCES ResizeFSJob.cpp LINK_PRIVATE_LIBRARIES - kpmcore + # kpmcore calamares SHARED_LIB ) From a81588190a161b7232690717db8ee6dcbffe8e9f Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 14 Sep 2018 16:51:09 +0200 Subject: [PATCH 04/70] [fsresizer] Simplify and make safer - Make RelativeSize public so we can use it in non-member functions - Make a template out of matching the string suffixes; this is safer because the length of the suffix can be computed at compile-time (+1 for the trailing NUL) rather than writing it out in boilerplate. --- src/modules/fsresizer/ResizeFSJob.cpp | 42 +++++++++++++++------------ src/modules/fsresizer/ResizeFSJob.h | 6 ++-- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/src/modules/fsresizer/ResizeFSJob.cpp b/src/modules/fsresizer/ResizeFSJob.cpp index 4a7b0da59..e10894c30 100644 --- a/src/modules/fsresizer/ResizeFSJob.cpp +++ b/src/modules/fsresizer/ResizeFSJob.cpp @@ -29,32 +29,36 @@ #include "utils/Logger.h" ResizeFSJob::RelativeSize::RelativeSize() - : m_unit( None ) - , m_value( 0 ) + : m_value( 0 ) + , m_unit( None ) { } -ResizeFSJob::RelativeSize::RelativeSize( const QString& s) - : m_unit( None ) - , m_value( 0 ) +template +void matchUnitSuffix( + const QString& s, + const char (&suffix)[N], + ResizeFSJob::RelativeSize::Unit matchedUnit, + int& value, + ResizeFSJob::RelativeSize::Unit& unit + ) { - QString valuePart; - - if ( s.endsWith( '%' ) ) + if ( s.endsWith( suffix ) ) { - valuePart = s.left( s.length() - 1 ); - m_unit = Percent; + value = s.left( s.length() - N + 1 ).toInt(); + unit = matchedUnit; } - if ( s.endsWith( "MiB" ) ) - { - valuePart = s.left( s.length() - 3 ); - m_unit = Absolute; - } - - if ( ( m_unit != None ) && !valuePart.isEmpty() ) - m_value = valuePart.toInt(); - +} + + +ResizeFSJob::RelativeSize::RelativeSize( const QString& s) + : m_value( 0 ) + , m_unit( None ) +{ + matchUnitSuffix( s, "%", Percent, m_value, m_unit ); + matchUnitSuffix( s, "MiB", Absolute, m_value, m_unit ); + if ( !m_value ) m_unit = None; } diff --git a/src/modules/fsresizer/ResizeFSJob.h b/src/modules/fsresizer/ResizeFSJob.h index 681328f81..415d04c81 100644 --- a/src/modules/fsresizer/ResizeFSJob.h +++ b/src/modules/fsresizer/ResizeFSJob.h @@ -32,6 +32,7 @@ class PLUGINDLLEXPORT ResizeFSJob : public Calamares::CppJob { Q_OBJECT +public: class RelativeSize { public: @@ -45,15 +46,14 @@ class PLUGINDLLEXPORT ResizeFSJob : public Calamares::CppJob Absolute }; - quint64 value() const { return m_value; } + int value() const { return m_value; } Unit unit() const { return m_unit; } private: - quint64 m_value; + int m_value; Unit m_unit; } ; -public: explicit ResizeFSJob( QObject* parent = nullptr ); virtual ~ResizeFSJob() override; From a6c3899e10c28a366e6b27ae4b5bcce33f4a1e1f Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 14 Sep 2018 17:59:50 +0200 Subject: [PATCH 05/70] [fsresizer] Add tests - Test the parsing of configuration values, that it gets the right values when given correct(-ish) configurations. Doesn't test any situations with bad config. --- src/modules/fsresizer/CMakeLists.txt | 22 ++++- src/modules/fsresizer/Tests.cpp | 126 +++++++++++++++++++++++++++ src/modules/fsresizer/Tests.h | 39 +++++++++ 3 files changed, 185 insertions(+), 2 deletions(-) create mode 100644 src/modules/fsresizer/Tests.cpp create mode 100644 src/modules/fsresizer/Tests.h diff --git a/src/modules/fsresizer/CMakeLists.txt b/src/modules/fsresizer/CMakeLists.txt index 5097c53b0..c3585bbcd 100644 --- a/src/modules/fsresizer/CMakeLists.txt +++ b/src/modules/fsresizer/CMakeLists.txt @@ -1,5 +1,3 @@ -find_package(ECM ${ECM_VERSION} REQUIRED NO_MODULE) - find_package( KPMcore 3.3 ) find_package( Qt5 REQUIRED DBus ) # Needed for KPMCore find_package( KF5 REQUIRED I18n WidgetsAddons ) # Needed for KPMCore @@ -22,6 +20,26 @@ if ( 1 ) # KPMcore_FOUND ) calamares SHARED_LIB ) + + if( ECM_FOUND ) + find_package( Qt5 COMPONENTS Test REQUIRED ) + include( ECMAddTests ) + + ecm_add_test( + Tests.cpp + TEST_NAME + fsresizertest + LINK_LIBRARIES + ${CALAMARES_LIBRARIES} + calamares + calamares_job_fsresizer # From above + ${YAMLCPP_LIBRARY} + Qt5::Core + Qt5::Test + ) + set_target_properties( fsresizertest PROPERTIES AUTOMOC TRUE ) + target_include_directories(fsresizertest PRIVATE /usr/local/include ) + endif() else() calamares_skip_module( "fsresizer (missing suitable KPMcore)" ) endif() diff --git a/src/modules/fsresizer/Tests.cpp b/src/modules/fsresizer/Tests.cpp new file mode 100644 index 000000000..255153fa2 --- /dev/null +++ b/src/modules/fsresizer/Tests.cpp @@ -0,0 +1,126 @@ +/* === This file is part of Calamares - === + * + * Copyright 2017-2018, Adriaan de Groot + * + * 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 . + */ + +#include "Tests.h" + +#include "GlobalStorage.h" +#include "JobQueue.h" +#include "Settings.h" + +#include "utils/Logger.h" +#include "utils/YamlUtils.h" + +#include + +#include + +#include +#include + +#define private public +#include "ResizeFSJob.h" +#undef private + +QTEST_GUILESS_MAIN( FSResizerTests ) + +FSResizerTests::FSResizerTests() +{ +} + +FSResizerTests::~FSResizerTests() +{ +} + +void +FSResizerTests::initTestCase() +{ +} + +void FSResizerTests::testConfigurationRobust() +{ + ResizeFSJob j; + + // Empty config + j.setConfigurationMap( QVariantMap() ); + QVERIFY( j.m_fsname.isEmpty() ); + QVERIFY( j.m_devicename.isEmpty() ); + QCOMPARE( j.m_size.unit(), ResizeFSJob::RelativeSize::None ); + QCOMPARE( j.m_atleast.unit(), ResizeFSJob::RelativeSize::None ); + + // Config is missing fs and dev, so it isn't valid + YAML::Node doc0 = YAML::Load( R"(--- +size: 100% +atleast: 600MiB +)" ); + j.setConfigurationMap( CalamaresUtils::yamlMapToVariant( doc0 ).toMap() ); + QVERIFY( j.m_fsname.isEmpty() ); + QVERIFY( j.m_devicename.isEmpty() ); + QCOMPARE( j.m_size.unit(), ResizeFSJob::RelativeSize::None ); + QCOMPARE( j.m_atleast.unit(), ResizeFSJob::RelativeSize::None ); + QCOMPARE( j.m_size.value(), 0 ); + QCOMPARE( j.m_atleast.value(), 0 ); +} + +void FSResizerTests::testConfigurationValues() +{ + ResizeFSJob j; + + // Check both + YAML::Node doc0 = YAML::Load( R"(--- +fs: / +size: 100% +atleast: 600MiB +)" ); + j.setConfigurationMap( CalamaresUtils::yamlMapToVariant( doc0 ).toMap() ); + QVERIFY( !j.m_fsname.isEmpty() ); + QVERIFY( j.m_devicename.isEmpty() ); + QCOMPARE( j.m_size.unit(), ResizeFSJob::RelativeSize::Percent ); + QCOMPARE( j.m_atleast.unit(), ResizeFSJob::RelativeSize::Absolute ); + QCOMPARE( j.m_size.value(), 100 ); + QCOMPARE( j.m_atleast.value(), 600 ); + + // Silly config + doc0 = YAML::Load( R"(--- +fs: / +dev: /dev/m00 +size: 72 MiB +atleast: 127 % +)" ); + j.setConfigurationMap( CalamaresUtils::yamlMapToVariant( doc0 ).toMap() ); + QVERIFY( !j.m_fsname.isEmpty() ); + QVERIFY( !j.m_devicename.isEmpty() ); + QCOMPARE( j.m_size.unit(), ResizeFSJob::RelativeSize::Absolute ); + QCOMPARE( j.m_atleast.unit(), ResizeFSJob::RelativeSize::Percent ); + QCOMPARE( j.m_size.value(), 72 ); + QCOMPARE( j.m_atleast.value(), 127 ); + + // Silly config + doc0 = YAML::Load( R"(--- +fs: / +# dev: /dev/m00 +size: 71MiB +# atleast: 127% +)" ); + j.setConfigurationMap( CalamaresUtils::yamlMapToVariant( doc0 ).toMap() ); + QVERIFY( !j.m_fsname.isEmpty() ); + QVERIFY( j.m_devicename.isEmpty() ); + QCOMPARE( j.m_size.unit(), ResizeFSJob::RelativeSize::Absolute ); + QCOMPARE( j.m_atleast.unit(), ResizeFSJob::RelativeSize::None ); + QCOMPARE( j.m_size.value(), 71 ); + QCOMPARE( j.m_atleast.value(), 0 ); +} diff --git a/src/modules/fsresizer/Tests.h b/src/modules/fsresizer/Tests.h new file mode 100644 index 000000000..958c0e655 --- /dev/null +++ b/src/modules/fsresizer/Tests.h @@ -0,0 +1,39 @@ +/* === This file is part of Calamares - === + * + * Copyright 2018, Adriaan de Groot + * + * 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 . + */ + +#ifndef TESTS_H +#define TESTS_H + +#include + +class FSResizerTests : public QObject +{ + Q_OBJECT +public: + FSResizerTests(); + ~FSResizerTests() override; + +private Q_SLOTS: + void initTestCase(); + // Can handle missing values + void testConfigurationRobust(); + // Can parse % and MiB values + void testConfigurationValues(); +}; + +#endif From 745629b659997f15f272cc6bfa2d31ea7a3b284c Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 17 Sep 2018 06:58:18 -0400 Subject: [PATCH 06/70] [fsresizer] Turn on KPMCore requirement again --- src/modules/fsresizer/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/fsresizer/CMakeLists.txt b/src/modules/fsresizer/CMakeLists.txt index c3585bbcd..ae87de160 100644 --- a/src/modules/fsresizer/CMakeLists.txt +++ b/src/modules/fsresizer/CMakeLists.txt @@ -2,7 +2,7 @@ find_package( KPMcore 3.3 ) find_package( Qt5 REQUIRED DBus ) # Needed for KPMCore find_package( KF5 REQUIRED I18n WidgetsAddons ) # Needed for KPMCore -if ( 1 ) # KPMcore_FOUND ) +if ( KPMcore_FOUND ) if ( KPMcore_VERSION VERSION_GREATER "3.3.0") add_definitions(-DWITH_KPMCOREGT33) # kpmcore greater than 3.3 endif() @@ -16,7 +16,7 @@ if ( 1 ) # KPMcore_FOUND ) SOURCES ResizeFSJob.cpp LINK_PRIVATE_LIBRARIES - # kpmcore + kpmcore calamares SHARED_LIB ) From 40e031411c50e35ce54af3adc26c68e59fce9881 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 20 Sep 2018 07:01:27 -0400 Subject: [PATCH 07/70] [calamares] Improve debug log in module test-loader --- src/calamares/testmain.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/calamares/testmain.cpp b/src/calamares/testmain.cpp index c22342f9a..86f971462 100644 --- a/src/calamares/testmain.cpp +++ b/src/calamares/testmain.cpp @@ -158,7 +158,7 @@ main( int argc, char* argv[] ) std::unique_ptr< Calamares::Settings > settings_p( new Calamares::Settings( QString(), true ) ); std::unique_ptr< Calamares::JobQueue > jobqueue_p( new Calamares::JobQueue( nullptr ) ); - cDebug() << "Calamares test module-loader" << module.moduleName(); + cDebug() << "Calamares module-loader testing" << module.moduleName(); Calamares::Module* m = load_module( module ); if ( !m ) { @@ -175,13 +175,19 @@ main( int argc, char* argv[] ) return 1; } - cDebug() << "Module" << m->name() << m->typeString() << m->interfaceString(); + using TR = Logger::DebugRow; + cDebug() << "Module metadata" + << TR( "name", m->name() ) + << TR( "type", m->typeString() ) + << TR( "interface", m->interfaceString() ); + + cDebug() << "Job outputs:"; Calamares::JobList jobList = m->jobs(); unsigned int count = 1; for ( const auto& p : jobList ) { - cDebug() << count << p->prettyName(); + cDebug() << "Job #" << count << "name" << p->prettyName(); Calamares::JobResult r = p->exec(); if ( !r ) cDebug() << count << ".. failed" << r; From c6e8cdf65b2de2f148ee4e82817149848fd09326 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 20 Sep 2018 07:07:17 -0400 Subject: [PATCH 08/70] [calamares] Better command-line help in module test-loader --- src/calamares/testmain.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/calamares/testmain.cpp b/src/calamares/testmain.cpp index 86f971462..8efdfd80d 100644 --- a/src/calamares/testmain.cpp +++ b/src/calamares/testmain.cpp @@ -59,6 +59,7 @@ handle_args( QCoreApplication& a ) parser.addOption( debugLevelOption ); parser.addPositionalArgument( "module", "Path or name of module to run." ); + parser.addPositionalArgument( "config", "Path of job-config file to use.", "[config]"); parser.process( a ); @@ -140,6 +141,8 @@ load_module( const ModuleConfig& moduleConfig ) ? moduleDirectory + '/' + name + ".conf" : moduleConfig.configFile() ); + cDebug() << "Module" << moduleName << "job-configuration:" << configFile; + Calamares::Module* module = Calamares::Module::fromDescriptor( descriptor, name, configFile, moduleDirectory ); From 39a0d2315b2a31f22242bbfb3622636bd8d5c028 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 20 Sep 2018 07:39:43 -0400 Subject: [PATCH 09/70] [calamares] Better config-loading diagnostics - Be more verbose when things go wrong while loading module- configuration files. - Allow more forms of paths to be specified. In debug mode, this is mostyle helpful for the module test-loader. --- src/libcalamaresui/modulesystem/Module.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/libcalamaresui/modulesystem/Module.cpp b/src/libcalamaresui/modulesystem/Module.cpp index 8d92c37ad..a1349c280 100644 --- a/src/libcalamaresui/modulesystem/Module.cpp +++ b/src/libcalamaresui/modulesystem/Module.cpp @@ -145,8 +145,15 @@ moduleConfigurationCandidates( bool assumeBuildDir, const QString& moduleName, c paths << CalamaresUtils::appDataDir().absoluteFilePath( QString( "modules/%1" ).arg( configFileName ) ); else { + // If an absolute path is given, in debug mode, look for it + // first. The case contains('/'), below, will add the absolute + // path a second time, though. + if ( assumeBuildDir && configFileName.startsWith( '/' ) ) + paths << configFileName; if ( assumeBuildDir ) paths << QDir().absoluteFilePath(QString( "src/modules/%1/%2" ).arg( moduleName ).arg( configFileName ) ); + if ( assumeBuildDir && configFileName.contains( '/' ) ) + paths << QDir().absoluteFilePath( configFileName ); paths << QString( "/etc/calamares/modules/%1" ).arg( configFileName ); paths << CalamaresUtils::appDataDir().absoluteFilePath( QString( "modules/%1" ).arg( configFileName ) ); @@ -168,6 +175,7 @@ Module::loadConfigurationFile( const QString& configFileName ) //throws YAML::Ex YAML::Node doc = YAML::Load( ba.constData() ); if ( doc.IsNull() ) { + cDebug() << "Found empty module configuration" << path; // Special case: empty config files are valid, // but aren't a map. return; @@ -178,14 +186,13 @@ Module::loadConfigurationFile( const QString& configFileName ) //throws YAML::Ex return; } + cDebug() << "Loaded module configuration" << path; m_configurationMap = CalamaresUtils::yamlMapToVariant( doc ).toMap(); m_emergency = m_maybe_emergency && m_configurationMap.contains( EMERGENCY ) && m_configurationMap[ EMERGENCY ].toBool(); return; } - else - continue; } } From bf092de76fdc913e718620c2b7acf7d946848e23 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 20 Sep 2018 07:48:06 -0400 Subject: [PATCH 10/70] [calamares] Explain config-file failures better --- src/modules/test_conf.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/test_conf.cpp b/src/modules/test_conf.cpp index b5362d25a..ca6b72cc7 100644 --- a/src/modules/test_conf.cpp +++ b/src/modules/test_conf.cpp @@ -87,7 +87,7 @@ int main(int argc, char** argv) if ( !doc.IsMap() ) { cerr << "WARNING:" << filename << '\n'; - cerr << "WARNING: not-a-YAML-map\n"; + cerr << "WARNING: not-a-YAML-map (type=" << doc.Type() << ")\n"; return 1; } From 3b8fa187e1679a0b7134e6e2df969d17f3c7cfff Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 20 Sep 2018 07:49:49 -0400 Subject: [PATCH 11/70] [fsresizer] Fix syntax error in YAML --- src/modules/fsresizer/fsresizer.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/fsresizer/fsresizer.conf b/src/modules/fsresizer/fsresizer.conf index 1539a7751..5a5700a79 100644 --- a/src/modules/fsresizer/fsresizer.conf +++ b/src/modules/fsresizer/fsresizer.conf @@ -7,7 +7,7 @@ # written to an 8GiB SD card; the FS should expand to take # advantage of the unused 2GiB. The FS should expand much # more if the same image is written to a 16GiB card. --- +--- # Which FS needs to be grown? Choose one way to identify it: # - *fs* names a mount point which should already be mounted From a32149bd927a2c138e0f46d7df6d5ba495528ce7 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 20 Sep 2018 08:02:43 -0400 Subject: [PATCH 12/70] CI: run tests after build as well --- ci/travis-continuous.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ci/travis-continuous.sh b/ci/travis-continuous.sh index eccb6743e..e0bbf1351 100755 --- a/ci/travis-continuous.sh +++ b/ci/travis-continuous.sh @@ -51,4 +51,6 @@ df -h echo "# Install results" install_debugging "$DESTDIR" -$result # Result of make install, above +$result || { echo "! Install failed" ; exit 1 ; } # Result of make install, above + +make test From b0db4780bfb09716b31cf293ac3fe7af1de5c810 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 20 Sep 2018 15:13:43 +0200 Subject: [PATCH 13/70] CI: be more chatty while running tests --- ci/travis-continuous.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ci/travis-continuous.sh b/ci/travis-continuous.sh index e0bbf1351..647d460b8 100755 --- a/ci/travis-continuous.sh +++ b/ci/travis-continuous.sh @@ -53,4 +53,8 @@ install_debugging "$DESTDIR" $result || { echo "! Install failed" ; exit 1 ; } # Result of make install, above -make test +echo "# Running tests" +find . -name test_conf +find . -name loadmodule +ctest -V + From 499dd2ce838a330b8f0f01aad7d24a24547622e0 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 20 Sep 2018 15:38:26 +0200 Subject: [PATCH 14/70] [fsresizer] Document configuration - Add some notes on configuration of fsresizer - Convenience methods for checking validity. --- src/modules/fsresizer/ResizeFSJob.cpp | 5 +++++ src/modules/fsresizer/ResizeFSJob.h | 17 +++++++++++++++++ src/modules/fsresizer/fsresizer.conf | 5 ++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/modules/fsresizer/ResizeFSJob.cpp b/src/modules/fsresizer/ResizeFSJob.cpp index e10894c30..925301e42 100644 --- a/src/modules/fsresizer/ResizeFSJob.cpp +++ b/src/modules/fsresizer/ResizeFSJob.cpp @@ -85,6 +85,11 @@ ResizeFSJob::prettyName() const Calamares::JobResult ResizeFSJob::exec() { + if ( !isValid() ) + return Calamares::JobResult::error( + tr( "Invalid configuration" ), + tr( "The file-system resize job has an invalid configuration " + "and will not run." ) ); return Calamares::JobResult::ok(); } diff --git a/src/modules/fsresizer/ResizeFSJob.h b/src/modules/fsresizer/ResizeFSJob.h index 415d04c81..6308f12ed 100644 --- a/src/modules/fsresizer/ResizeFSJob.h +++ b/src/modules/fsresizer/ResizeFSJob.h @@ -33,6 +33,12 @@ class PLUGINDLLEXPORT ResizeFSJob : public Calamares::CppJob Q_OBJECT public: + /** @brief Size expressions + * + * Sizes can be specified in MiB or percent (of the device they + * are on). This class handles parsing of such strings from the + * config file. + */ class RelativeSize { public: @@ -49,6 +55,11 @@ public: int value() const { return m_value; } Unit unit() const { return m_unit; } + constexpr bool isValid() const + { + return ( unit() != None ) && ( value() > 0 ); + } + private: int m_value; Unit m_unit; @@ -63,6 +74,12 @@ public: void setConfigurationMap( const QVariantMap& configurationMap ) override; + constexpr bool isValid() const + { + return ( !m_fsname.isEmpty() || !m_devicename.isEmpty() ) && + m_size.isValid(); + } + private: RelativeSize m_size; RelativeSize m_atleast; diff --git a/src/modules/fsresizer/fsresizer.conf b/src/modules/fsresizer/fsresizer.conf index 5a5700a79..f02983e45 100644 --- a/src/modules/fsresizer/fsresizer.conf +++ b/src/modules/fsresizer/fsresizer.conf @@ -21,10 +21,13 @@ fs: / # in percent, so set it to 100. Perhaps a fixed size is # needed (that would be weird though, since you don't know # how big the card is), use MiB as suffix in that case. +# If missing, then it's assumed to be 0, and no resizing +# will happen. size: 100% # Resizing might not be worth it, though. Set the minimum # that it must grow; if it cannot grow that much, the # resizing is skipped. Can be in percentage or absolute -# size, as above. +# size, as above. If missing, then it's assumed to be 0, +# which means resizing is always worthwhile. atleast: 1000MiB From a40864f70974d4bd8f22ca1118d98621bfb61b32 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 20 Sep 2018 15:40:26 +0200 Subject: [PATCH 15/70] CI: mess around with running tests --- ci/travis-continuous.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ci/travis-continuous.sh b/ci/travis-continuous.sh index 647d460b8..b8a1c8548 100755 --- a/ci/travis-continuous.sh +++ b/ci/travis-continuous.sh @@ -56,5 +56,10 @@ $result || { echo "! Install failed" ; exit 1 ; } # Result of make install, abov echo "# Running tests" find . -name test_conf find . -name loadmodule +./test_conf --help +$BUILDDIR/test_conf --help +/build/test_conf --help + +echo "# Running ctest" ctest -V From 45195b9f7ed17b508d662bfa2887a81fd4c1136e Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 20 Sep 2018 10:34:46 -0400 Subject: [PATCH 16/70] [fsresizer] Remove over-enthusiastic constexpr --- src/modules/fsresizer/ResizeFSJob.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/modules/fsresizer/ResizeFSJob.h b/src/modules/fsresizer/ResizeFSJob.h index 6308f12ed..85ed98cdc 100644 --- a/src/modules/fsresizer/ResizeFSJob.h +++ b/src/modules/fsresizer/ResizeFSJob.h @@ -34,7 +34,7 @@ class PLUGINDLLEXPORT ResizeFSJob : public Calamares::CppJob public: /** @brief Size expressions - * + * * Sizes can be specified in MiB or percent (of the device they * are on). This class handles parsing of such strings from the * config file. @@ -55,11 +55,11 @@ public: int value() const { return m_value; } Unit unit() const { return m_unit; } - constexpr bool isValid() const + bool isValid() const { return ( unit() != None ) && ( value() > 0 ); } - + private: int m_value; Unit m_unit; @@ -74,12 +74,12 @@ public: void setConfigurationMap( const QVariantMap& configurationMap ) override; - constexpr bool isValid() const + bool isValid() const { return ( !m_fsname.isEmpty() || !m_devicename.isEmpty() ) && m_size.isValid(); } - + private: RelativeSize m_size; RelativeSize m_atleast; From bc732ccbc70420cc7d023b90defc53ac81dafdab Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 20 Sep 2018 10:53:46 -0400 Subject: [PATCH 17/70] CI: mess around with test-application permissions --- ci/travis-continuous.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ci/travis-continuous.sh b/ci/travis-continuous.sh index b8a1c8548..04e8c2ca2 100755 --- a/ci/travis-continuous.sh +++ b/ci/travis-continuous.sh @@ -54,11 +54,10 @@ install_debugging "$DESTDIR" $result || { echo "! Install failed" ; exit 1 ; } # Result of make install, above echo "# Running tests" -find . -name test_conf -find . -name loadmodule -./test_conf --help +ls -la $BUILDDIR/test_conf +chmod 755 $BUILDDIR/test_conf $BUILDDIR/test_conf --help -/build/test_conf --help +ls -la $BUILDDIR/test_conf echo "# Running ctest" ctest -V From 579f1dfee7fa6e8cce272be24b85b95acf253caa Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 20 Sep 2018 11:07:56 -0400 Subject: [PATCH 18/70] CI: don't try to run tests. - permissions on the tmpfs where everything is built, prevents the test-applications from running. --- ci/travis-continuous.sh | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/ci/travis-continuous.sh b/ci/travis-continuous.sh index 04e8c2ca2..1b3841e54 100755 --- a/ci/travis-continuous.sh +++ b/ci/travis-continuous.sh @@ -52,13 +52,3 @@ echo "# Install results" install_debugging "$DESTDIR" $result || { echo "! Install failed" ; exit 1 ; } # Result of make install, above - -echo "# Running tests" -ls -la $BUILDDIR/test_conf -chmod 755 $BUILDDIR/test_conf -$BUILDDIR/test_conf --help -ls -la $BUILDDIR/test_conf - -echo "# Running ctest" -ctest -V - From 428929b64f1059ed44fba3fb470ddbb8dc9e03f0 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sat, 22 Sep 2018 11:11:19 -0400 Subject: [PATCH 19/70] [fsresizer] Tiny step towards getting data from KPMcore --- src/modules/fsresizer/ResizeFSJob.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/modules/fsresizer/ResizeFSJob.cpp b/src/modules/fsresizer/ResizeFSJob.cpp index 925301e42..490010e0c 100644 --- a/src/modules/fsresizer/ResizeFSJob.cpp +++ b/src/modules/fsresizer/ResizeFSJob.cpp @@ -22,6 +22,9 @@ #include #include +#include +#include + #include "CalamaresVersion.h" #include "JobQueue.h" #include "GlobalStorage.h" @@ -36,8 +39,8 @@ ResizeFSJob::RelativeSize::RelativeSize() template -void matchUnitSuffix( - const QString& s, +void matchUnitSuffix( + const QString& s, const char (&suffix)[N], ResizeFSJob::RelativeSize::Unit matchedUnit, int& value, @@ -50,15 +53,15 @@ void matchUnitSuffix( unit = matchedUnit; } } - - + + ResizeFSJob::RelativeSize::RelativeSize( const QString& s) : m_value( 0 ) , m_unit( None ) { matchUnitSuffix( s, "%", Percent, m_value, m_unit ); matchUnitSuffix( s, "MiB", Absolute, m_value, m_unit ); - + if ( !m_value ) m_unit = None; } @@ -85,11 +88,18 @@ ResizeFSJob::prettyName() const Calamares::JobResult ResizeFSJob::exec() { + auto backend_p = CoreBackendManager::self()->backend(); + if ( backend_p ) + cDebug() << "KPMCore backend @" << (void *)backend_p << backend_p->id() << backend_p->version(); + else + cDebug() << "No KPMCore backend"; + if ( !isValid() ) return Calamares::JobResult::error( tr( "Invalid configuration" ), tr( "The file-system resize job has an invalid configuration " "and will not run." ) ); + return Calamares::JobResult::ok(); } From 35ca813064ce9ad76045ee01e0e0cc632ea0f108 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 25 Sep 2018 06:34:03 -0400 Subject: [PATCH 20/70] [partition] Use "" for including from current directory --- src/modules/partition/core/PartitionIterator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/partition/core/PartitionIterator.cpp b/src/modules/partition/core/PartitionIterator.cpp index 5ed48fd91..8301835c6 100644 --- a/src/modules/partition/core/PartitionIterator.cpp +++ b/src/modules/partition/core/PartitionIterator.cpp @@ -18,7 +18,7 @@ * along with Calamares. If not, see . */ -#include +#include "PartitionIterator.h" // KPMcore #include From 06a00a15c68c9711f72ccbb2a357b61b0c1b2725 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 25 Sep 2018 06:39:14 -0400 Subject: [PATCH 21/70] [fsresizer] Scan for devices, list partitions - The is just debugging output, but it's the start of what needs to happen to find the FS that needs resizing. --- src/modules/fsresizer/CMakeLists.txt | 5 +++- src/modules/fsresizer/ResizeFSJob.cpp | 39 ++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/modules/fsresizer/CMakeLists.txt b/src/modules/fsresizer/CMakeLists.txt index ae87de160..9f0234406 100644 --- a/src/modules/fsresizer/CMakeLists.txt +++ b/src/modules/fsresizer/CMakeLists.txt @@ -10,17 +10,20 @@ if ( KPMcore_FOUND ) include_directories( ${KPMCORE_INCLUDE_DIR} ) include_directories( ${PROJECT_BINARY_DIR}/src/libcalamares ) + # The PartitionIterator is a small class, and it's easiest -- but also a + # gross hack -- to just compile it again from the partition module tree. calamares_add_plugin( fsresizer TYPE job EXPORT_MACRO PLUGINDLLEXPORT_PRO SOURCES ResizeFSJob.cpp + ${PROJECT_SOURCE_DIR}/src/modules/partition/core/PartitionIterator.cpp LINK_PRIVATE_LIBRARIES kpmcore calamares SHARED_LIB ) - + if( ECM_FOUND ) find_package( Qt5 COMPONENTS Test REQUIRED ) include( ECMAddTests ) diff --git a/src/modules/fsresizer/ResizeFSJob.cpp b/src/modules/fsresizer/ResizeFSJob.cpp index 490010e0c..e3820e535 100644 --- a/src/modules/fsresizer/ResizeFSJob.cpp +++ b/src/modules/fsresizer/ResizeFSJob.cpp @@ -24,6 +24,8 @@ #include #include +#include +#include #include "CalamaresVersion.h" #include "JobQueue.h" @@ -31,6 +33,8 @@ #include "utils/Logger.h" +#include "modules/partition/core/PartitionIterator.h" + ResizeFSJob::RelativeSize::RelativeSize() : m_value( 0 ) , m_unit( None ) @@ -92,7 +96,40 @@ ResizeFSJob::exec() if ( backend_p ) cDebug() << "KPMCore backend @" << (void *)backend_p << backend_p->id() << backend_p->version(); else - cDebug() << "No KPMCore backend"; + { + cDebug() << "No KPMCore backend loaded yet"; + QByteArray backendName = qgetenv( "KPMCORE_BACKEND" ); + if ( !CoreBackendManager::self()->load( backendName.isEmpty() ? CoreBackendManager::defaultBackendName() : backendName ) ) + { + cWarning() << "Could not load KPMCore backend."; + return Calamares::JobResult::error( + tr( "KPMCore not Available" ), + tr( "Calamares cannot start KPMCore for the file-system resize job." ) ); + } + + backend_p = CoreBackendManager::self()->backend(); + } + if ( !backend_p ) + { + cWarning() << "Could not load KPMCore backend (2)."; + return Calamares::JobResult::error( + tr( "KPMCore not Available" ), + tr( "Calamares cannot start KPMCore for the file-system resize job." ) ); + } + + using DeviceList = QList< Device* >; + DeviceList devices = backend_p->scanDevices( false ); + cDebug() << "ResizeFSJob found" << devices.count() << "devices."; + for ( DeviceList::iterator it = devices.begin(); it != devices.end(); ) + { + if ( ! (*it) ) + continue; + cDebug() << "ResizeFSJob found" << ( *it )->deviceNode(); + for ( auto pit = PartitionIterator::begin( *it); pit != PartitionIterator::end( *it); ++pit ) + { + cDebug() << ".." << ( *pit )->mountPoint(); + } + } if ( !isValid() ) return Calamares::JobResult::error( From 3ab891793a87fddf38a96286b4913c73a22c9da6 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 26 Sep 2018 16:54:39 +0200 Subject: [PATCH 22/70] [keyboard] Add Austrian keyboard layout - Map xkb 'at' to 'de' on the text console - Thanks Philip Mueller, Kevin Kofler FIXES #1035 --- src/modules/keyboard/kbd-model-map | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/modules/keyboard/kbd-model-map b/src/modules/keyboard/kbd-model-map index 68c8baf72..49ec4ad75 100644 --- a/src/modules/keyboard/kbd-model-map +++ b/src/modules/keyboard/kbd-model-map @@ -6,6 +6,9 @@ # This is the version from 534644b7be7b240eb0fbbe06e20cbecbe8206767, # committed 2015-01-22 01:07:24 . # +# Updates: +# - 2018-09-26 Added "Austrian" keyboard (de at). Issue #1035 +# # Generated from system-config-keyboard's model list # consolelayout xlayout xmodel xvariant xoptions sg ch pc105 de_nodeadkeys terminate:ctrl_alt_bksp @@ -15,6 +18,7 @@ trq tr pc105 - terminate:ctrl_alt_bksp uk gb pc105 - terminate:ctrl_alt_bksp is-latin1 is pc105 - terminate:ctrl_alt_bksp de de pc105 - terminate:ctrl_alt_bksp +de at pc105 - terminate:ctrl_alt_bksp la-latin1 latam pc105 - terminate:ctrl_alt_bksp us us pc105+inet - terminate:ctrl_alt_bksp ko kr pc105 - terminate:ctrl_alt_bksp From aae4b38e6979c84ac888d7cde3f68533199f47e0 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 27 Sep 2018 03:44:39 -0400 Subject: [PATCH 23/70] [fsresizer] Fix endless loop - Improve variable names - Missing iterator++ --- src/modules/fsresizer/ResizeFSJob.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/modules/fsresizer/ResizeFSJob.cpp b/src/modules/fsresizer/ResizeFSJob.cpp index e3820e535..06429699b 100644 --- a/src/modules/fsresizer/ResizeFSJob.cpp +++ b/src/modules/fsresizer/ResizeFSJob.cpp @@ -120,14 +120,14 @@ ResizeFSJob::exec() using DeviceList = QList< Device* >; DeviceList devices = backend_p->scanDevices( false ); cDebug() << "ResizeFSJob found" << devices.count() << "devices."; - for ( DeviceList::iterator it = devices.begin(); it != devices.end(); ) + for ( DeviceList::iterator dev_it = devices.begin(); dev_it != devices.end(); ++dev_it ) { - if ( ! (*it) ) + if ( ! (*dev_it) ) continue; - cDebug() << "ResizeFSJob found" << ( *it )->deviceNode(); - for ( auto pit = PartitionIterator::begin( *it); pit != PartitionIterator::end( *it); ++pit ) + cDebug() << "ResizeFSJob found" << ( *dev_it )->deviceNode(); + for ( auto part_it = PartitionIterator::begin( *dev_it); part_it != PartitionIterator::end( *dev_it ); ++part_it ) { - cDebug() << ".." << ( *pit )->mountPoint(); + cDebug() << ".." << ( *part_it )->mountPoint(); } } From 1c2714d832ac832fff008f4615e92c66f9db595a Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 27 Sep 2018 03:56:57 -0400 Subject: [PATCH 24/70] [fsresizer] Match configuration to system - Bail out earlier before doing any work if the configuration is invalid. - If it's valid, look for a matching device. --- src/modules/fsresizer/ResizeFSJob.cpp | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/modules/fsresizer/ResizeFSJob.cpp b/src/modules/fsresizer/ResizeFSJob.cpp index 06429699b..cf2ea47f6 100644 --- a/src/modules/fsresizer/ResizeFSJob.cpp +++ b/src/modules/fsresizer/ResizeFSJob.cpp @@ -92,6 +92,13 @@ ResizeFSJob::prettyName() const Calamares::JobResult ResizeFSJob::exec() { + if ( !isValid() ) + return Calamares::JobResult::error( + tr( "Invalid configuration" ), + tr( "The file-system resize job has an invalid configuration " + "and will not run." ) ); + + // Get KPMCore auto backend_p = CoreBackendManager::self()->backend(); if ( backend_p ) cDebug() << "KPMCore backend @" << (void *)backend_p << backend_p->id() << backend_p->version(); @@ -117,6 +124,9 @@ ResizeFSJob::exec() tr( "Calamares cannot start KPMCore for the file-system resize job." ) ); } + Device* resize_this_device = nullptr; + Partition* resize_this_partition = nullptr; + using DeviceList = QList< Device* >; DeviceList devices = backend_p->scanDevices( false ); cDebug() << "ResizeFSJob found" << devices.count() << "devices."; @@ -127,16 +137,18 @@ ResizeFSJob::exec() cDebug() << "ResizeFSJob found" << ( *dev_it )->deviceNode(); for ( auto part_it = PartitionIterator::begin( *dev_it); part_it != PartitionIterator::end( *dev_it ); ++part_it ) { - cDebug() << ".." << ( *part_it )->mountPoint(); + cDebug() << ".." << ( *part_it )->mountPoint() << "on" << ( *part_it )->deviceNode(); + if ( ( !m_fsname.isEmpty() && ( *part_it )->mountPoint() == m_fsname ) || + ( !m_devicename.isEmpty() && ( *part_it )->deviceNode() == m_devicename ) ) + { + resize_this_device = ( *dev_it ); + resize_this_partition = ( *part_it ); + cDebug() << ".. matched configuration dev=" << m_devicename << "fs=" << m_fsname; + break; + } } } - if ( !isValid() ) - return Calamares::JobResult::error( - tr( "Invalid configuration" ), - tr( "The file-system resize job has an invalid configuration " - "and will not run." ) ); - return Calamares::JobResult::ok(); } From 9e1c95ad056f4794b7e73bd4b9e09d7dad79bd38 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 27 Sep 2018 04:10:25 -0400 Subject: [PATCH 25/70] [fsresizer] Refactor finding device - Find device in separate function - If device isn't found, bail out --- src/modules/fsresizer/ResizeFSJob.cpp | 56 +++++++++++++++------------ src/modules/fsresizer/ResizeFSJob.h | 9 +++++ 2 files changed, 41 insertions(+), 24 deletions(-) diff --git a/src/modules/fsresizer/ResizeFSJob.cpp b/src/modules/fsresizer/ResizeFSJob.cpp index cf2ea47f6..68fd166e7 100644 --- a/src/modules/fsresizer/ResizeFSJob.cpp +++ b/src/modules/fsresizer/ResizeFSJob.cpp @@ -88,6 +88,32 @@ ResizeFSJob::prettyName() const return tr( "Resize Filesystem Job" ); } +ResizeFSJob::PartitionMatch +ResizeFSJob::findPartition( CoreBackend* backend ) +{ + using DeviceList = QList< Device* >; + DeviceList devices = backend->scanDevices( false ); + cDebug() << "ResizeFSJob found" << devices.count() << "devices."; + for ( DeviceList::iterator dev_it = devices.begin(); dev_it != devices.end(); ++dev_it ) + { + if ( ! (*dev_it) ) + continue; + cDebug() << "ResizeFSJob found" << ( *dev_it )->deviceNode(); + for ( auto part_it = PartitionIterator::begin( *dev_it); part_it != PartitionIterator::end( *dev_it ); ++part_it ) + { + cDebug() << ".." << ( *part_it )->mountPoint() << "on" << ( *part_it )->deviceNode(); + if ( ( !m_fsname.isEmpty() && ( *part_it )->mountPoint() == m_fsname ) || + ( !m_devicename.isEmpty() && ( *part_it )->deviceNode() == m_devicename ) ) + { + cDebug() << ".. matched configuration dev=" << m_devicename << "fs=" << m_fsname; + return PartitionMatch( *dev_it, *part_it ); + } + } + } + + cDebug() << "No match for configuration dev=" << m_devicename << "fs=" << m_fsname; + return PartitionMatch( nullptr, nullptr ); +} Calamares::JobResult ResizeFSJob::exec() @@ -124,30 +150,12 @@ ResizeFSJob::exec() tr( "Calamares cannot start KPMCore for the file-system resize job." ) ); } - Device* resize_this_device = nullptr; - Partition* resize_this_partition = nullptr; - - using DeviceList = QList< Device* >; - DeviceList devices = backend_p->scanDevices( false ); - cDebug() << "ResizeFSJob found" << devices.count() << "devices."; - for ( DeviceList::iterator dev_it = devices.begin(); dev_it != devices.end(); ++dev_it ) - { - if ( ! (*dev_it) ) - continue; - cDebug() << "ResizeFSJob found" << ( *dev_it )->deviceNode(); - for ( auto part_it = PartitionIterator::begin( *dev_it); part_it != PartitionIterator::end( *dev_it ); ++part_it ) - { - cDebug() << ".." << ( *part_it )->mountPoint() << "on" << ( *part_it )->deviceNode(); - if ( ( !m_fsname.isEmpty() && ( *part_it )->mountPoint() == m_fsname ) || - ( !m_devicename.isEmpty() && ( *part_it )->deviceNode() == m_devicename ) ) - { - resize_this_device = ( *dev_it ); - resize_this_partition = ( *part_it ); - cDebug() << ".. matched configuration dev=" << m_devicename << "fs=" << m_fsname; - break; - } - } - } + PartitionMatch m = findPartition( backend_p ); + if ( !m.first || !m.second ) + return Calamares::JobResult::error( + tr( "Resize Failed" ), + m_fsname.isEmpty() ? tr( "The filesystem %1 could not be found in this system, and can not be resized." ).arg(m_fsname) + : tr( "The device %1 could not be found in this system, and can not be resized." ).arg(m_devicename) ); return Calamares::JobResult::ok(); } diff --git a/src/modules/fsresizer/ResizeFSJob.h b/src/modules/fsresizer/ResizeFSJob.h index 85ed98cdc..72b28e690 100644 --- a/src/modules/fsresizer/ResizeFSJob.h +++ b/src/modules/fsresizer/ResizeFSJob.h @@ -28,6 +28,10 @@ #include +class CoreBackend; // From KPMCore +class Device; // From KPMCore +class Partition; + class PLUGINDLLEXPORT ResizeFSJob : public Calamares::CppJob { Q_OBJECT @@ -74,6 +78,7 @@ public: void setConfigurationMap( const QVariantMap& configurationMap ) override; + /** @brief Is the configuration of this job valid? */ bool isValid() const { return ( !m_fsname.isEmpty() || !m_devicename.isEmpty() ) && @@ -85,6 +90,10 @@ private: RelativeSize m_atleast; QString m_fsname; // Either this, or devicename, is set, not both QString m_devicename; + + using PartitionMatch = QPair; + /** @brief Find the configured FS using KPMCore @p backend */ + PartitionMatch findPartition( CoreBackend* backend ); }; CALAMARES_PLUGIN_FACTORY_DECLARATION( ResizeFSJobFactory ) From 9124281bcbe6addaf7da5546d1639a09f61a4fd5 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 27 Sep 2018 05:28:20 -0400 Subject: [PATCH 26/70] [fsresizer] Calculate resize parameters - apply() a relativesize to a device to find out how much it means in sectors - find the space into which the configured FS can grow. --- src/modules/fsresizer/ResizeFSJob.cpp | 82 ++++++++++++++++++++++++++- src/modules/fsresizer/ResizeFSJob.h | 12 ++++ 2 files changed, 93 insertions(+), 1 deletion(-) diff --git a/src/modules/fsresizer/ResizeFSJob.cpp b/src/modules/fsresizer/ResizeFSJob.cpp index 68fd166e7..e3744661d 100644 --- a/src/modules/fsresizer/ResizeFSJob.cpp +++ b/src/modules/fsresizer/ResizeFSJob.cpp @@ -26,12 +26,14 @@ #include #include #include +#include #include "CalamaresVersion.h" #include "JobQueue.h" #include "GlobalStorage.h" #include "utils/Logger.h" +#include "utils/Units.h" #include "modules/partition/core/PartitionIterator.h" @@ -70,6 +72,26 @@ ResizeFSJob::RelativeSize::RelativeSize( const QString& s) m_unit = None; } +qint64 +ResizeFSJob::RelativeSize::apply( Device* d ) +{ + if ( !isValid() ) + return -1; + + switch( m_unit ) + { + case None: + return -1; + case Absolute: + return CalamaresUtils::MiBtoBytes( value() ) / d->logicalSize(); + case Percent: + return d->logicalSize() * value() / 100; + } + + // notreached + return -1; +} + ResizeFSJob::ResizeFSJob( QObject* parent ) : Calamares::CppJob( parent ) @@ -99,7 +121,7 @@ ResizeFSJob::findPartition( CoreBackend* backend ) if ( ! (*dev_it) ) continue; cDebug() << "ResizeFSJob found" << ( *dev_it )->deviceNode(); - for ( auto part_it = PartitionIterator::begin( *dev_it); part_it != PartitionIterator::end( *dev_it ); ++part_it ) + for ( auto part_it = PartitionIterator::begin( *dev_it ); part_it != PartitionIterator::end( *dev_it ); ++part_it ) { cDebug() << ".." << ( *part_it )->mountPoint() << "on" << ( *part_it )->deviceNode(); if ( ( !m_fsname.isEmpty() && ( *part_it )->mountPoint() == m_fsname ) || @@ -115,6 +137,51 @@ ResizeFSJob::findPartition( CoreBackend* backend ) return PartitionMatch( nullptr, nullptr ); } +qint64 +ResizeFSJob::findGrownEnd(ResizeFSJob::PartitionMatch m) +{ + if ( !m.first || !m.second ) + return -1; + if ( !ResizeOperation::canGrow( m.second ) ) + return -1; + + qint64 last_available = m.first->totalLogical(); + cDebug() << "Containing device size" << last_available; + qint64 last_currently = m.second->lastSector(); + cDebug() << "Growing partition" << m.second->firstSector() << '-' << last_currently; + + for ( auto part_it = PartitionIterator::begin( m.first ); part_it != PartitionIterator::end( m.first ); ++part_it ) + { + qint64 next_start = ( *part_it )->firstSector(); + cDebug() << ".. comparing" << next_start << '-' << ( *part_it )->lastSector(); + if ( (next_start > last_currently) && (next_start < last_available) ) + { + cDebug() << " .. shrunk last available to" << next_start; + last_available = next_start - 1; // Before that one starts + } + } + + if ( !( last_available > last_currently ) ) + { + cDebug() << "Partition can not grow larger."; + return -1; + } + + qint64 expand = last_available - last_currently; // number of sectors + if ( m_atleast.isValid() ) + { + qint64 required = m_atleast.apply( m.first ); + if ( expand < required ) + { + cDebug() << ".. need to expand by" << required << "but only" << expand << "is available."; + return -1; + } + } + + return last_available; +} + + Calamares::JobResult ResizeFSJob::exec() { @@ -157,6 +224,19 @@ ResizeFSJob::exec() m_fsname.isEmpty() ? tr( "The filesystem %1 could not be found in this system, and can not be resized." ).arg(m_fsname) : tr( "The device %1 could not be found in this system, and can not be resized." ).arg(m_devicename) ); + if ( !ResizeOperation::canGrow( m.second ) ) + { + cDebug() << "canGrow() returned false."; + return Calamares::JobResult::error( + tr( "Resize Failed" ), + m_fsname.isEmpty() ? tr( "The filesystem %1 can not be resized." ).arg(m_fsname) + : tr( "The device %1 can not be resized." ).arg(m_devicename) ); + } + + cDebug() << "Resize from" << m.second->firstSector() + << '+' << m.second->length() << '=' << m.second->lastSector() + << "to" << findGrownEnd( m ); + return Calamares::JobResult::ok(); } diff --git a/src/modules/fsresizer/ResizeFSJob.h b/src/modules/fsresizer/ResizeFSJob.h index 72b28e690..36527ab56 100644 --- a/src/modules/fsresizer/ResizeFSJob.h +++ b/src/modules/fsresizer/ResizeFSJob.h @@ -64,6 +64,15 @@ public: return ( unit() != None ) && ( value() > 0 ); } + /** @brief Apply this size to the given device @p d + * + * For invalid sizes, returns -1. + * For absolute sizes, returns the number of sectors needed. + * For percent sizes, returns the number of sectors matching + * that percentage of the device size. + */ + qint64 apply( Device* d ); + private: int m_value; Unit m_unit; @@ -94,6 +103,9 @@ private: using PartitionMatch = QPair; /** @brief Find the configured FS using KPMCore @p backend */ PartitionMatch findPartition( CoreBackend* backend ); + + /** @brief Return a new end-sector for the given dev-part pair. */ + qint64 findGrownEnd( PartitionMatch ); }; CALAMARES_PLUGIN_FACTORY_DECLARATION( ResizeFSJobFactory ) From 427c142182de90a9b47b92c6e092e872e98ffd26 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 27 Sep 2018 12:51:32 +0200 Subject: [PATCH 27/70] Changelog: credits and mark fixed --- CHANGES | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES b/CHANGES index 8c56b4023..e6a16fac8 100644 --- a/CHANGES +++ b/CHANGES @@ -8,6 +8,7 @@ website will have to do for older versions. This release contains contributions from (alphabetically by first name): - Alf Gaida - Caio Carvalho + - Kevin Kofler - Philip Mueller ## Core ## @@ -16,6 +17,8 @@ This release contains contributions from (alphabetically by first name): * The *partition* module supports RAID devices, but only when Calamares is compiled with the newest KPMCore release. + * The *keyboard* module now handles the (bogus) Austrian keymap for + the system console properly. # 3.2.2 (2018-09-04) # From e7c62c114f9e88aeca32fc719fa7478421144075 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 27 Sep 2018 13:35:33 +0200 Subject: [PATCH 28/70] [keyboard] Improve debugging output --- src/modules/keyboard/SetKeyboardLayoutJob.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/modules/keyboard/SetKeyboardLayoutJob.cpp b/src/modules/keyboard/SetKeyboardLayoutJob.cpp index 02d807045..75c52bb51 100644 --- a/src/modules/keyboard/SetKeyboardLayoutJob.cpp +++ b/src/modules/keyboard/SetKeyboardLayoutJob.cpp @@ -65,6 +65,8 @@ SetKeyboardLayoutJob::prettyName() const QString SetKeyboardLayoutJob::findConvertedKeymap( const QString& convertedKeymapPath ) const { + cDebug() << "Looking for converted keymap in" << convertedKeymapPath; + // No search path supplied, assume the distribution does not provide // converted keymaps if ( convertedKeymapPath.isEmpty() ) @@ -76,8 +78,7 @@ SetKeyboardLayoutJob::findConvertedKeymap( const QString& convertedKeymapPath ) if ( convertedKeymapDir.exists( name + ".map" ) || convertedKeymapDir.exists( name + ".map.gz" ) ) { - cDebug() << "Found converted keymap" << name; - + cDebug() << ".. Found converted keymap" << name; return name; } @@ -88,6 +89,8 @@ SetKeyboardLayoutJob::findConvertedKeymap( const QString& convertedKeymapPath ) QString SetKeyboardLayoutJob::findLegacyKeymap() const { + cDebug() << "Looking for legacy keymap in QRC"; + int bestMatching = 0; QString name; @@ -137,7 +140,7 @@ SetKeyboardLayoutJob::findLegacyKeymap() const // The best matching entry so far, then let's save that if ( matching >= qMax( bestMatching, 1 ) ) { - cDebug() << "Found legacy keymap" << mapping[0] + cDebug() << ".. Found legacy keymap" << mapping[0] << "with score" << matching; if ( matching > bestMatching ) From a749f041f016b9386a32cf72b183d48fb7b15c2b Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 27 Sep 2018 20:45:13 +0200 Subject: [PATCH 29/70] [calamares] More verbose failure in test-loader --- src/calamares/testmain.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/calamares/testmain.cpp b/src/calamares/testmain.cpp index c22342f9a..e1d934b54 100644 --- a/src/calamares/testmain.cpp +++ b/src/calamares/testmain.cpp @@ -184,7 +184,12 @@ main( int argc, char* argv[] ) cDebug() << count << p->prettyName(); Calamares::JobResult r = p->exec(); if ( !r ) - cDebug() << count << ".. failed" << r; + { + using TR = Logger::DebugRow; + cDebug() << count << ".. failed" + << TR( "summary", r.message() ) + << TR( "details", r.details() ); + } ++count; } From 2556891e390ea27e932844f8d855fec549b5c480 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 27 Sep 2018 20:49:28 +0200 Subject: [PATCH 30/70] [fsresizer] Fix backwards logic in error message --- src/modules/fsresizer/ResizeFSJob.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/fsresizer/ResizeFSJob.cpp b/src/modules/fsresizer/ResizeFSJob.cpp index e3744661d..d501ba4f1 100644 --- a/src/modules/fsresizer/ResizeFSJob.cpp +++ b/src/modules/fsresizer/ResizeFSJob.cpp @@ -221,7 +221,7 @@ ResizeFSJob::exec() if ( !m.first || !m.second ) return Calamares::JobResult::error( tr( "Resize Failed" ), - m_fsname.isEmpty() ? tr( "The filesystem %1 could not be found in this system, and can not be resized." ).arg(m_fsname) + !m_fsname.isEmpty() ? tr( "The filesystem %1 could not be found in this system, and can not be resized." ).arg(m_fsname) : tr( "The device %1 could not be found in this system, and can not be resized." ).arg(m_devicename) ); if ( !ResizeOperation::canGrow( m.second ) ) @@ -229,7 +229,7 @@ ResizeFSJob::exec() cDebug() << "canGrow() returned false."; return Calamares::JobResult::error( tr( "Resize Failed" ), - m_fsname.isEmpty() ? tr( "The filesystem %1 can not be resized." ).arg(m_fsname) + !m_fsname.isEmpty() ? tr( "The filesystem %1 can not be resized." ).arg(m_fsname) : tr( "The device %1 can not be resized." ).arg(m_devicename) ); } From e627633c444061f8490f8a6a23ad7af2acf9aafd Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 27 Sep 2018 21:39:22 +0200 Subject: [PATCH 31/70] [fsresizer] initialize FS support --- src/modules/fsresizer/ResizeFSJob.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/modules/fsresizer/ResizeFSJob.cpp b/src/modules/fsresizer/ResizeFSJob.cpp index d501ba4f1..b68485815 100644 --- a/src/modules/fsresizer/ResizeFSJob.cpp +++ b/src/modules/fsresizer/ResizeFSJob.cpp @@ -216,7 +216,9 @@ ResizeFSJob::exec() tr( "KPMCore not Available" ), tr( "Calamares cannot start KPMCore for the file-system resize job." ) ); } + backend_p->initFSSupport(); + // Now get the partition and FS we want to work on PartitionMatch m = findPartition( backend_p ); if ( !m.first || !m.second ) return Calamares::JobResult::error( From 14b675571437353b0c1555154ef0741557b5c5d2 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 27 Sep 2018 21:47:54 +0200 Subject: [PATCH 32/70] [fsresizer] Initialize harder --- src/modules/fsresizer/ResizeFSJob.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/fsresizer/ResizeFSJob.cpp b/src/modules/fsresizer/ResizeFSJob.cpp index b68485815..8f5bce917 100644 --- a/src/modules/fsresizer/ResizeFSJob.cpp +++ b/src/modules/fsresizer/ResizeFSJob.cpp @@ -216,7 +216,7 @@ ResizeFSJob::exec() tr( "KPMCore not Available" ), tr( "Calamares cannot start KPMCore for the file-system resize job." ) ); } - backend_p->initFSSupport(); + backend_p->initFSSupport(); // Might not be enough, see below // Now get the partition and FS we want to work on PartitionMatch m = findPartition( backend_p ); @@ -226,6 +226,7 @@ ResizeFSJob::exec() !m_fsname.isEmpty() ? tr( "The filesystem %1 could not be found in this system, and can not be resized." ).arg(m_fsname) : tr( "The device %1 could not be found in this system, and can not be resized." ).arg(m_devicename) ); + m.second->fileSystem().init(); // Initialize support for specific FS if ( !ResizeOperation::canGrow( m.second ) ) { cDebug() << "canGrow() returned false."; From 5dc11b223a29c7e7cd15cf07b444f2c237f13174 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 28 Sep 2018 11:55:16 +0200 Subject: [PATCH 33/70] [fsresizer] Do the resize itself - handle weird partition tables - ignore unallocated space -- that's what we want to expand into - use ResizeOperation for the actual work --- src/modules/fsresizer/ResizeFSJob.cpp | 41 +++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/src/modules/fsresizer/ResizeFSJob.cpp b/src/modules/fsresizer/ResizeFSJob.cpp index 8f5bce917..e5b3c0afc 100644 --- a/src/modules/fsresizer/ResizeFSJob.cpp +++ b/src/modules/fsresizer/ResizeFSJob.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include "CalamaresVersion.h" #include "JobQueue.h" @@ -145,15 +146,26 @@ ResizeFSJob::findGrownEnd(ResizeFSJob::PartitionMatch m) if ( !ResizeOperation::canGrow( m.second ) ) return -1; - qint64 last_available = m.first->totalLogical(); - cDebug() << "Containing device size" << last_available; + cDebug() << "Containing device size" << m.first->totalLogical(); + qint64 last_available = m.first->totalLogical() - 1; // Numbered from 0 qint64 last_currently = m.second->lastSector(); cDebug() << "Growing partition" << m.second->firstSector() << '-' << last_currently; for ( auto part_it = PartitionIterator::begin( m.first ); part_it != PartitionIterator::end( m.first ); ++part_it ) { qint64 next_start = ( *part_it )->firstSector(); - cDebug() << ".. comparing" << next_start << '-' << ( *part_it )->lastSector(); + qint64 next_end = ( *part_it )->lastSector(); + if ( next_start > next_end ) + { + cWarning() << "Corrupt partition has end" << next_end << " < start" << next_start; + std::swap( next_start, next_end ); + } + if ( ( *part_it )->roles().has( PartitionRole::Unallocated ) ) + { + cDebug() << ".. ignoring unallocated" << next_start << '-' << next_end; + continue; + } + cDebug() << ".. comparing" << next_start << '-' << next_end; if ( (next_start > last_currently) && (next_start < last_available) ) { cDebug() << " .. shrunk last available to" << next_start; @@ -236,9 +248,26 @@ ResizeFSJob::exec() : tr( "The device %1 can not be resized." ).arg(m_devicename) ); } - cDebug() << "Resize from" << m.second->firstSector() - << '+' << m.second->length() << '=' << m.second->lastSector() - << "to" << findGrownEnd( m ); + qint64 new_end = findGrownEnd( m ); + cDebug() << "Resize from" + << m.second->firstSector() << '-' << m.second->lastSector() + << '(' << m.second->length() << ')' + << "to -" << new_end; + + if ( ( new_end > 0 ) && ( new_end > m.second->lastSector() ) ) + { + ResizeOperation op( *m.first, *m.second, m.second->firstSector(), new_end ); + Report op_report( nullptr ); + if ( op.execute( op_report ) ) + cDebug() << "Resize operation OK."; + else + { + cDebug() << "Resize failed." << op_report.output(); + return Calamares::JobResult::error( + tr( "Resize Failed" ), + report.toText() ); + } + } return Calamares::JobResult::ok(); } From c725f6b55263bf00f60be04fc23a9c4301eec38c Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 28 Sep 2018 12:05:41 +0200 Subject: [PATCH 34/70] [fsresizer] Distinguish error from no-useful-resize --- src/modules/fsresizer/ResizeFSJob.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/modules/fsresizer/ResizeFSJob.cpp b/src/modules/fsresizer/ResizeFSJob.cpp index e5b3c0afc..0d10c5583 100644 --- a/src/modules/fsresizer/ResizeFSJob.cpp +++ b/src/modules/fsresizer/ResizeFSJob.cpp @@ -138,6 +138,14 @@ ResizeFSJob::findPartition( CoreBackend* backend ) return PartitionMatch( nullptr, nullptr ); } +/** @brief Returns the last sector the matched partition should occupy. + * + * Returns a sector number. Returns -1 if something is wrong (e.g. + * can't resize at all, or missing data). Returns 0 if the resize + * won't fit because it doesn't satisfy the settings for atleast + * and size (or won't grow at all because the partition is blocked + * by occupied space after it). + */ qint64 ResizeFSJob::findGrownEnd(ResizeFSJob::PartitionMatch m) { @@ -176,7 +184,7 @@ ResizeFSJob::findGrownEnd(ResizeFSJob::PartitionMatch m) if ( !( last_available > last_currently ) ) { cDebug() << "Partition can not grow larger."; - return -1; + return 0; } qint64 expand = last_available - last_currently; // number of sectors @@ -186,7 +194,7 @@ ResizeFSJob::findGrownEnd(ResizeFSJob::PartitionMatch m) if ( expand < required ) { cDebug() << ".. need to expand by" << required << "but only" << expand << "is available."; - return -1; + return 0; } } @@ -254,6 +262,19 @@ ResizeFSJob::exec() << '(' << m.second->length() << ')' << "to -" << new_end; + if ( new_end < 0 ) + return Calamares::JobResult::error( + tr( "Resize Failed" ), + !m_fsname.isEmpty() ? tr( "The filesystem %1 can not be resized." ).arg(m_fsname) + : tr( "The device %1 can not be resized." ).arg(m_devicename) ); + if ( new_end == 0 ) + { + // TODO: is that a bad thing? is the resize required? + cWarning() << "Resize operation on" << m_fsname << m_devicename + << "skipped as not-useful."; + return Calamares::JobResult::ok(); + } + if ( ( new_end > 0 ) && ( new_end > m.second->lastSector() ) ) { ResizeOperation op( *m.first, *m.second, m.second->firstSector(), new_end ); From aaf27ac2ab63cc4a302dc40d54debfce000a0d22 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 28 Sep 2018 12:32:08 +0200 Subject: [PATCH 35/70] [fsresizer] Apply sizes properly - Distinguish size and atleast; in percentages they mean different things (atleast is a bit weird as a percentage, but hey). - Fix bug in percentage calculation. - Avoid percentage above 100. - Add documentation in config-file. --- src/modules/fsresizer/ResizeFSJob.cpp | 38 ++++++++++++++++++++++----- src/modules/fsresizer/ResizeFSJob.h | 16 ++++++++--- src/modules/fsresizer/fsresizer.conf | 4 +++ 3 files changed, 48 insertions(+), 10 deletions(-) diff --git a/src/modules/fsresizer/ResizeFSJob.cpp b/src/modules/fsresizer/ResizeFSJob.cpp index 0d10c5583..f71f010bd 100644 --- a/src/modules/fsresizer/ResizeFSJob.cpp +++ b/src/modules/fsresizer/ResizeFSJob.cpp @@ -68,31 +68,48 @@ ResizeFSJob::RelativeSize::RelativeSize( const QString& s) { matchUnitSuffix( s, "%", Percent, m_value, m_unit ); matchUnitSuffix( s, "MiB", Absolute, m_value, m_unit ); + + if ( ( unit() == Percent ) && ( value() > 100 ) ) + { + cDebug() << "Percent value" << value() << "is not valid."; + m_value = 0; + m_unit = None; + } if ( !m_value ) m_unit = None; } qint64 -ResizeFSJob::RelativeSize::apply( Device* d ) +ResizeFSJob::RelativeSize::apply( qint64 totalSectors , qint64 sectorSize ) { if ( !isValid() ) return -1; - + if ( sectorSize < 1 ) + return -1; + switch( m_unit ) { case None: return -1; case Absolute: - return CalamaresUtils::MiBtoBytes( value() ) / d->logicalSize(); + return CalamaresUtils::MiBtoBytes( value() ) / sectorSize; case Percent: - return d->logicalSize() * value() / 100; + if ( value() == 100 ) + return totalSectors; // Common-case, avoid futzing around + else + return totalSectors * value() / 100; } // notreached return -1; } +qint64 +ResizeFSJob::RelativeSize::apply( Device* d ) +{ + return apply( d->totalLogical(), d->logicalSize() ); +} ResizeFSJob::ResizeFSJob( QObject* parent ) : Calamares::CppJob( parent ) @@ -150,9 +167,11 @@ qint64 ResizeFSJob::findGrownEnd(ResizeFSJob::PartitionMatch m) { if ( !m.first || !m.second ) - return -1; + return -1; // Missing device data if ( !ResizeOperation::canGrow( m.second ) ) - return -1; + return -1; // Operation is doomed + if ( !m_size.isValid() ) + return -1; // Must have a grow-size cDebug() << "Containing device size" << m.first->totalLogical(); qint64 last_available = m.first->totalLogical() - 1; // Numbered from 0 @@ -198,6 +217,13 @@ ResizeFSJob::findGrownEnd(ResizeFSJob::PartitionMatch m) } } + qint64 wanted = m_size.apply( expand, m.first->logicalSize() ); + if ( wanted < expand ) + { + cDebug() << ".. only growing by" << wanted << "instead of full" << expand; + last_available -= ( expand - wanted ); + } + return last_available; } diff --git a/src/modules/fsresizer/ResizeFSJob.h b/src/modules/fsresizer/ResizeFSJob.h index 36527ab56..063495e7d 100644 --- a/src/modules/fsresizer/ResizeFSJob.h +++ b/src/modules/fsresizer/ResizeFSJob.h @@ -64,15 +64,23 @@ public: return ( unit() != None ) && ( value() > 0 ); } - /** @brief Apply this size to the given device @p d + /** @brief Apply this size to the number of sectors @p totalSectors . * + * Each sector has size @p sectorSize , for converting absolute + * sizes in MiB to sector counts. + * * For invalid sizes, returns -1. * For absolute sizes, returns the number of sectors needed. - * For percent sizes, returns the number of sectors matching - * that percentage of the device size. + * For percent sizes, returns that percent of the number of sectors. + */ + qint64 apply( qint64 totalSectors, qint64 sectorSize ); + + /** @brief Apply this size to the given device. + * + * Equivalent to apply( d->totalLogical(), d->logicalSize() ) */ qint64 apply( Device* d ); - + private: int m_value; Unit m_unit; diff --git a/src/modules/fsresizer/fsresizer.conf b/src/modules/fsresizer/fsresizer.conf index f02983e45..06141fc7d 100644 --- a/src/modules/fsresizer/fsresizer.conf +++ b/src/modules/fsresizer/fsresizer.conf @@ -23,6 +23,8 @@ fs: / # how big the card is), use MiB as suffix in that case. # If missing, then it's assumed to be 0, and no resizing # will happen. +# +# Percentages apply to **available space**. size: 100% # Resizing might not be worth it, though. Set the minimum @@ -30,4 +32,6 @@ size: 100% # resizing is skipped. Can be in percentage or absolute # size, as above. If missing, then it's assumed to be 0, # which means resizing is always worthwhile. +# +# Percentages apply to **total device size**. atleast: 1000MiB From ed841d16747bb0528099254704ab52af9e318d2e Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 28 Sep 2018 12:34:40 +0200 Subject: [PATCH 36/70] [fsresizer] Typo --- src/modules/fsresizer/ResizeFSJob.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/fsresizer/ResizeFSJob.cpp b/src/modules/fsresizer/ResizeFSJob.cpp index f71f010bd..0589e1866 100644 --- a/src/modules/fsresizer/ResizeFSJob.cpp +++ b/src/modules/fsresizer/ResizeFSJob.cpp @@ -312,7 +312,7 @@ ResizeFSJob::exec() cDebug() << "Resize failed." << op_report.output(); return Calamares::JobResult::error( tr( "Resize Failed" ), - report.toText() ); + op_report.toText() ); } } From f1ab363f603c35986ef0fae3f1cc3eb58f0f7060 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 28 Sep 2018 12:56:06 +0200 Subject: [PATCH 37/70] Changelog: MD styling FIXES #921 --- CHANGES | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index a996526a3..c7e5432ce 100644 --- a/CHANGES +++ b/CHANGES @@ -19,7 +19,7 @@ This release contains contributions from (alphabetically by first name): is compiled with the newest KPMCore release. * The *keyboard* module now handles the (bogus) Austrian keymap for the system console properly. - - New module *fsresizer* can be used to resize filesystems. It is intended + * New module *fsresizer* can be used to resize filesystems. It is intended for use in OEM installs where an image of fixed size is created, and then sized to the actual SD card the user has used. From b42a36e5ade669d03321e10d12c3d827f4213220 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 28 Sep 2018 14:24:25 +0200 Subject: [PATCH 38/70] [fsresizer] Don't need to check KPMCore version --- src/modules/fsresizer/CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/modules/fsresizer/CMakeLists.txt b/src/modules/fsresizer/CMakeLists.txt index 9f0234406..5de329cad 100644 --- a/src/modules/fsresizer/CMakeLists.txt +++ b/src/modules/fsresizer/CMakeLists.txt @@ -3,10 +3,6 @@ find_package( Qt5 REQUIRED DBus ) # Needed for KPMCore find_package( KF5 REQUIRED I18n WidgetsAddons ) # Needed for KPMCore if ( KPMcore_FOUND ) - if ( KPMcore_VERSION VERSION_GREATER "3.3.0") - add_definitions(-DWITH_KPMCOREGT33) # kpmcore greater than 3.3 - endif() - include_directories( ${KPMCORE_INCLUDE_DIR} ) include_directories( ${PROJECT_BINARY_DIR}/src/libcalamares ) From 7e88f637b15822a6ed9e5166d28cfccb4d880ce9 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sun, 30 Sep 2018 18:56:48 +0200 Subject: [PATCH 39/70] [localecfg] Fix error in string-formatting. --- src/modules/localecfg/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/localecfg/main.py b/src/modules/localecfg/main.py index 62a00b738..713b1e321 100644 --- a/src/modules/localecfg/main.py +++ b/src/modules/localecfg/main.py @@ -134,7 +134,7 @@ def run(): if os.path.exists(target_locale_gen_bak): shutil.copy2(target_locale_gen_bak, target_locale_gen) libcalamares.utils.debug("Restored backup {!s} -> {!s}" - .format(target_locale_gen_bak).format(target_locale_gen)) + .format(target_locale_gen_bak, target_locale_gen)) # run locale-gen if detected; this *will* cause an exception # if the live system has locale.gen, but the target does not: From 0b4c0f9c3896930544f89fe7931094042eb75615 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 1 Oct 2018 04:06:01 -0400 Subject: [PATCH 40/70] [fsresizer] Add setting required - If resize is required, fail if it doesn't happen. --- src/modules/fsresizer/ResizeFSJob.cpp | 14 +++++++++----- src/modules/fsresizer/ResizeFSJob.h | 9 +++++---- src/modules/fsresizer/fsresizer.conf | 16 ++++++++++++++-- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/modules/fsresizer/ResizeFSJob.cpp b/src/modules/fsresizer/ResizeFSJob.cpp index 0589e1866..254e80adb 100644 --- a/src/modules/fsresizer/ResizeFSJob.cpp +++ b/src/modules/fsresizer/ResizeFSJob.cpp @@ -33,6 +33,7 @@ #include "JobQueue.h" #include "GlobalStorage.h" +#include "utils/CalamaresUtils.h" #include "utils/Logger.h" #include "utils/Units.h" @@ -68,7 +69,7 @@ ResizeFSJob::RelativeSize::RelativeSize( const QString& s) { matchUnitSuffix( s, "%", Percent, m_value, m_unit ); matchUnitSuffix( s, "MiB", Absolute, m_value, m_unit ); - + if ( ( unit() == Percent ) && ( value() > 100 ) ) { cDebug() << "Percent value" << value() << "is not valid."; @@ -87,7 +88,7 @@ ResizeFSJob::RelativeSize::apply( qint64 totalSectors , qint64 sectorSize ) return -1; if ( sectorSize < 1 ) return -1; - + switch( m_unit ) { case None: @@ -113,6 +114,7 @@ ResizeFSJob::RelativeSize::apply( Device* d ) ResizeFSJob::ResizeFSJob( QObject* parent ) : Calamares::CppJob( parent ) + , m_required( false ) { } @@ -156,7 +158,7 @@ ResizeFSJob::findPartition( CoreBackend* backend ) } /** @brief Returns the last sector the matched partition should occupy. - * + * * Returns a sector number. Returns -1 if something is wrong (e.g. * can't resize at all, or missing data). Returns 0 if the resize * won't fit because it doesn't satisfy the settings for atleast @@ -223,7 +225,7 @@ ResizeFSJob::findGrownEnd(ResizeFSJob::PartitionMatch m) cDebug() << ".. only growing by" << wanted << "instead of full" << expand; last_available -= ( expand - wanted ); } - + return last_available; } @@ -300,7 +302,7 @@ ResizeFSJob::exec() << "skipped as not-useful."; return Calamares::JobResult::ok(); } - + if ( ( new_end > 0 ) && ( new_end > m.second->lastSector() ) ) { ResizeOperation op( *m.first, *m.second, m.second->firstSector(), new_end ); @@ -334,6 +336,8 @@ ResizeFSJob::setConfigurationMap( const QVariantMap& configurationMap ) m_size = RelativeSize( configurationMap["size"].toString() ); m_atleast = RelativeSize( configurationMap["atleast"].toString() ); + + m_required = CalamaresUtils::getBool( configurationMap, "required", false ); } CALAMARES_PLUGIN_FACTORY_DEFINITION( ResizeFSJobFactory, registerPlugin(); ) diff --git a/src/modules/fsresizer/ResizeFSJob.h b/src/modules/fsresizer/ResizeFSJob.h index 063495e7d..c34ccb865 100644 --- a/src/modules/fsresizer/ResizeFSJob.h +++ b/src/modules/fsresizer/ResizeFSJob.h @@ -68,19 +68,19 @@ public: * * Each sector has size @p sectorSize , for converting absolute * sizes in MiB to sector counts. - * + * * For invalid sizes, returns -1. * For absolute sizes, returns the number of sectors needed. * For percent sizes, returns that percent of the number of sectors. */ qint64 apply( qint64 totalSectors, qint64 sectorSize ); - + /** @brief Apply this size to the given device. - * + * * Equivalent to apply( d->totalLogical(), d->logicalSize() ) */ qint64 apply( Device* d ); - + private: int m_value; Unit m_unit; @@ -107,6 +107,7 @@ private: RelativeSize m_atleast; QString m_fsname; // Either this, or devicename, is set, not both QString m_devicename; + bool m_required; using PartitionMatch = QPair; /** @brief Find the configured FS using KPMCore @p backend */ diff --git a/src/modules/fsresizer/fsresizer.conf b/src/modules/fsresizer/fsresizer.conf index 06141fc7d..33329248d 100644 --- a/src/modules/fsresizer/fsresizer.conf +++ b/src/modules/fsresizer/fsresizer.conf @@ -12,7 +12,7 @@ # Which FS needs to be grown? Choose one way to identify it: # - *fs* names a mount point which should already be mounted # in the system. -# - *dev* names a device +# - *dev* names a device fs: / # dev: /dev/mmcblk0p1 @@ -33,5 +33,17 @@ size: 100% # size, as above. If missing, then it's assumed to be 0, # which means resizing is always worthwhile. # +# If *atleast* is not zero, then the setting *required*, +# below, becomes relevant. +# # Percentages apply to **total device size**. -atleast: 1000MiB +#atleast: 1000MiB + +# When *atleast* is not zero, then the resize may be +# recommended (the default) or **required**. If the +# resize is required and cannot be carried out (because +# there's not enough space), then that is a fatal +# error for the installer. By default, resize is only +# recommended and it is not an error for no resize to be +# carried out. +required: false From eb7c6385cdce9c76c27bdb6c6518a4e407e2e357 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 1 Oct 2018 04:14:15 -0400 Subject: [PATCH 41/70] [fsresizer] Bail out if resize required but not feasible --- src/modules/fsresizer/ResizeFSJob.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/modules/fsresizer/ResizeFSJob.cpp b/src/modules/fsresizer/ResizeFSJob.cpp index 254e80adb..886ce803a 100644 --- a/src/modules/fsresizer/ResizeFSJob.cpp +++ b/src/modules/fsresizer/ResizeFSJob.cpp @@ -297,9 +297,14 @@ ResizeFSJob::exec() : tr( "The device %1 can not be resized." ).arg(m_devicename) ); if ( new_end == 0 ) { - // TODO: is that a bad thing? is the resize required? cWarning() << "Resize operation on" << m_fsname << m_devicename << "skipped as not-useful."; + if ( m_required ) + return Calamares::JobResult::error( + tr( "Resize Failed" ), + !m_fsname.isEmpty() ? tr( "The filesystem %1 must be resized, but cannot." ).arg(m_fsname) + : tr( "The device %11 must be resized, but cannot" ).arg(m_fsname) ); + return Calamares::JobResult::ok(); } From 39902d1c3f4dcdea42fa7748723d2d508e45cb70 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 1 Oct 2018 04:15:09 -0400 Subject: [PATCH 42/70] [fsresizer] "can not" -> "cannot" --- src/modules/fsresizer/ResizeFSJob.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/modules/fsresizer/ResizeFSJob.cpp b/src/modules/fsresizer/ResizeFSJob.cpp index 886ce803a..af0cb7bd0 100644 --- a/src/modules/fsresizer/ResizeFSJob.cpp +++ b/src/modules/fsresizer/ResizeFSJob.cpp @@ -204,7 +204,7 @@ ResizeFSJob::findGrownEnd(ResizeFSJob::PartitionMatch m) if ( !( last_available > last_currently ) ) { - cDebug() << "Partition can not grow larger."; + cDebug() << "Partition cannot grow larger."; return 0; } @@ -271,8 +271,8 @@ ResizeFSJob::exec() if ( !m.first || !m.second ) return Calamares::JobResult::error( tr( "Resize Failed" ), - !m_fsname.isEmpty() ? tr( "The filesystem %1 could not be found in this system, and can not be resized." ).arg(m_fsname) - : tr( "The device %1 could not be found in this system, and can not be resized." ).arg(m_devicename) ); + !m_fsname.isEmpty() ? tr( "The filesystem %1 could not be found in this system, and cannot be resized." ).arg(m_fsname) + : tr( "The device %1 could not be found in this system, and cannot be resized." ).arg(m_devicename) ); m.second->fileSystem().init(); // Initialize support for specific FS if ( !ResizeOperation::canGrow( m.second ) ) @@ -280,8 +280,8 @@ ResizeFSJob::exec() cDebug() << "canGrow() returned false."; return Calamares::JobResult::error( tr( "Resize Failed" ), - !m_fsname.isEmpty() ? tr( "The filesystem %1 can not be resized." ).arg(m_fsname) - : tr( "The device %1 can not be resized." ).arg(m_devicename) ); + !m_fsname.isEmpty() ? tr( "The filesystem %1 cannot be resized." ).arg(m_fsname) + : tr( "The device %1 cannot be resized." ).arg(m_devicename) ); } qint64 new_end = findGrownEnd( m ); @@ -293,8 +293,8 @@ ResizeFSJob::exec() if ( new_end < 0 ) return Calamares::JobResult::error( tr( "Resize Failed" ), - !m_fsname.isEmpty() ? tr( "The filesystem %1 can not be resized." ).arg(m_fsname) - : tr( "The device %1 can not be resized." ).arg(m_devicename) ); + !m_fsname.isEmpty() ? tr( "The filesystem %1 cannot be resized." ).arg(m_fsname) + : tr( "The device %1 cannot be resized." ).arg(m_devicename) ); if ( new_end == 0 ) { cWarning() << "Resize operation on" << m_fsname << m_devicename From 21fedfce65a5ef7f1f4c41914389e4b4dd91366b Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 1 Oct 2018 04:22:25 -0400 Subject: [PATCH 43/70] [fsresizer] Calamares oding style --- src/modules/fsresizer/ResizeFSJob.cpp | 51 +++++++++++++-------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/src/modules/fsresizer/ResizeFSJob.cpp b/src/modules/fsresizer/ResizeFSJob.cpp index af0cb7bd0..4320baba1 100644 --- a/src/modules/fsresizer/ResizeFSJob.cpp +++ b/src/modules/fsresizer/ResizeFSJob.cpp @@ -49,11 +49,11 @@ ResizeFSJob::RelativeSize::RelativeSize() template void matchUnitSuffix( const QString& s, - const char (&suffix)[N], + const char ( &suffix )[N], ResizeFSJob::RelativeSize::Unit matchedUnit, int& value, ResizeFSJob::RelativeSize::Unit& unit - ) +) { if ( s.endsWith( suffix ) ) { @@ -63,7 +63,7 @@ void matchUnitSuffix( } -ResizeFSJob::RelativeSize::RelativeSize( const QString& s) +ResizeFSJob::RelativeSize::RelativeSize( const QString& s ) : m_value( 0 ) , m_unit( None ) { @@ -82,14 +82,14 @@ ResizeFSJob::RelativeSize::RelativeSize( const QString& s) } qint64 -ResizeFSJob::RelativeSize::apply( qint64 totalSectors , qint64 sectorSize ) +ResizeFSJob::RelativeSize::apply( qint64 totalSectors, qint64 sectorSize ) { if ( !isValid() ) return -1; if ( sectorSize < 1 ) return -1; - switch( m_unit ) + switch ( m_unit ) { case None: return -1; @@ -138,14 +138,14 @@ ResizeFSJob::findPartition( CoreBackend* backend ) cDebug() << "ResizeFSJob found" << devices.count() << "devices."; for ( DeviceList::iterator dev_it = devices.begin(); dev_it != devices.end(); ++dev_it ) { - if ( ! (*dev_it) ) + if ( ! ( *dev_it ) ) continue; cDebug() << "ResizeFSJob found" << ( *dev_it )->deviceNode(); for ( auto part_it = PartitionIterator::begin( *dev_it ); part_it != PartitionIterator::end( *dev_it ); ++part_it ) { cDebug() << ".." << ( *part_it )->mountPoint() << "on" << ( *part_it )->deviceNode(); if ( ( !m_fsname.isEmpty() && ( *part_it )->mountPoint() == m_fsname ) || - ( !m_devicename.isEmpty() && ( *part_it )->deviceNode() == m_devicename ) ) + ( !m_devicename.isEmpty() && ( *part_it )->deviceNode() == m_devicename ) ) { cDebug() << ".. matched configuration dev=" << m_devicename << "fs=" << m_fsname; return PartitionMatch( *dev_it, *part_it ); @@ -166,7 +166,7 @@ ResizeFSJob::findPartition( CoreBackend* backend ) * by occupied space after it). */ qint64 -ResizeFSJob::findGrownEnd(ResizeFSJob::PartitionMatch m) +ResizeFSJob::findGrownEnd( ResizeFSJob::PartitionMatch m ) { if ( !m.first || !m.second ) return -1; // Missing device data @@ -195,7 +195,7 @@ ResizeFSJob::findGrownEnd(ResizeFSJob::PartitionMatch m) continue; } cDebug() << ".. comparing" << next_start << '-' << next_end; - if ( (next_start > last_currently) && (next_start < last_available) ) + if ( ( next_start > last_currently ) && ( next_start < last_available ) ) { cDebug() << " .. shrunk last available to" << next_start; last_available = next_start - 1; // Before that one starts @@ -236,13 +236,12 @@ ResizeFSJob::exec() if ( !isValid() ) return Calamares::JobResult::error( tr( "Invalid configuration" ), - tr( "The file-system resize job has an invalid configuration " - "and will not run." ) ); + tr( "The file-system resize job has an invalid configuration and will not run." ) ); // Get KPMCore auto backend_p = CoreBackendManager::self()->backend(); if ( backend_p ) - cDebug() << "KPMCore backend @" << (void *)backend_p << backend_p->id() << backend_p->version(); + cDebug() << "KPMCore backend @" << ( void* )backend_p << backend_p->id() << backend_p->version(); else { cDebug() << "No KPMCore backend loaded yet"; @@ -271,8 +270,8 @@ ResizeFSJob::exec() if ( !m.first || !m.second ) return Calamares::JobResult::error( tr( "Resize Failed" ), - !m_fsname.isEmpty() ? tr( "The filesystem %1 could not be found in this system, and cannot be resized." ).arg(m_fsname) - : tr( "The device %1 could not be found in this system, and cannot be resized." ).arg(m_devicename) ); + !m_fsname.isEmpty() ? tr( "The filesystem %1 could not be found in this system, and cannot be resized." ).arg( m_fsname ) + : tr( "The device %1 could not be found in this system, and cannot be resized." ).arg( m_devicename ) ); m.second->fileSystem().init(); // Initialize support for specific FS if ( !ResizeOperation::canGrow( m.second ) ) @@ -280,30 +279,30 @@ ResizeFSJob::exec() cDebug() << "canGrow() returned false."; return Calamares::JobResult::error( tr( "Resize Failed" ), - !m_fsname.isEmpty() ? tr( "The filesystem %1 cannot be resized." ).arg(m_fsname) - : tr( "The device %1 cannot be resized." ).arg(m_devicename) ); + !m_fsname.isEmpty() ? tr( "The filesystem %1 cannot be resized." ).arg( m_fsname ) + : tr( "The device %1 cannot be resized." ).arg( m_devicename ) ); } qint64 new_end = findGrownEnd( m ); cDebug() << "Resize from" - << m.second->firstSector() << '-' << m.second->lastSector() - << '(' << m.second->length() << ')' - << "to -" << new_end; + << m.second->firstSector() << '-' << m.second->lastSector() + << '(' << m.second->length() << ')' + << "to -" << new_end; if ( new_end < 0 ) return Calamares::JobResult::error( tr( "Resize Failed" ), - !m_fsname.isEmpty() ? tr( "The filesystem %1 cannot be resized." ).arg(m_fsname) - : tr( "The device %1 cannot be resized." ).arg(m_devicename) ); + !m_fsname.isEmpty() ? tr( "The filesystem %1 cannot be resized." ).arg( m_fsname ) + : tr( "The device %1 cannot be resized." ).arg( m_devicename ) ); if ( new_end == 0 ) { cWarning() << "Resize operation on" << m_fsname << m_devicename - << "skipped as not-useful."; + << "skipped as not-useful."; if ( m_required ) return Calamares::JobResult::error( tr( "Resize Failed" ), - !m_fsname.isEmpty() ? tr( "The filesystem %1 must be resized, but cannot." ).arg(m_fsname) - : tr( "The device %11 must be resized, but cannot" ).arg(m_fsname) ); + !m_fsname.isEmpty() ? tr( "The filesystem %1 must be resized, but cannot." ).arg( m_fsname ) + : tr( "The device %11 must be resized, but cannot" ).arg( m_fsname ) ); return Calamares::JobResult::ok(); } @@ -318,8 +317,8 @@ ResizeFSJob::exec() { cDebug() << "Resize failed." << op_report.output(); return Calamares::JobResult::error( - tr( "Resize Failed" ), - op_report.toText() ); + tr( "Resize Failed" ), + op_report.toText() ); } } From 0d8cf98811bd4d20a408d02d8c70f5da2f35ab51 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 1 Oct 2018 04:27:26 -0400 Subject: [PATCH 44/70] Changelog: nudge closer to release. --- CHANGES | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGES b/CHANGES index c7e5432ce..da731b3a6 100644 --- a/CHANGES +++ b/CHANGES @@ -13,10 +13,16 @@ This release contains contributions from (alphabetically by first name): ## Core ## +There are no core changes in this version. + ## Modules ## * The *partition* module supports RAID devices, but only when Calamares is compiled with the newest KPMCore release. + * The calculation of required space -- including swap -- has been simplified, + and Calamares no longer reserves 2GiB of space in calculations for internal + use (this means that it no longer mysteriously drops swap when the disk + size is close to the required installation size). * The *keyboard* module now handles the (bogus) Austrian keymap for the system console properly. * New module *fsresizer* can be used to resize filesystems. It is intended From 3ef4842a4d7bb0104c88130f11e0f8da7e182ec1 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 1 Oct 2018 10:40:43 +0200 Subject: [PATCH 45/70] [preservefiles] Add permissions-parsing code from Scott Harvey --- CHANGES | 3 + src/modules/preservefiles/permissions.cpp | 70 +++++++++++++++++++++++ src/modules/preservefiles/permissions.h | 58 +++++++++++++++++++ 3 files changed, 131 insertions(+) create mode 100644 src/modules/preservefiles/permissions.cpp create mode 100644 src/modules/preservefiles/permissions.h diff --git a/CHANGES b/CHANGES index da731b3a6..896a9fee2 100644 --- a/CHANGES +++ b/CHANGES @@ -10,6 +10,7 @@ This release contains contributions from (alphabetically by first name): - Caio Carvalho - Kevin Kofler - Philip Mueller + - Scott Harvey ## Core ## @@ -25,6 +26,8 @@ There are no core changes in this version. size is close to the required installation size). * The *keyboard* module now handles the (bogus) Austrian keymap for the system console properly. + * The *preservefiles* module now has a mechanism for setting the permissions + (and ownership) of preserved files. * New module *fsresizer* can be used to resize filesystems. It is intended for use in OEM installs where an image of fixed size is created, and then sized to the actual SD card the user has used. diff --git a/src/modules/preservefiles/permissions.cpp b/src/modules/preservefiles/permissions.cpp new file mode 100644 index 000000000..93606f7d8 --- /dev/null +++ b/src/modules/preservefiles/permissions.cpp @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2018 Scott Harvey + * + * This program 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. + * + * This program 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 this program. If not, see . + * + */ + +#include +#include +#include "permissions.h" + +Permissions::Permissions(QString p) : + m_username(), + m_group(), + m_valid(true), + m_value(0) + +{ + parsePermissions(p); +} + +const void Permissions::parsePermissions(const QString& p) { + + QStringList segments = p.split(":"); + + if (segments.length() != 3) { + m_valid = false; + return; + } + + if (segments[0].isEmpty() || segments[1].isEmpty()) { + m_valid = false; + return; + } + + bool ok; + int octal = segments[2].toInt(&ok, 8); + if (!ok || octal == 0) { + m_valid = false; + return; + } else { + m_value = octal; + } + + // We have exactly three segments and the third is valid octal, + // so we can declare the string valid and set the user and group names + m_valid = true; + m_username = segments[0]; + m_group = segments[1]; + + return; + +} + + + + + + diff --git a/src/modules/preservefiles/permissions.h b/src/modules/preservefiles/permissions.h new file mode 100644 index 000000000..27224181f --- /dev/null +++ b/src/modules/preservefiles/permissions.h @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 Scott Harvey + * + * This program 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. + * + * This program 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 this program. If not, see . + * + */ + +#ifndef PERMISSIONS_H +#define PERMISSIONS_H + +#include + +/** + * @brief The Permissions class takes a QString @p in the form of + * ::, checks it for validity, and makes the three + * components available indivdually. + */ +class Permissions +{ + +public: + +/** Constructor + * Splits the string @p at the colon (":") into separate elements for + * , , and (permissions), where is returned as + * an **octal** integer. + */ + Permissions(QString p); + + bool isValid() const { return m_valid; } + QString username() const { return m_username; } + QString group() const { return m_group; } + int value() const { return m_value; } + + +private: + + const void parsePermissions(QString const &p); + + QString m_username; + QString m_group; + bool m_valid; + int m_value; + +}; + +#endif // PERMISSIONS_H From 1c85a648a4bf1f3f0a986433c2fbb580e515ce1e Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 1 Oct 2018 10:45:39 +0200 Subject: [PATCH 46/70] [preservefiles] Tie permissions into the build, file header --- src/modules/preservefiles/CMakeLists.txt | 1 + src/modules/preservefiles/permissions.cpp | 3 ++- src/modules/preservefiles/permissions.h | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/modules/preservefiles/CMakeLists.txt b/src/modules/preservefiles/CMakeLists.txt index 1ac979d1b..c1021eeda 100644 --- a/src/modules/preservefiles/CMakeLists.txt +++ b/src/modules/preservefiles/CMakeLists.txt @@ -4,6 +4,7 @@ calamares_add_plugin( preservefiles TYPE job EXPORT_MACRO PLUGINDLLEXPORT_PRO SOURCES + permissions.cpp PreserveFiles.cpp LINK_PRIVATE_LIBRARIES calamares diff --git a/src/modules/preservefiles/permissions.cpp b/src/modules/preservefiles/permissions.cpp index 93606f7d8..e85386292 100644 --- a/src/modules/preservefiles/permissions.cpp +++ b/src/modules/preservefiles/permissions.cpp @@ -1,4 +1,5 @@ -/* +/* === This file is part of Calamares - === + * * Copyright (C) 2018 Scott Harvey * * This program is free software: you can redistribute it and/or modify diff --git a/src/modules/preservefiles/permissions.h b/src/modules/preservefiles/permissions.h index 27224181f..5bbb17fba 100644 --- a/src/modules/preservefiles/permissions.h +++ b/src/modules/preservefiles/permissions.h @@ -1,4 +1,5 @@ -/* +/* === This file is part of Calamares - === + * * Copyright (C) 2018 Scott Harvey * * This program is free software: you can redistribute it and/or modify From 91c94c60220cf5e8885215566dc8762b14aeb267 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 1 Oct 2018 10:51:21 +0200 Subject: [PATCH 47/70] [preservefiles] Tidy up permissions code - superfluous const - add default constructor - Add octal-string accessor to permissions --- src/modules/preservefiles/permissions.cpp | 10 +++++++--- src/modules/preservefiles/permissions.h | 19 +++++++++++-------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/modules/preservefiles/permissions.cpp b/src/modules/preservefiles/permissions.cpp index e85386292..a3f8ac136 100644 --- a/src/modules/preservefiles/permissions.cpp +++ b/src/modules/preservefiles/permissions.cpp @@ -21,17 +21,21 @@ #include #include "permissions.h" -Permissions::Permissions(QString p) : +Permissions::Permissions() : m_username(), m_group(), - m_valid(true), + m_valid(false), m_value(0) +{ +} + +Permissions::Permissions(QString p) : Permissions() { parsePermissions(p); } -const void Permissions::parsePermissions(const QString& p) { +void Permissions::parsePermissions(const QString& p) { QStringList segments = p.split(":"); diff --git a/src/modules/preservefiles/permissions.h b/src/modules/preservefiles/permissions.h index 5bbb17fba..4cb70a2c2 100644 --- a/src/modules/preservefiles/permissions.h +++ b/src/modules/preservefiles/permissions.h @@ -32,22 +32,25 @@ class Permissions public: -/** Constructor - * Splits the string @p at the colon (":") into separate elements for - * , , and (permissions), where is returned as - * an **octal** integer. - */ + /** @brief Constructor + * + * Splits the string @p at the colon (":") into separate elements for + * , , and (permissions), where is returned as + * an **octal** integer. + */ Permissions(QString p); + + /** @brief Default constructor of an invalid Permissions. */ + Permissions(); bool isValid() const { return m_valid; } QString username() const { return m_username; } QString group() const { return m_group; } int value() const { return m_value; } - + QString octal() const { return QString::number( m_value, 8 ); } private: - - const void parsePermissions(QString const &p); + void parsePermissions(QString const &p); QString m_username; QString m_group; From d3d08241e2d6779886d41383f7fc0eb33f1355ce Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 1 Oct 2018 11:02:56 +0200 Subject: [PATCH 48/70] [preservefiles] Support perm setting - Use settings from config file - Refactor copy operation - Apply permissions inside target system --- src/modules/preservefiles/PreserveFiles.cpp | 87 ++++++++++++++------- src/modules/preservefiles/PreserveFiles.h | 5 +- 2 files changed, 63 insertions(+), 29 deletions(-) diff --git a/src/modules/preservefiles/PreserveFiles.cpp b/src/modules/preservefiles/PreserveFiles.cpp index 0fe1d278b..03387fd24 100644 --- a/src/modules/preservefiles/PreserveFiles.cpp +++ b/src/modules/preservefiles/PreserveFiles.cpp @@ -18,6 +18,8 @@ #include "PreserveFiles.h" +#include "permissions.h" + #include "CalamaresVersion.h" #include "JobQueue.h" #include "GlobalStorage.h" @@ -83,6 +85,38 @@ PreserveFiles::prettyName() const return tr( "Saving files for later ..." ); } +static bool +copy_file( const QString& source, const QString& dest ) +{ + QFile sourcef( source ); + if ( !sourcef.open( QFile::ReadOnly ) ) + { + cWarning() << "Could not read" << source; + return false; + } + + QFile destf( dest ); + if ( !destf.open( QFile::WriteOnly ) ) + { + sourcef.close(); + cWarning() << "Could not open" << destf.fileName() << "for writing; could not copy" << source; + return false; + } + + QByteArray b; + do + { + b = sourcef.read( 1_MiB ); + destf.write( b ); + } + while ( b.count() > 0 ); + + sourcef.close(); + destf.close(); + + return true; +} + Calamares::JobResult PreserveFiles::exec() { if ( m_items.isEmpty() ) @@ -96,7 +130,8 @@ Calamares::JobResult PreserveFiles::exec() for ( const auto& it : m_items ) { QString source = it.source; - QString dest = prefix + atReplacements( it.dest ); + QString bare_dest = atReplacements( it.dest ); + QString dest = prefix + bare_dest; if ( it.type == ItemType::Log ) source = Logger::logFile(); @@ -111,32 +146,29 @@ Calamares::JobResult PreserveFiles::exec() cWarning() << "Skipping unnamed source file for" << dest; else { - QFile sourcef( source ); - if ( !sourcef.open( QFile::ReadOnly ) ) + if ( copy_file( source, dest ) ) { - cWarning() << "Could not read" << source; - continue; + if ( it.perm.isValid() ) + { + auto s_p = CalamaresUtils::System::instance(); + + int r; + + r = s_p->targetEnvCall( QStringList{ "chown", it.perm.username(), bare_dest } ); + if ( r ) + cWarning() << "Could not chown target" << bare_dest; + + r = s_p->targetEnvCall( QStringList{ "chgrp", it.perm.group(), bare_dest } ); + if ( r ) + cWarning() << "Could not chgrp target" << bare_dest; + + r = s_p->targetEnvCall( QStringList{ "chmod", it.perm.octal(), bare_dest } ); + if ( r ) + cWarning() << "Could not chmod target" << bare_dest; + } + + ++count; } - - QFile destf( dest ); - if ( !destf.open( QFile::WriteOnly ) ) - { - sourcef.close(); - cWarning() << "Could not open" << destf.fileName() << "for writing; could not copy" << source; - continue; - } - - QByteArray b; - do - { - b = sourcef.read( 1_MiB ); - destf.write( b ); - } - while ( b.count() > 0 ); - - sourcef.close(); - destf.close(); - ++count; } } @@ -168,7 +200,7 @@ void PreserveFiles::setConfigurationMap(const QVariantMap& configurationMap) { QString filename = li.toString(); if ( !filename.isEmpty() ) - m_items.append( Item{ filename, filename, ItemType::Path } ); + m_items.append( Item{ filename, filename, Permissions(), ItemType::Path } ); else cDebug() << "Empty filename for preservefiles, item" << c; } @@ -181,6 +213,7 @@ void PreserveFiles::setConfigurationMap(const QVariantMap& configurationMap) ( from == "log" ) ? ItemType::Log : ( from == "config" ) ? ItemType::Config : ItemType::None; + QString perm = map[ "perm" ].toString(); if ( dest.isEmpty() ) { @@ -192,7 +225,7 @@ void PreserveFiles::setConfigurationMap(const QVariantMap& configurationMap) } else { - m_items.append( Item{ QString(), dest, t } ); + m_items.append( Item{ QString(), dest, Permissions(perm), t } ); } } else diff --git a/src/modules/preservefiles/PreserveFiles.h b/src/modules/preservefiles/PreserveFiles.h index 0c9216336..ed2fe889c 100644 --- a/src/modules/preservefiles/PreserveFiles.h +++ b/src/modules/preservefiles/PreserveFiles.h @@ -24,11 +24,11 @@ #include #include "CppJob.h" +#include "PluginDllMacro.h" #include "utils/PluginFactory.h" -#include "PluginDllMacro.h" - +#include "permissions.h" class PLUGINDLLEXPORT PreserveFiles : public Calamares::CppJob { @@ -46,6 +46,7 @@ class PLUGINDLLEXPORT PreserveFiles : public Calamares::CppJob { QString source; QString dest; + Permissions perm; ItemType type; } ; From eb6fc01c0127c21001cf77f65387bce563034833 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 1 Oct 2018 11:06:42 +0200 Subject: [PATCH 49/70] [preservefiles] Document new permissions key --- src/modules/preservefiles/preservefiles.conf | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/modules/preservefiles/preservefiles.conf b/src/modules/preservefiles/preservefiles.conf index ab9114d20..ac8e1f7db 100644 --- a/src/modules/preservefiles/preservefiles.conf +++ b/src/modules/preservefiles/preservefiles.conf @@ -9,13 +9,18 @@ # as the source). # - a map with a *dest* key. The *dest* value is a path interpreted in the # target system (if dontChroot is true, in the host system). Relative paths -# are not recommended. There are two possible other keys in the map: +# are not recommended. There are three possible other keys in the map: # - *from*, which must have one of the values, below; it is used to # preserve files whose pathname is known to Calamares internally. # - *src*, to refer to a path interpreted in the host system. Relative # paths are not recommended, and are interpreted relative to where # Calamares is being run. -# Only one of the two other keys (either *from* or *src*) may be set. +# - *perm*, is a colon-separated tuple of :: +# where is in octal (e.g. 4777 for wide-open, 0400 for read-only +# by owner). If set, the file's ownership and permissions are set to +# those values within the target system; if not set, no permissions +# are changed. +# Only one of the two source keys (either *from* or *src*) may be set. # # The target filename is modified as follows: # - `@@ROOT@@` is replaced by the path to the target root (may be /) @@ -32,5 +37,7 @@ files: - /etc/oem-information - from: log dest: /root/install.log + perm: root:wheel:644 - from: config dest: /root/install.cfg + perm: root:wheel:400 From 1a248e0574fec04934c88f096b382d202dfec3cd Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 1 Oct 2018 11:31:54 +0200 Subject: [PATCH 50/70] [preservefiles] Apply restrictive default permissions --- src/modules/preservefiles/PreserveFiles.cpp | 10 ++++++++-- src/modules/preservefiles/preservefiles.conf | 6 ++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/modules/preservefiles/PreserveFiles.cpp b/src/modules/preservefiles/PreserveFiles.cpp index 03387fd24..2c1b85103 100644 --- a/src/modules/preservefiles/PreserveFiles.cpp +++ b/src/modules/preservefiles/PreserveFiles.cpp @@ -192,6 +192,10 @@ void PreserveFiles::setConfigurationMap(const QVariantMap& configurationMap) return; } + QString defaultPermissions = configurationMap[ "perm" ].toString(); + if ( defaultPermissions.isEmpty() ) + defaultPermissions = QStringLiteral( "root:root:0400" ); + QVariantList l = files.toList(); unsigned int c = 0; for ( const auto& li : l ) @@ -200,7 +204,7 @@ void PreserveFiles::setConfigurationMap(const QVariantMap& configurationMap) { QString filename = li.toString(); if ( !filename.isEmpty() ) - m_items.append( Item{ filename, filename, Permissions(), ItemType::Path } ); + m_items.append( Item{ filename, filename, Permissions( defaultPermissions ), ItemType::Path } ); else cDebug() << "Empty filename for preservefiles, item" << c; } @@ -214,6 +218,8 @@ void PreserveFiles::setConfigurationMap(const QVariantMap& configurationMap) ( from == "config" ) ? ItemType::Config : ItemType::None; QString perm = map[ "perm" ].toString(); + if ( perm.isEmpty() ) + perm = defaultPermissions; if ( dest.isEmpty() ) { @@ -225,7 +231,7 @@ void PreserveFiles::setConfigurationMap(const QVariantMap& configurationMap) } else { - m_items.append( Item{ QString(), dest, Permissions(perm), t } ); + m_items.append( Item{ QString(), dest, Permissions( perm ), t } ); } } else diff --git a/src/modules/preservefiles/preservefiles.conf b/src/modules/preservefiles/preservefiles.conf index ac8e1f7db..671a308cc 100644 --- a/src/modules/preservefiles/preservefiles.conf +++ b/src/modules/preservefiles/preservefiles.conf @@ -41,3 +41,9 @@ files: - from: config dest: /root/install.cfg perm: root:wheel:400 + +# The *perm* key contains a default value to apply to all files listed +# above that do not have a *perm* key of their own. If not set, +# root:root:0400 (highly restrictive) is used. +# +# perm: "root:root:0400" From 800f9d34f9f4c4b07fe5279e032894dcd4b3251e Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 3 Oct 2018 13:46:08 +0200 Subject: [PATCH 51/70] [partition] In logging, distinguish more cases - While winnowing devices, the zram and nullptr cases were mixed together; split them, for the sake of logging more accurately. - While here, fix up some coding-style issues. --- src/modules/partition/core/DeviceList.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/modules/partition/core/DeviceList.cpp b/src/modules/partition/core/DeviceList.cpp index 4a353efb4..f51eec047 100644 --- a/src/modules/partition/core/DeviceList.cpp +++ b/src/modules/partition/core/DeviceList.cpp @@ -113,28 +113,32 @@ QList< Device* > getDevices( DeviceType which, qint64 minimumSize ) // Remove the device which contains / from the list for ( DeviceList::iterator it = devices.begin(); it != devices.end(); ) - if ( ! ( *it ) || - ( *it )->deviceNode().startsWith( "/dev/zram" ) + if ( !( *it ) ) + { + cDebug() << " .. Skipping nullptr device"; + it = erase( devices, it); + } + else if ( ( *it )->deviceNode().startsWith( "/dev/zram" ) ) { cDebug() << " .. Removing zram" << it; - it = erase(devices, it ); + it = erase( devices, it ); } else if ( writableOnly && hasRootPartition( *it ) ) { cDebug() << " .. Removing device with root filesystem (/) on it" << it; - it = erase(devices, it ); + it = erase( devices, it ); } else if ( writableOnly && isIso9660( *it ) ) { cDebug() << " .. Removing device with iso9660 filesystem (probably a CD) on it" << it; - it = erase(devices, it ); + it = erase( devices, it ); } else if ( (minimumSize >= 0) && !( (*it)->capacity() > minimumSize ) ) { cDebug() << " .. Removing too-small" << it; - it = erase(devices, it ); + it = erase( devices, it ); } else ++it; From b38316365e1e7feca6c82f32a34d0b0ec6b62198 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 3 Oct 2018 13:58:50 +0200 Subject: [PATCH 52/70] [partition] Be more verbose about why UI buttons appear --- src/modules/partition/gui/ChoicePage.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp index abe7795c0..5cbfb69f7 100644 --- a/src/modules/partition/gui/ChoicePage.cpp +++ b/src/modules/partition/gui/ChoicePage.cpp @@ -1174,6 +1174,9 @@ ChoicePage::setupActions() OsproberEntryList osproberEntriesForCurrentDevice = getOsproberEntriesForDevice( currentDevice ); + cDebug() << "Setting up actions for" << currentDevice->deviceNode() + << "with" << osproberEntriesForCurrentDevice.count() << "entries."; + if ( currentDevice->partitionTable() ) m_deviceInfoWidget->setPartitionTableType( currentDevice->partitionTable()->type() ); else @@ -1190,18 +1193,30 @@ ChoicePage::setupActions() #ifdef WITH_KPMCOREGT33 if ( currentDevice->type() == Device::Type::SoftwareRAID_Device && static_cast< SoftwareRAID* >(currentDevice)->status() == SoftwareRAID::Status::Inactive ) + { + cDebug() << ".. part of an inactive RAID device"; isInactiveRAID = true; + } #endif for ( auto it = PartitionIterator::begin( currentDevice ); it != PartitionIterator::end( currentDevice ); ++it ) { if ( PartUtils::canBeResized( *it ) ) + { + cDebug() << ".. contains resizable" << it; atLeastOneCanBeResized = true; + } if ( PartUtils::canBeReplaced( *it ) ) + { + cDebug() << ".. contains replacable" << it; atLeastOneCanBeReplaced = true; + } if ( (*it)->isMounted() ) + { + cDebug() << ".. contains mounted" << it; atLeastOneIsMounted = true; + } } if ( osproberEntriesForCurrentDevice.count() == 0 ) @@ -1318,7 +1333,12 @@ ChoicePage::setupActions() if ( !atLeastOneIsMounted && !isInactiveRAID ) m_eraseButton->show(); // None mounted else + { + cDebug() << "Erase button suppressed" + << "mount?" << atLeastOneIsMounted + << "raid?" << isInactiveRAID; force_uncheck( m_grp, m_eraseButton ); + } bool isEfi = PartUtils::isEfiSystem(); bool efiSystemPartitionFound = !m_core->efiSystemPartitions().isEmpty(); From 292bc57523bca3a374f0661fe5c0de7d3032ad58 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 3 Oct 2018 13:49:52 -0400 Subject: [PATCH 53/70] [partition] Fix build with suitable operator << --- src/modules/partition/gui/ChoicePage.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp index 5cbfb69f7..9bc571459 100644 --- a/src/modules/partition/gui/ChoicePage.cpp +++ b/src/modules/partition/gui/ChoicePage.cpp @@ -1161,6 +1161,13 @@ force_uncheck(QButtonGroup* grp, PrettyRadioButton* button) grp->setExclusive( true ); } +static inline QDebug& +operator <<( QDebug& s, PartitionIterator& it ) +{ + s << ( ( *it ) ? ( *it )->deviceNode() : QString( "" ) ); + return s; +} + /** * @brief ChoicePage::setupActions happens every time a new Device* is selected in the * device picker. Sets up the text and visibility of the partitioning actions based @@ -1176,7 +1183,7 @@ ChoicePage::setupActions() cDebug() << "Setting up actions for" << currentDevice->deviceNode() << "with" << osproberEntriesForCurrentDevice.count() << "entries."; - + if ( currentDevice->partitionTable() ) m_deviceInfoWidget->setPartitionTableType( currentDevice->partitionTable()->type() ); else From c63ecc8a35a6e515169e5331447713a51dc7a35d Mon Sep 17 00:00:00 2001 From: Calamares CI Date: Fri, 5 Oct 2018 07:36:39 -0400 Subject: [PATCH 54/70] i18n: [calamares] Automatic merge of Transifex translations --- lang/calamares_da.ts | 2 +- lang/calamares_fr.ts | 2 +- lang/calamares_he.ts | 4 ++-- lang/calamares_hu.ts | 6 +++--- lang/calamares_lt.ts | 2 +- lang/calamares_nl.ts | 16 ++++++++-------- lang/calamares_zh_CN.ts | 30 +++++++++++++++--------------- 7 files changed, 31 insertions(+), 31 deletions(-) diff --git a/lang/calamares_da.ts b/lang/calamares_da.ts index 7cfef1875..c69150583 100644 --- a/lang/calamares_da.ts +++ b/lang/calamares_da.ts @@ -1693,7 +1693,7 @@ Installationsprogrammet vil stoppe og alle ændringer vil gå tabt. The partition table on %1 already has %2 primary partitions, and no more can be added. Please remove one primary partition and add an extended partition, instead. - Partitionstabellen på %1 har allerede %2 primære partitioner, og der kan ikke tilføjes flere. Fjern venligst en primær partition og tilføj i stedet en udviddet partition. + Partitionstabellen på %1 har allerede %2 primære partitioner, og der kan ikke tilføjes flere. Fjern venligst en primær partition og tilføj i stedet en udvidet partition. diff --git a/lang/calamares_fr.ts b/lang/calamares_fr.ts index 572a4b1df..26062f604 100644 --- a/lang/calamares_fr.ts +++ b/lang/calamares_fr.ts @@ -4,7 +4,7 @@ The <strong>boot environment</strong> of this system.<br><br>Older x86 systems only support <strong>BIOS</strong>.<br>Modern systems usually use <strong>EFI</strong>, but may also show up as BIOS if started in compatibility mode. - L'<strong>environnement de démarrage</strong> de ce système.<br><br>Les anciens systèmes x86 supportent uniquement le <strong>BIOS</strong>.<br>Les systèmes récents utilisent habituellement <strong>EFI</strong>, mais peuvent également afficher BIOS s'ils sont démarrés en mode de compatibilité. + L'<strong>environnement de démarrage</strong> de ce système.<br><br>Les anciens systèmes x86 supportent uniquement <strong>BIOS</strong>.<br>Les systèmes récents utilisent habituellement <strong>EFI</strong>, mais peuvent également afficher BIOS s'ils sont démarrés en mode de compatibilité. diff --git a/lang/calamares_he.ts b/lang/calamares_he.ts index fed3a48f4..cdceb60de 100644 --- a/lang/calamares_he.ts +++ b/lang/calamares_he.ts @@ -521,7 +521,7 @@ The installer will quit and all changes will be lost. Contextual Processes Job - + משימת תהליכי הקשר @@ -2358,7 +2358,7 @@ Output: Shell Processes Job - + משימת תהליכי מעטפת diff --git a/lang/calamares_hu.ts b/lang/calamares_hu.ts index 20ffbb815..75f3457b8 100644 --- a/lang/calamares_hu.ts +++ b/lang/calamares_hu.ts @@ -207,7 +207,7 @@ &Install - + &Telepítés @@ -229,7 +229,7 @@ Minden változtatás elveszik, ha kilépsz a telepítőből. &No - @Nem + &Nem @@ -944,7 +944,7 @@ Telepítés nem folytatható. <a href="#details">Részletek...&l &Restart now - $Újraindítás most + Új&raindítás most diff --git a/lang/calamares_lt.ts b/lang/calamares_lt.ts index 12d53ba11..33191566b 100644 --- a/lang/calamares_lt.ts +++ b/lang/calamares_lt.ts @@ -244,7 +244,7 @@ Diegimo programa užbaigs darbą ir visi pakeitimai bus prarasti. The %1 installer is about to make changes to your disk in order to install %2.<br/><strong>You will not be able to undo these changes.</strong> - %1 diegimo programa, siekdama įdiegti %2, ketina atlikti pakeitimus diske.<br/><strong>Šių pakeitimų atšaukti nebegalėsite.</strong> + %1 diegimo programa, siekdama įdiegti %2, ketina atlikti pakeitimus diske.<br/><strong>Šių pakeitimų nebegalėsite atšaukti.</strong> diff --git a/lang/calamares_nl.ts b/lang/calamares_nl.ts index d20d75630..d1c1a62cc 100644 --- a/lang/calamares_nl.ts +++ b/lang/calamares_nl.ts @@ -50,7 +50,7 @@ Blank Page - + Lege pagina @@ -192,7 +192,7 @@ Calamares Initialization Failed - + Calamares Initialisatie mislukt @@ -202,7 +202,7 @@ <br/>The following modules could not be loaded: - + <br/>The volgende modules konden niet worden geladen: @@ -1244,7 +1244,7 @@ Het installatieprogramma zal afsluiten en alle wijzigingen zullen verloren gaan. Password is too weak - + Wachtwoord is te zwak @@ -1259,12 +1259,12 @@ Het installatieprogramma zal afsluiten en alle wijzigingen zullen verloren gaan. The password is the same as the old one - + Het wachtwoord is hetzelfde als het oude wachtwoord The password is a palindrome - + Het wachtwoord is een palindroom @@ -1274,12 +1274,12 @@ Het installatieprogramma zal afsluiten en alle wijzigingen zullen verloren gaan. The password is too similar to the old one - + Het wachtwoord lijkt te veel op het oude wachtwoord The password contains the user name in some form - + Het wachtwoord bevat de gebruikersnaam op een of andere manier diff --git a/lang/calamares_zh_CN.ts b/lang/calamares_zh_CN.ts index 4889eabf1..b69c5f63c 100644 --- a/lang/calamares_zh_CN.ts +++ b/lang/calamares_zh_CN.ts @@ -9,7 +9,7 @@ This system was started with an <strong>EFI</strong> boot environment.<br><br>To configure startup from an EFI environment, this installer must deploy a boot loader application, like <strong>GRUB</strong> or <strong>systemd-boot</strong> on an <strong>EFI System Partition</strong>. This is automatic, unless you choose manual partitioning, in which case you must choose it or create it on your own. - 这个系统从 <strong>EFI</strong> 引导环境启动。<br><br>目前市面上大多数的民用设备都使用 EFI,并同时与之使用 GPT 分区表。<br>要从 EFI 环境引导的话,本安装程序必须部署一个引导器(如 <strong>GRUB</strong> 或 <strong>systemd-boot</strong>)到 <strong>EFI 系统分区</strong>。这个步骤是自动的,除非您选择手动分区——此时您必须自行选择或创建。 + 这个系统是从 <strong>EFI</strong> 引导环境启动的。<br><br>目前市面上大多数的民用设备都使用 EFI,并同时对硬盘使用 GPT 分区表分区。<br>您如果要从 EFI 环境引导这个系统的话,本安装程序必须安装一个引导器(如 <strong>GRUB</strong> 或 <strong>systemd-boot</strong>)到 <strong>EFI 分区</strong>。这个步骤将会由本安装程序自动执行,除非您选择自己创建分区——此时您必须选择让本安装程序自动创建EFI分区或您自己手动创建EFI分区。 @@ -51,7 +51,7 @@ Blank Page - + 空白页 @@ -193,17 +193,17 @@ Calamares Initialization Failed - + Calamares安装失败 %1 can not be installed. Calamares was unable to load all of the configured modules. This is a problem with the way Calamares is being used by the distribution. - + %1无法安装。 Calamares无法加载所有已配置的模块。这是分配使用Calamares的方式的问题。 <br/>The following modules could not be loaded: - + <br/>无法加载以下模块: @@ -265,7 +265,7 @@ The installer will quit and all changes will be lost. The installation is complete. Close the installer. - 安装过程已完毕。请关闭安装器。 + 安装已完成。请关闭安装程序。 @@ -334,7 +334,7 @@ The installer will quit and all changes will be lost. For best results, please ensure that this computer: - 为了更好的体验,请确定这台电脑: + 为了更好的体验,请确保这台电脑: @@ -509,12 +509,12 @@ The installer will quit and all changes will be lost. The command runs in the host environment and needs to know the root path, but no rootMountPoint is defined. - + 该命令在主机环境中运行,且需要知道根路径,但没有定义root挂载点。 The command needs to know the user's name, but no username is defined. - + 命令行需要知道用户的名字,但用户名没有被设置 @@ -1665,7 +1665,7 @@ The installer will quit and all changes will be lost. Cre&ate - + 创建 @@ -1690,12 +1690,12 @@ The installer will quit and all changes will be lost. Can not create new partition - + 无法创建新分区 The partition table on %1 already has %2 primary partitions, and no more can be added. Please remove one primary partition and add an extended partition, instead. - + %1上的分区表已经有%2个主分区,并且不能再添加。请删除一个主分区并添加扩展分区。 @@ -1841,17 +1841,17 @@ The installer will quit and all changes will be lost. Saving files for later ... - + 保存文件以供日后使用 No files configured to save for later. - + 没有已保存且供日后使用的配置文件。 Not all of the configured files could be preserved. - + 并不是所有配置文件都可以被保留 From dfae4a76375de93e6f7b8c9345446debee92463b Mon Sep 17 00:00:00 2001 From: Calamares CI Date: Fri, 5 Oct 2018 07:36:39 -0400 Subject: [PATCH 55/70] i18n: [desktop] Automatic merge of Transifex translations --- calamares.desktop | 154 +++++++++++++++++++++++----------------------- 1 file changed, 77 insertions(+), 77 deletions(-) diff --git a/calamares.desktop b/calamares.desktop index 3cdce6888..46b2e979f 100644 --- a/calamares.desktop +++ b/calamares.desktop @@ -14,165 +14,165 @@ Categories=Qt;System; X-AppStream-Ignore=true Name[ar]=نظام التثبيت -Icon[be]=calamares -GenericName[be]=Усталёўшчык сістэмы Comment[be]=Calamares — усталёўшчык сістэмы +Icon[be]=calamares Name[be]=Усталяваць сістэму -Icon[bg]=calamares -GenericName[bg]=Системен Инсталатор +GenericName[be]=Усталёўшчык сістэмы Comment[bg]=Calamares — Системен Инсталатор +Icon[bg]=calamares Name[bg]=Инсталирай системата -Icon[ca]=calamares -GenericName[ca]=Instal·lador de sistema +GenericName[bg]=Системен Инсталатор Comment[ca]=Calamares — Instal·lador de sistema +Icon[ca]=calamares Name[ca]=Instal·la el sistema -Icon[da]=calamares -GenericName[da]=Systeminstallationsprogram +GenericName[ca]=Instal·lador de sistema Comment[da]=Calamares — Systeminstallationsprogram +Icon[da]=calamares Name[da]=Installér system -Icon[de]=calamares -GenericName[de]=Installation des Betriebssystems +GenericName[da]=Systeminstallationsprogram Comment[de]=Calamares - Installation des Betriebssystems +Icon[de]=calamares Name[de]=System installieren -Icon[el]=calamares -GenericName[el]=Εγκατάσταση συστήματος +GenericName[de]=Installation des Betriebssystems Comment[el]=Calamares — Εγκατάσταση συστήματος +Icon[el]=calamares Name[el]=Εγκατάσταση συστήματος -Icon[en_GB]=calamares -GenericName[en_GB]=System Installer +GenericName[el]=Εγκατάσταση συστήματος Comment[en_GB]=Calamares — System Installer +Icon[en_GB]=calamares Name[en_GB]=Install System -Icon[es]=calamares -GenericName[es]=Instalador del Sistema +GenericName[en_GB]=System Installer Comment[es]=Calamares — Instalador del Sistema +Icon[es]=calamares Name[es]=Instalar Sistema -Icon[et]=calamares -GenericName[et]=Süsteemipaigaldaja +GenericName[es]=Instalador del Sistema Comment[et]=Calamares — süsteemipaigaldaja +Icon[et]=calamares Name[et]=Paigalda süsteem +GenericName[et]=Süsteemipaigaldaja Name[eu]=Sistema instalatu Name[es_PR]=Instalar el sistema -Icon[fr]=calamares -GenericName[fr]=Installateur système Comment[fr]=Calamares - Installateur système +Icon[fr]=calamares Name[fr]=Installer le système +GenericName[fr]=Installateur système Name[gl]=Instalación do Sistema -Icon[he]=calamares -GenericName[he]=אשף התקנה Comment[he]=Calamares - אשף התקנה +Icon[he]=calamares Name[he]=התקנת מערכת -Icon[hi]=calamares -GenericName[hi]=सिस्टम इंस्टॉलर +GenericName[he]=אשף התקנה Comment[hi]=Calamares — सिस्टम इंस्टॉलर +Icon[hi]=calamares Name[hi]=सिस्टम इंस्टॉल करें -Icon[hr]=calamares -GenericName[hr]=Instalacija sustava +GenericName[hi]=सिस्टम इंस्टॉलर Comment[hr]=Calamares — Instalacija sustava +Icon[hr]=calamares Name[hr]=Instaliraj sustav -Icon[hu]=calamares -GenericName[hu]=Rendszer Telepítő +GenericName[hr]=Instalacija sustava Comment[hu]=Calamares — Rendszer Telepítő +Icon[hu]=calamares Name[hu]=Rendszer telepítése -Icon[id]=calamares -GenericName[id]=Pemasang +GenericName[hu]=Rendszer Telepítő Comment[id]=Calamares — Pemasang Sistem +Icon[id]=calamares Name[id]=Instal Sistem -Icon[is]=calamares -GenericName[is]=Kerfis uppsetning +GenericName[id]=Pemasang Comment[is]=Calamares — Kerfis uppsetning +Icon[is]=calamares Name[is]=Setja upp kerfið -Icon[cs_CZ]=calamares -GenericName[cs_CZ]=Instalátor systému +GenericName[is]=Kerfis uppsetning Comment[cs_CZ]=Calamares – instalátor operačních systémů +Icon[cs_CZ]=calamares Name[cs_CZ]=Nainstalovat -Icon[ja]=calamares -GenericName[ja]=システムインストーラー +GenericName[cs_CZ]=Instalátor systému Comment[ja]=Calamares — システムインストーラー +Icon[ja]=calamares Name[ja]=システムをインストール -Icon[ko]=깔라마레스 -GenericName[ko]=시스템 설치 관리자 +GenericName[ja]=システムインストーラー Comment[ko]=깔라마레스 — 시스템 설치 관리자 +Icon[ko]=깔라마레스 Name[ko]=시스템 설치 -Icon[lt]=calamares -GenericName[lt]=Sistemos diegimas į kompiuterį +GenericName[ko]=시스템 설치 관리자 Comment[lt]=Calamares — Sistemos diegimo programa +Icon[lt]=calamares Name[lt]=Įdiegti Sistemą -Icon[it_IT]=calamares -GenericName[it_IT]=Programma d'installazione del sistema +GenericName[lt]=Sistemos diegimas į kompiuterį Comment[it_IT]=Calamares — Programma d'installazione del sistema +Icon[it_IT]=calamares Name[it_IT]=Installa il sistema -Icon[nb]=calamares -GenericName[nb]=Systeminstallatør +GenericName[it_IT]=Programma d'installazione del sistema Comment[nb]=Calamares-systeminstallatør +Icon[nb]=calamares Name[nb]=Installer System -Icon[nl]=calamares -GenericName[nl]=Installatieprogramma +GenericName[nb]=Systeminstallatør Comment[nl]=Calamares — Installatieprogramma +Icon[nl]=calamares Name[nl]=Installeer systeem -Icon[pl]=calamares -GenericName[pl]=Instalator systemu +GenericName[nl]=Installatieprogramma Comment[pl]=Calamares — Instalator systemu +Icon[pl]=calamares Name[pl]=Zainstaluj system -Icon[pt_BR]=calamares -GenericName[pt_BR]=Instalador de Sistema +GenericName[pl]=Instalator systemu Comment[pt_BR]=Calamares — Instalador de Sistema +Icon[pt_BR]=calamares Name[pt_BR]=Sistema de Instalação -Icon[ro]=calamares -GenericName[ro]=Instalator de sistem +GenericName[pt_BR]=Instalador de Sistema Comment[ro]=Calamares — Instalator de sistem +Icon[ro]=calamares Name[ro]=Instalează sistemul -Icon[ru]=calamares -GenericName[ru]=Установщик системы +GenericName[ro]=Instalator de sistem Comment[ru]=Calamares - Установщик системы +Icon[ru]=calamares Name[ru]=Установить систему -Icon[sk]=calamares -GenericName[sk]=Inštalátor systému +GenericName[ru]=Установщик системы Comment[sk]=Calamares — Inštalátor systému +Icon[sk]=calamares Name[sk]=Inštalovať systém +GenericName[sk]=Inštalátor systému Name[sl]=Namesti sistem -Icon[sq]=calamares -GenericName[sq]=Instalues Sistemi Comment[sq]=Calamares — Instalues Sistemi +Icon[sq]=calamares Name[sq]=Instalo Sistemin -Icon[fi_FI]=calamares -GenericName[fi_FI]=Järjestelmän Asennusohjelma +GenericName[sq]=Instalues Sistemi Comment[fi_FI]=Calamares — Järjestelmän Asentaja +Icon[fi_FI]=calamares Name[fi_FI]=Asenna Järjestelmä +GenericName[fi_FI]=Järjestelmän Asennusohjelma Name[sr@latin]=Instaliraj sistem Name[sr]=Инсталирај систем -Icon[sv]=calamares -GenericName[sv]=Systeminstallerare Comment[sv]=Calamares — Systeminstallerare +Icon[sv]=calamares Name[sv]=Installera system +GenericName[sv]=Systeminstallerare Name[th]=ติดตั้งระบบ -GenericName[uk]=Встановлювач системи Comment[uk]=Calamares - Встановлювач системи Name[uk]=Встановити Систему -Icon[zh_CN]=calamares -GenericName[zh_CN]=系统安装程序 +GenericName[uk]=Встановлювач системи Comment[zh_CN]=Calamares — 系统安装程序 +Icon[zh_CN]=calamares Name[zh_CN]=安装系统 -Icon[zh_TW]=calamares -GenericName[zh_TW]=系統安裝程式 +GenericName[zh_CN]=系统安装程序 Comment[zh_TW]=Calamares ── 系統安裝程式 +Icon[zh_TW]=calamares Name[zh_TW]=安裝系統 -Icon[ast]=calamares -GenericName[ast]=Instalador del sistema +GenericName[zh_TW]=系統安裝程式 Comment[ast]=Calamares — Instalador del sistema +Icon[ast]=calamares Name[ast]=Instalar sistema -Icon[eo]=calamares -GenericName[eo]=Sistema Instalilo +GenericName[ast]=Instalador del sistema Comment[eo]=Calamares — Sistema Instalilo +Icon[eo]=calamares Name[eo]=Instali Sistemo -Icon[es_MX]=calamares -GenericName[es_MX]=Instalador del sistema +GenericName[eo]=Sistema Instalilo Comment[es_MX]=Calamares - Instalador del sistema +Icon[es_MX]=calamares Name[es_MX]=Instalar el Sistema -Icon[pt_PT]=calamares -GenericName[pt_PT]=Instalador de Sistema +GenericName[es_MX]=Instalador del sistema Comment[pt_PT]=Calamares - Instalador de Sistema +Icon[pt_PT]=calamares Name[pt_PT]=Instalar Sistema -Icon[tr_TR]=calamares -GenericName[tr_TR]=Sistem Yükleyici +GenericName[pt_PT]=Instalador de Sistema Comment[tr_TR]=Calamares — Sistem Yükleyici +Icon[tr_TR]=calamares Name[tr_TR]=Sistemi Yükle +GenericName[tr_TR]=Sistem Yükleyici From 36161461e2c2fdef1611e9907a41a98968d64a4a Mon Sep 17 00:00:00 2001 From: Calamares CI Date: Fri, 5 Oct 2018 07:36:40 -0400 Subject: [PATCH 56/70] i18n: [dummypythonqt] Automatic merge of Transifex translations --- .../lang/zh_CN/LC_MESSAGES/dummypythonqt.mo | Bin 957 -> 945 bytes .../lang/zh_CN/LC_MESSAGES/dummypythonqt.po | 6 +++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/dummypythonqt/lang/zh_CN/LC_MESSAGES/dummypythonqt.mo b/src/modules/dummypythonqt/lang/zh_CN/LC_MESSAGES/dummypythonqt.mo index 0dac94ca0b57858d43b1639d8f17249e3c21cae4..240d5c4dbabee9bc5843ed7f46132688159761ad 100644 GIT binary patch delta 125 zcmdnXzL9-Gi0N`h28IM67G+>y;9zE8&;ZhMK$;&&y8~%yARP|n7XxWsAisHIrv@XB zg|2~_uAzm3fw`5*B;$d=?YGXnF=;pscC6RiJ1, 2017\n" +"Last-Translator: soenggam , 2017\n" "Language-Team: Chinese (China) (https://www.transifex.com/calamares/teams/20061/zh_CN/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -24,7 +24,7 @@ msgstr "按我按我!" #: src/modules/dummypythonqt/main.py:94 msgid "A new QLabel." -msgstr "一个平淡无奇的 QLabel。" +msgstr "一个新的QLabel。" #: src/modules/dummypythonqt/main.py:97 msgid "Dummy PythonQt ViewStep" From 0e7f97fe491f45be5f3fb2eb971a992922a34945 Mon Sep 17 00:00:00 2001 From: Calamares CI Date: Fri, 5 Oct 2018 07:36:40 -0400 Subject: [PATCH 57/70] i18n: [python] Automatic merge of Transifex translations --- lang/python/hu/LC_MESSAGES/python.mo | Bin 844 -> 1196 bytes lang/python/hu/LC_MESSAGES/python.po | 12 ++++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lang/python/hu/LC_MESSAGES/python.mo b/lang/python/hu/LC_MESSAGES/python.mo index 94e29ac49162babdd3eaa340eac2199459720694..4cb87d96aeadff36f295cb60d2906b2f856c1f5e 100644 GIT binary patch delta 532 zcmZXOO-lkn7{_PROb-RULQpgXmA$Z86a|IUA){Lf-69y=X)$MKWoH!>qA$=Pk*>iW zJVbWt6U1IU2Hm30b?XcC-_($N;Ky&~ng2X9jYvIq^)?i~C8!vf00!s>br94$7z7_+ z1bnv~)tdcDcpbeJcnLP(1bhRJ!q0FGynFCeK zWx-l7DqowaG`H+xSN5;lO17scot#L^E=ZT2X9cIKq+D((y*i`a&FvXZmN7{UP7fU0 zcIl28Xg6nY-FD36GF?loZap=$V{LxlEYXazEoM@e3!e8MUH@L;m+c3eht+{l^0Xt% mh3k7oTLf`WvHx+}b)NFQ3*m5Ss4{nWjtXA%J;7ADb^iyRp@oqE delta 204 zcmZ3(d4{e2o)F7a1|VPqVi_Rz0b*_-t^r~YSOLU>K)e!&MSyrWl)eC@LE=w=SR07H z193Ma1A{UU3j^8fnHU%(f%IV@tpTL(0%|cz{I;jlT#RVCSPZq%afa#U20*XqhMrUXuf$CQy}AHMHYPk&axP5 diff --git a/lang/python/hu/LC_MESSAGES/python.po b/lang/python/hu/LC_MESSAGES/python.po index 286e27b3b..e2b46349c 100644 --- a/lang/python/hu/LC_MESSAGES/python.po +++ b/lang/python/hu/LC_MESSAGES/python.po @@ -10,7 +10,7 @@ msgstr "" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2018-06-18 07:46-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: miku84, 2017\n" +"Last-Translator: Adriaan de Groot , 2018\n" "Language-Team: Hungarian (https://www.transifex.com/calamares/teams/20061/hu/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -20,7 +20,7 @@ msgstr "" #: src/modules/umount/main.py:40 msgid "Unmount file systems." -msgstr "" +msgstr "Fájlrendszerek leválasztása." #: src/modules/dummypython/main.py:44 msgid "Dummy python job." @@ -47,12 +47,12 @@ msgstr "Csomagok telepítése." #, python-format msgid "Installing one package." msgid_plural "Installing %(num)d packages." -msgstr[0] "" -msgstr[1] "" +msgstr[0] "Egy csomag telepítése." +msgstr[1] "%(num)d csomag telepítése." #: src/modules/packages/main.py:70 #, python-format msgid "Removing one package." msgid_plural "Removing %(num)d packages." -msgstr[0] "" -msgstr[1] "" +msgstr[0] "Egy csomag eltávolítása." +msgstr[1] "%(num)d csomag eltávolítása." From a33b0c4f24d9b798a4a9ba10148c2d3b3ffefa9b Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 5 Oct 2018 07:45:05 -0400 Subject: [PATCH 58/70] [partition] Log the flags that are used to create a partition --- src/modules/partition/jobs/SetPartitionFlagsJob.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/modules/partition/jobs/SetPartitionFlagsJob.cpp b/src/modules/partition/jobs/SetPartitionFlagsJob.cpp index 7f6169bbe..fee987479 100644 --- a/src/modules/partition/jobs/SetPartitionFlagsJob.cpp +++ b/src/modules/partition/jobs/SetPartitionFlagsJob.cpp @@ -132,6 +132,10 @@ SetPartFlagsJob::prettyStatusMessage() const Calamares::JobResult SetPartFlagsJob::exec() { + cDebug() << "Setting flags on" << m_device->deviceNode() + << "partition" << partition()->deviceNode() + << "to" << m_flags; + Report report ( nullptr ); SetPartFlagsOperation op( *m_device, *partition(), m_flags ); op.setStatus( Operation::StatusRunning ); From 7515386cf87fa625b4c9e0f157e8e6a2eb1b125f Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 5 Oct 2018 09:19:25 -0400 Subject: [PATCH 59/70] CMake: clean up test setup - Remove redundant searches for ECM and Qt::Test, move them to top-level. --- CMakeLists.txt | 5 ++++ src/modules/contextualprocess/CMakeLists.txt | 5 +--- src/modules/fsresizer/CMakeLists.txt | 5 +--- src/modules/locale/CMakeLists.txt | 6 ----- src/modules/partition/tests/CMakeLists.txt | 24 ++++++++++---------- src/modules/shellprocess/CMakeLists.txt | 5 +--- src/modules/users/CMakeLists.txt | 9 ++------ 7 files changed, 22 insertions(+), 37 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f241cedd0..4fb88420b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -237,6 +237,11 @@ set_package_properties( find_package(ECM ${ECM_VERSION} NO_MODULE) if( ECM_FOUND ) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} ${CMAKE_MODULE_PATH}) + if ( BUILD_TESTING ) + # ECM implies that we can build the tests, too + find_package( Qt5 COMPONENTS Test REQUIRED ) + include( ECMAddTests ) + endif() endif() find_package( KF5 COMPONENTS CoreAddons Crash ) diff --git a/src/modules/contextualprocess/CMakeLists.txt b/src/modules/contextualprocess/CMakeLists.txt index 2cf8d3879..f75946b58 100644 --- a/src/modules/contextualprocess/CMakeLists.txt +++ b/src/modules/contextualprocess/CMakeLists.txt @@ -8,10 +8,7 @@ calamares_add_plugin( contextualprocess SHARED_LIB ) -if( ECM_FOUND ) - find_package( Qt5 COMPONENTS Test REQUIRED ) - include( ECMAddTests ) - +if( ECM_FOUND AND BUILD_TESTING ) ecm_add_test( Tests.cpp ContextualProcessJob.cpp # Builds it a second time diff --git a/src/modules/fsresizer/CMakeLists.txt b/src/modules/fsresizer/CMakeLists.txt index 5de329cad..e339b2799 100644 --- a/src/modules/fsresizer/CMakeLists.txt +++ b/src/modules/fsresizer/CMakeLists.txt @@ -20,10 +20,7 @@ if ( KPMcore_FOUND ) SHARED_LIB ) - if( ECM_FOUND ) - find_package( Qt5 COMPONENTS Test REQUIRED ) - include( ECMAddTests ) - + if( ECM_FOUND AND BUILD_TESTING ) ecm_add_test( Tests.cpp TEST_NAME diff --git a/src/modules/locale/CMakeLists.txt b/src/modules/locale/CMakeLists.txt index 24259d797..576f2e16e 100644 --- a/src/modules/locale/CMakeLists.txt +++ b/src/modules/locale/CMakeLists.txt @@ -1,9 +1,3 @@ -find_package(ECM ${ECM_VERSION} NO_MODULE) -if( ECM_FOUND AND BUILD_TESTING ) - include( ECMAddTests ) - find_package( Qt5 COMPONENTS Core Test REQUIRED ) -endif() - # When debugging the timezone widget, add this debugging definition # to have a debugging-friendly timezone widget, debug logging, # and no intrusive timezone-setting while clicking around. diff --git a/src/modules/partition/tests/CMakeLists.txt b/src/modules/partition/tests/CMakeLists.txt index 68474287e..7b40c34a5 100644 --- a/src/modules/partition/tests/CMakeLists.txt +++ b/src/modules/partition/tests/CMakeLists.txt @@ -1,6 +1,4 @@ -find_package( Qt5 COMPONENTS Gui Test REQUIRED ) - -include( ECMAddTests ) +find_package( Qt5 COMPONENTS Gui REQUIRED ) set( PartitionModule_SOURCE_DIR .. ) @@ -23,13 +21,15 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR} ) -ecm_add_test( ${partitionjobtests_SRCS} - TEST_NAME partitionjobtests - LINK_LIBRARIES - ${CALAMARES_LIBRARIES} - kpmcore - Qt5::Core - Qt5::Test -) +if( ECM_FOUND AND BUILD_TESTING ) + ecm_add_test( ${partitionjobtests_SRCS} + TEST_NAME partitionjobtests + LINK_LIBRARIES + ${CALAMARES_LIBRARIES} + kpmcore + Qt5::Core + Qt5::Test + ) -set_target_properties( partitionjobtests PROPERTIES AUTOMOC TRUE ) + set_target_properties( partitionjobtests PROPERTIES AUTOMOC TRUE ) +endif() diff --git a/src/modules/shellprocess/CMakeLists.txt b/src/modules/shellprocess/CMakeLists.txt index 51d4c4a4c..82ae8b911 100644 --- a/src/modules/shellprocess/CMakeLists.txt +++ b/src/modules/shellprocess/CMakeLists.txt @@ -8,10 +8,7 @@ calamares_add_plugin( shellprocess SHARED_LIB ) -if( ECM_FOUND ) - find_package( Qt5 COMPONENTS Test REQUIRED ) - include( ECMAddTests ) - +if( ECM_FOUND AND BUILD_TESTING ) ecm_add_test( Tests.cpp TEST_NAME diff --git a/src/modules/users/CMakeLists.txt b/src/modules/users/CMakeLists.txt index 16e235fd5..207ffbb3a 100644 --- a/src/modules/users/CMakeLists.txt +++ b/src/modules/users/CMakeLists.txt @@ -1,9 +1,4 @@ -find_package(ECM ${ECM_VERSION} NO_MODULE) -if( ECM_FOUND ) - include( ECMAddTests ) -endif() - -find_package( Qt5 COMPONENTS Core Test REQUIRED ) +find_package( Qt5 COMPONENTS Core REQUIRED ) find_package( Crypt REQUIRED ) # Add optional libraries here @@ -44,7 +39,7 @@ calamares_add_plugin( users SHARED_LIB ) -if( ECM_FOUND ) +if( ECM_FOUND AND BUILD_TESTING ) ecm_add_test( PasswordTests.cpp SetPasswordJob.cpp From 0b1c969a809f38283320643b3d066ca9fe56890d Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 5 Oct 2018 08:43:57 -0400 Subject: [PATCH 60/70] [libcalamares] Allow querying debug settings --- src/libcalamares/utils/Logger.cpp | 12 ++++++++++++ src/libcalamares/utils/Logger.h | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/src/libcalamares/utils/Logger.cpp b/src/libcalamares/utils/Logger.cpp index 735414b85..98aa2121f 100644 --- a/src/libcalamares/utils/Logger.cpp +++ b/src/libcalamares/utils/Logger.cpp @@ -55,6 +55,18 @@ setupLogLevel(unsigned int level) s_threshold = level + 1; // Comparison is < in log() function } +bool +logLevelEnabled(unsigned int level) +{ + return level < s_threshold; +} + +unsigned int +logLevel() +{ + return s_threshold > 0 ? s_threshold - 1 : 0; +} + static void log( const char* msg, unsigned int debugLevel, bool toDisk = true ) { diff --git a/src/libcalamares/utils/Logger.h b/src/libcalamares/utils/Logger.h index dba386eae..0cb4b494f 100644 --- a/src/libcalamares/utils/Logger.h +++ b/src/libcalamares/utils/Logger.h @@ -89,6 +89,12 @@ namespace Logger */ DLLEXPORT void setupLogLevel( unsigned int level ); + /** @brief Return the configured log-level. */ + DLLEXPORT unsigned int logLevel(); + + /** @brief Would the given @p level really be logged? */ + DLLEXPORT bool logLevelEnabled( unsigned int level ); + /** * @brief Row-oriented formatted logging. * From 5b936f33ecdecf1623b7499299d52069768d6a0d Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 5 Oct 2018 09:37:25 -0400 Subject: [PATCH 61/70] [libcalamares] Add tests - Test only the new debug-level query methods --- src/libcalamares/CMakeLists.txt | 13 ++++++++ src/libcalamares/Tests.cpp | 59 +++++++++++++++++++++++++++++++++ src/libcalamares/Tests.h | 36 ++++++++++++++++++++ 3 files changed, 108 insertions(+) create mode 100644 src/libcalamares/Tests.cpp create mode 100644 src/libcalamares/Tests.h diff --git a/src/libcalamares/CMakeLists.txt b/src/libcalamares/CMakeLists.txt index 598d3c313..4bf78176e 100644 --- a/src/libcalamares/CMakeLists.txt +++ b/src/libcalamares/CMakeLists.txt @@ -105,6 +105,19 @@ install( TARGETS calamares ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ) +if ( ECM_FOUND AND BUILD_TESTING ) + ecm_add_test( + Tests.cpp + TEST_NAME + libcalamarestest + LINK_LIBRARIES + calamares + Qt5::Core + Qt5::Test + ) + set_target_properties( libcalamarestest PROPERTIES AUTOMOC TRUE ) +endif() + # Make symlink lib/calamares/libcalamares.so to lib/libcalamares.so.VERSION so # lib/calamares can be used as module path for the Python interpreter. install( CODE " diff --git a/src/libcalamares/Tests.cpp b/src/libcalamares/Tests.cpp new file mode 100644 index 000000000..7595718e4 --- /dev/null +++ b/src/libcalamares/Tests.cpp @@ -0,0 +1,59 @@ +/* === This file is part of Calamares - === + * + * Copyright 2018, Adriaan de Groot + * + * 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 . + */ + +#include "Tests.h" + +#include "utils/Logger.h" + +#include + +QTEST_GUILESS_MAIN( LibCalamaresTests ) + +LibCalamaresTests::LibCalamaresTests() +{ +} + +LibCalamaresTests::~LibCalamaresTests() +{ +} + +void +LibCalamaresTests::initTestCase() +{ +} + +void +LibCalamaresTests::testDebugLevels() +{ + Logger::setupLogLevel( Logger::LOG_DISABLE ); + + QCOMPARE( Logger::logLevel(), Logger::LOG_DISABLE ); + + for ( unsigned int level = 0; level <= Logger::LOGVERBOSE ; ++level ) + { + Logger::setupLogLevel( level ); + QCOMPARE( Logger::logLevel(), level ); + QVERIFY( Logger::logLevelEnabled( level ) ); + + for ( unsigned int xlevel = 0; xlevel <= Logger::LOGVERBOSE; ++xlevel ) + { + QCOMPARE( Logger::logLevelEnabled( xlevel ), xlevel <= level ); + } + } +} + diff --git a/src/libcalamares/Tests.h b/src/libcalamares/Tests.h new file mode 100644 index 000000000..123655c6e --- /dev/null +++ b/src/libcalamares/Tests.h @@ -0,0 +1,36 @@ +/* === This file is part of Calamares - === + * + * Copyright 2018, Adriaan de Groot + * + * 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 . + */ + +#ifndef TESTS_H +#define TESTS_H + +#include + +class LibCalamaresTests : public QObject +{ + Q_OBJECT +public: + LibCalamaresTests(); + ~LibCalamaresTests() override; + +private Q_SLOTS: + void initTestCase(); + void testDebugLevels(); +}; + +#endif From 4757496c3d340bc94bf64629331f4bb89ca9e9c3 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 5 Oct 2018 07:59:44 -0400 Subject: [PATCH 62/70] [partition] Improve partition-UUID logging. --- .../partition/jobs/FillGlobalStorageJob.cpp | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/modules/partition/jobs/FillGlobalStorageJob.cpp b/src/modules/partition/jobs/FillGlobalStorageJob.cpp index 43a5f3904..597d62a82 100644 --- a/src/modules/partition/jobs/FillGlobalStorageJob.cpp +++ b/src/modules/partition/jobs/FillGlobalStorageJob.cpp @@ -56,9 +56,12 @@ findPartitionUuids( QList < Device* > devices ) QString path = p->partitionPath(); QString uuid = p->fileSystem().readUUID( p->partitionPath() ); hash.insert( path, uuid ); + cDebug() << ".. added path=" << path << "UUID=" << uuid; } } - cDebug() << hash; + + if ( hash.isEmpty() ) + cDebug() << ".. no UUIDs found."; return hash; } @@ -90,10 +93,16 @@ mapForPartition( Partition* partition, const QString& uuid ) dynamic_cast< FS::luks& >( partition->fileSystem() ).innerFS() ) map[ "fs" ] = dynamic_cast< FS::luks& >( partition->fileSystem() ).innerFS()->name(); map[ "uuid" ] = uuid; - cDebug() << partition->partitionPath() - << "mtpoint:" << PartitionInfo::mountPoint( partition ) - << "fs:" << map[ "fs" ] << '(' << map[ "fsName" ] << ')' - << uuid; + + // Debugging for inside the loop in createPartitionList(), + // so indent a bit + Logger::CLog deb = cDebug(); + using TR = Logger::DebugRow; + deb << " .. mapping for" << partition->partitionPath() << partition->deviceNode() + << TR( "mtpoint:", PartitionInfo::mountPoint( partition ) ) + << TR( "fs:", map[ "fs" ].toString() ) + << TR( "fsname", map[ "fsName" ].toString() ) + << TR( "uuid", uuid ); if ( partition->roles().has( PartitionRole::Luks ) ) { @@ -104,7 +113,7 @@ mapForPartition( Partition* partition, const QString& uuid ) map[ "luksMapperName" ] = luksFs->mapperName().split( "/" ).last(); map[ "luksUuid" ] = getLuksUuid( partition->partitionPath() ); map[ "luksPassphrase" ] = luksFs->passphrase(); - cDebug() << "luksMapperName:" << map[ "luksMapperName" ]; + deb << TR( "luksMapperName:", map[ "luksMapperName" ].toString() ); } } @@ -215,9 +224,11 @@ FillGlobalStorageJob::createPartitionList() const cDebug() << "Writing to GlobalStorage[\"partitions\"]"; for ( auto device : m_devices ) { + cDebug() << ".. partitions on" << device->deviceNode(); for ( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it ) { + // Debug-logging is done when creating the map lst << mapForPartition( *it, hash.value( ( *it )->partitionPath() ) ); } } From 02a6b7dd12ca03d4edb5a7af29437e3a7614125b Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 5 Oct 2018 08:23:01 -0400 Subject: [PATCH 63/70] [partition] Log the newly-created partition table - Log individual partitions instead of printing QObject() --- .../partition/jobs/CreatePartitionTableJob.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/modules/partition/jobs/CreatePartitionTableJob.cpp b/src/modules/partition/jobs/CreatePartitionTableJob.cpp index 2aec4a5fc..25bc79da6 100644 --- a/src/modules/partition/jobs/CreatePartitionTableJob.cpp +++ b/src/modules/partition/jobs/CreatePartitionTableJob.cpp @@ -20,6 +20,8 @@ #include "jobs/CreatePartitionTableJob.h" +#include "core/PartitionIterator.h" + #include "utils/Logger.h" // KPMcore @@ -65,6 +67,14 @@ CreatePartitionTableJob::prettyStatusMessage() const } +static inline QDebug& +operator <<( QDebug& s, PartitionIterator& it ) +{ + s << ( ( *it ) ? ( *it )->deviceNode() : QString( "" ) ); + return s; +} + + Calamares::JobResult CreatePartitionTableJob::exec() { @@ -73,7 +83,11 @@ CreatePartitionTableJob::exec() PartitionTable* table = m_device->partitionTable(); cDebug() << "Creating new partition table of type" << table->typeName() - << ", uncommitted yet:\n" << table; + << ", uncommitted yet:"; + + for ( auto it = PartitionIterator::begin( table ); + it != PartitionIterator::end( table ); ++it ) + cDebug() << *it; QProcess lsblk; lsblk.setProgram( "lsblk" ); From 74ab06e20a6238e0ee7a7d05422e4d81ddc5dc2c Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 5 Oct 2018 08:29:46 -0400 Subject: [PATCH 64/70] [partition] Drop redundant logging --- src/modules/partition/core/PartitionCoreModule.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/modules/partition/core/PartitionCoreModule.cpp b/src/modules/partition/core/PartitionCoreModule.cpp index b8011f066..f41142b6a 100644 --- a/src/modules/partition/core/PartitionCoreModule.cpp +++ b/src/modules/partition/core/PartitionCoreModule.cpp @@ -509,17 +509,8 @@ PartitionCoreModule::jobs() const lst << info->jobs; devices << info->device.data(); } - cDebug() << "Creating FillGlobalStorageJob with bootLoader path" << m_bootLoaderInstallPath; lst << Calamares::job_ptr( new FillGlobalStorageJob( devices, m_bootLoaderInstallPath ) ); - - QStringList jobsDebug; - foreach ( auto job, lst ) - jobsDebug.append( job->prettyName() ); - - cDebug() << "PartitionCodeModule has been asked for jobs. About to return:" - << jobsDebug.join( "\n" ); - return lst; } From bb586de056b076133efba37ea8f30832fcbc23aa Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 5 Oct 2018 08:45:10 -0400 Subject: [PATCH 65/70] [partition] Remove some slowdown methods when debugging is off - Running lsblk and mount for debugging purposes can be skipped when the debugging is going to be suppressed anyway. This will speed things up just a little for regular users. --- .../jobs/CreatePartitionTableJob.cpp | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/modules/partition/jobs/CreatePartitionTableJob.cpp b/src/modules/partition/jobs/CreatePartitionTableJob.cpp index 25bc79da6..937b8437d 100644 --- a/src/modules/partition/jobs/CreatePartitionTableJob.cpp +++ b/src/modules/partition/jobs/CreatePartitionTableJob.cpp @@ -85,23 +85,26 @@ CreatePartitionTableJob::exec() cDebug() << "Creating new partition table of type" << table->typeName() << ", uncommitted yet:"; - for ( auto it = PartitionIterator::begin( table ); - it != PartitionIterator::end( table ); ++it ) - cDebug() << *it; + if ( Logger::logLevelEnabled( Logger::LOGDEBUG ) ) + { + for ( auto it = PartitionIterator::begin( table ); + it != PartitionIterator::end( table ); ++it ) + cDebug() << *it; - QProcess lsblk; - lsblk.setProgram( "lsblk" ); - lsblk.setProcessChannelMode( QProcess::MergedChannels ); - lsblk.start(); - lsblk.waitForFinished(); - cDebug() << "lsblk:\n" << lsblk.readAllStandardOutput(); + QProcess lsblk; + lsblk.setProgram( "lsblk" ); + lsblk.setProcessChannelMode( QProcess::MergedChannels ); + lsblk.start(); + lsblk.waitForFinished(); + cDebug() << "lsblk:\n" << lsblk.readAllStandardOutput(); - QProcess mount; - mount.setProgram( "mount" ); - mount.setProcessChannelMode( QProcess::MergedChannels ); - mount.start(); - mount.waitForFinished(); - cDebug() << "mount:\n" << mount.readAllStandardOutput(); + QProcess mount; + mount.setProgram( "mount" ); + mount.setProcessChannelMode( QProcess::MergedChannels ); + mount.start(); + mount.waitForFinished(); + cDebug() << "mount:\n" << mount.readAllStandardOutput(); + } CreatePartitionTableOperation op(*m_device, table); op.setStatus(Operation::StatusRunning); From fc99824c8dd835a5fae6642dfe15c1ddbb02ce61 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 5 Oct 2018 17:22:12 +0200 Subject: [PATCH 66/70] [fsresizer] Fix string error, thanks Lithuanian translators --- src/modules/fsresizer/ResizeFSJob.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/fsresizer/ResizeFSJob.cpp b/src/modules/fsresizer/ResizeFSJob.cpp index 4320baba1..4df41a7d4 100644 --- a/src/modules/fsresizer/ResizeFSJob.cpp +++ b/src/modules/fsresizer/ResizeFSJob.cpp @@ -302,7 +302,7 @@ ResizeFSJob::exec() return Calamares::JobResult::error( tr( "Resize Failed" ), !m_fsname.isEmpty() ? tr( "The filesystem %1 must be resized, but cannot." ).arg( m_fsname ) - : tr( "The device %11 must be resized, but cannot" ).arg( m_fsname ) ); + : tr( "The device %1 must be resized, but cannot" ).arg( m_fsname ) ); return Calamares::JobResult::ok(); } From 4a2ca8bb77c15e90f24c520150e7ef60a00ba67c Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 8 Oct 2018 06:46:35 -0400 Subject: [PATCH 67/70] [libcalamares] Fix compilation of tests - QCOMPARE is picky with types, enum vs unsigned int, so just hit it with a hammer. --- src/libcalamares/Tests.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcalamares/Tests.cpp b/src/libcalamares/Tests.cpp index 7595718e4..acf5b03d3 100644 --- a/src/libcalamares/Tests.cpp +++ b/src/libcalamares/Tests.cpp @@ -42,7 +42,7 @@ LibCalamaresTests::testDebugLevels() { Logger::setupLogLevel( Logger::LOG_DISABLE ); - QCOMPARE( Logger::logLevel(), Logger::LOG_DISABLE ); + QCOMPARE( Logger::logLevel(), static_cast( Logger::LOG_DISABLE ) ); for ( unsigned int level = 0; level <= Logger::LOGVERBOSE ; ++level ) { From c489320af5fab068420a9dbb5cfecca7e4bc1a46 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 8 Oct 2018 06:44:31 -0400 Subject: [PATCH 68/70] [calamares] Add option to obey XDG dirs - Prep-work for #941 - This does nothing, yet, just sets the stage for using XDG_CONFIG_DIRS and XDG_DATA_DIRS as well as the regular directories. --- src/calamares/main.cpp | 5 ++++ src/libcalamares/utils/CalamaresUtils.cpp | 28 +++++++++++++++++++++++ src/libcalamares/utils/CalamaresUtils.h | 7 ++++++ 3 files changed, 40 insertions(+) diff --git a/src/calamares/main.cpp b/src/calamares/main.cpp index 9893e6792..f855b060f 100644 --- a/src/calamares/main.cpp +++ b/src/calamares/main.cpp @@ -44,6 +44,8 @@ handle_args( CalamaresApplication& a ) "Verbose output for debugging purposes (0-8).", "level" ); QCommandLineOption configOption( QStringList{ "c", "config"}, "Configuration directory to use, for testing purposes.", "config" ); + QCommandLineOption xdgOption( QStringList{"X", "xdg-config"}, + "Use XDG_{CONFIG,DATA}_DIRS as well." ); QCommandLineParser parser; parser.setApplicationDescription( "Distribution-independent installer framework" ); @@ -53,6 +55,7 @@ handle_args( CalamaresApplication& a ) parser.addOption( debugOption ); parser.addOption( debugLevelOption ); parser.addOption( configOption ); + parser.addOption( xdgOption ); parser.process( a ); @@ -72,6 +75,8 @@ handle_args( CalamaresApplication& a ) } if ( parser.isSet( configOption ) ) CalamaresUtils::setAppDataDir( QDir( parser.value( configOption ) ) ); + if ( parser.isSet( xdgOption ) ) + CalamaresUtils::setXdgDirs(); } int diff --git a/src/libcalamares/utils/CalamaresUtils.cpp b/src/libcalamares/utils/CalamaresUtils.cpp index 6a892511a..bd8d02d1d 100644 --- a/src/libcalamares/utils/CalamaresUtils.cpp +++ b/src/libcalamares/utils/CalamaresUtils.cpp @@ -49,6 +49,9 @@ static QTranslator* s_brandingTranslator = nullptr; static QTranslator* s_translator = nullptr; static QString s_translatorLocaleName; +static bool s_haveExtraDirs = false; +static QStringList s_extraConfigDirs; +static QStringList s_extraDataDirs; static bool isWritableDir( const QDir& dir ) @@ -94,6 +97,31 @@ setAppDataDir( const QDir& dir ) s_isAppDataDirOverridden = true; } +void +setXdgDirs() +{ + s_haveExtraDirs = true; + s_extraConfigDirs.append( QString( qgetenv( "XDG_CONFIG_DIRS" ) ).split(':') ); + s_extraDataDirs.append( QString( qgetenv( "XDG_DATA_DIRS" ) ).split(':') ); +} + +QStringList +extraConfigDirs() +{ + if ( s_haveExtraDirs ) + return s_extraConfigDirs; + return QStringList(); +} + +QStringList +extraDataDirs() +{ + if ( s_haveExtraDirs ) + return s_extraDataDirs; + return QStringList(); +} + + bool isAppDataDirOverridden() diff --git a/src/libcalamares/utils/CalamaresUtils.h b/src/libcalamares/utils/CalamaresUtils.h index e64fe4eec..78362b01c 100644 --- a/src/libcalamares/utils/CalamaresUtils.h +++ b/src/libcalamares/utils/CalamaresUtils.h @@ -79,6 +79,13 @@ namespace CalamaresUtils DLLEXPORT void setQmlModulesDir( const QDir& dir ); + /** @brief Setup extra config and data dirs from the XDG variables. + * + */ + DLLEXPORT void setXdgDirs(); + DLLEXPORT QStringList extraConfigDirs(); + DLLEXPORT QStringList extraDataDirs(); + /** * @brief removeDiacritics replaces letters with diacritics and ligatures with * alternative forms and digraphs. From 3b8d2835e037edc6269737e4f667da66c684b668 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 8 Oct 2018 10:28:30 -0400 Subject: [PATCH 69/70] [calamares] Use XDG_{DATA,CONFIG}_DIRS as appropriate - Use DATA for the qml and branding directories (looks for qml/ and branding// in those directories). - Use CONFIG for the global settings and module settings (looks for settings.conf and module// in those directories). FIXES #941 --- src/calamares/CalamaresApplication.cpp | 9 +++++++++ src/libcalamares/utils/CalamaresUtils.cpp | 21 ++++++++++++++++++--- src/libcalamares/utils/CalamaresUtils.h | 5 ++++- src/libcalamaresui/modulesystem/Module.cpp | 4 ++++ 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/src/calamares/CalamaresApplication.cpp b/src/calamares/CalamaresApplication.cpp index 018e2b677..0b715d6df 100644 --- a/src/calamares/CalamaresApplication.cpp +++ b/src/calamares/CalamaresApplication.cpp @@ -145,6 +145,9 @@ qmlDirCandidates( bool assumeBuilddir ) { if ( assumeBuilddir ) qmlDirs << QDir::current().absoluteFilePath( "src/qml" ); // In build-dir + if ( CalamaresUtils::haveExtraDirs() ) + for ( auto s : CalamaresUtils::extraDataDirs() ) + qmlDirs << ( s + QML ); qmlDirs << CalamaresUtils::appDataDir().absoluteFilePath( QML ); } @@ -164,6 +167,9 @@ settingsFileCandidates( bool assumeBuilddir ) { if ( assumeBuilddir ) settingsPaths << QDir::current().absoluteFilePath( settings ); + if ( CalamaresUtils::haveExtraDirs() ) + for ( auto s : CalamaresUtils::extraConfigDirs() ) + settingsPaths << ( s + settings ); settingsPaths << CMAKE_INSTALL_FULL_SYSCONFDIR "/calamares/settings.conf"; // String concat settingsPaths << CalamaresUtils::appDataDir().absoluteFilePath( settings ); } @@ -182,6 +188,9 @@ brandingFileCandidates( bool assumeBuilddir, const QString& brandingFilename ) { if ( assumeBuilddir ) brandingPaths << ( QDir::currentPath() + QStringLiteral( "/src/" ) + brandingFilename ); + if ( CalamaresUtils::haveExtraDirs() ) + for ( auto s : CalamaresUtils::extraDataDirs() ) + brandingPaths << ( s + brandingFilename ); brandingPaths << QDir( CMAKE_INSTALL_FULL_SYSCONFDIR "/calamares/" ).absoluteFilePath( brandingFilename ); brandingPaths << CalamaresUtils::appDataDir().absoluteFilePath( brandingFilename); } diff --git a/src/libcalamares/utils/CalamaresUtils.cpp b/src/libcalamares/utils/CalamaresUtils.cpp index bd8d02d1d..3ab758522 100644 --- a/src/libcalamares/utils/CalamaresUtils.cpp +++ b/src/libcalamares/utils/CalamaresUtils.cpp @@ -97,12 +97,23 @@ setAppDataDir( const QDir& dir ) s_isAppDataDirOverridden = true; } +/* Split $ENV{@p name} on :, append to @p l, making sure each ends in / */ +static void +mungeEnvironment( QStringList& l, const char *name ) +{ + for ( auto s : QString( qgetenv( name ) ).split(':') ) + if ( s.endsWith( '/' ) ) + l << s; + else + l << ( s + '/' ); +} + void setXdgDirs() { s_haveExtraDirs = true; - s_extraConfigDirs.append( QString( qgetenv( "XDG_CONFIG_DIRS" ) ).split(':') ); - s_extraDataDirs.append( QString( qgetenv( "XDG_DATA_DIRS" ) ).split(':') ); + mungeEnvironment( s_extraConfigDirs, "XDG_CONFIG_DIRS" ); + mungeEnvironment( s_extraDataDirs, "XDG_DATA_DIRS" ); } QStringList @@ -121,7 +132,11 @@ extraDataDirs() return QStringList(); } - +bool +haveExtraDirs() +{ + return s_haveExtraDirs && ( !s_extraConfigDirs.isEmpty() || !s_extraDataDirs.isEmpty() ); +} bool isAppDataDirOverridden() diff --git a/src/libcalamares/utils/CalamaresUtils.h b/src/libcalamares/utils/CalamaresUtils.h index 78362b01c..baf7a12dc 100644 --- a/src/libcalamares/utils/CalamaresUtils.h +++ b/src/libcalamares/utils/CalamaresUtils.h @@ -80,10 +80,13 @@ namespace CalamaresUtils DLLEXPORT void setQmlModulesDir( const QDir& dir ); /** @brief Setup extra config and data dirs from the XDG variables. - * */ DLLEXPORT void setXdgDirs(); + /** @brief Are any extra directories configured? */ + DLLEXPORT bool haveExtraDirs(); + /** @brief XDG_CONFIG_DIRS, each guaranteed to end with / */ DLLEXPORT QStringList extraConfigDirs(); + /** @brief XDG_DATA_DIRS, each guaranteed to end with / */ DLLEXPORT QStringList extraDataDirs(); /** diff --git a/src/libcalamaresui/modulesystem/Module.cpp b/src/libcalamaresui/modulesystem/Module.cpp index a1349c280..ef629ac4d 100644 --- a/src/libcalamaresui/modulesystem/Module.cpp +++ b/src/libcalamaresui/modulesystem/Module.cpp @@ -155,6 +155,10 @@ moduleConfigurationCandidates( bool assumeBuildDir, const QString& moduleName, c if ( assumeBuildDir && configFileName.contains( '/' ) ) paths << QDir().absoluteFilePath( configFileName ); + if ( CalamaresUtils::haveExtraDirs() ) + for ( auto s : CalamaresUtils::extraConfigDirs() ) + paths << ( s + QString( "modules/%1" ).arg( configFileName ) ); + paths << QString( "/etc/calamares/modules/%1" ).arg( configFileName ); paths << CalamaresUtils::appDataDir().absoluteFilePath( QString( "modules/%1" ).arg( configFileName ) ); } From 594618f2cc417cd42cfdf8a129b95c9e90e06dd9 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 8 Oct 2018 10:34:57 -0400 Subject: [PATCH 70/70] Changes: document -X option --- CHANGES | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 896a9fee2..7094f5866 100644 --- a/CHANGES +++ b/CHANGES @@ -14,7 +14,14 @@ This release contains contributions from (alphabetically by first name): ## Core ## -There are no core changes in this version. + * The Calamares application now recognizes the `-X` or `--xdg-config` + option, which adds XDG_DATA_DIRS to the places used to find QML + and branding directories, and XDG_CONFIG_DIRS to the places used + to find the global settings and module configurations. This allows + a more fine-grained, and more layered, approach to setting up + Calamares configurations (in particular, distro's can **add** + configuration files and give them priority, instead of **forking** + configuration files). ## Modules ##