Hello community,

here is the log from the commit of package calamares for openSUSE:Factory 
checked in at 2017-11-24 10:56:23
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/calamares (Old)
 and      /work/SRC/openSUSE:Factory/.calamares.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "calamares"

Fri Nov 24 10:56:23 2017 rev:3 rq:544956 version:3.1.8

Changes:
--------
--- /work/SRC/openSUSE:Factory/calamares/calamares.changes      2017-10-23 
16:53:49.587183516 +0200
+++ /work/SRC/openSUSE:Factory/.calamares.new/calamares.changes 2017-11-24 
10:56:25.460003445 +0100
@@ -1,0 +2,21 @@
+Thu Nov 23 18:13:32 UTC 2017 - [email protected]
+
+- Update to Calamares 3.1.8:
+  - Fix Netinstall crash if the returned netinstall-groups 
+    data was empty.
+  - Fix regression were GeoIP data had been read twice.
+  - Use more support code from KPMCore, instead of doing it 
+    ourselves.
+
+-------------------------------------------------------------------
+Thu Nov 23 18:12:14 UTC 2017 - [email protected]
+
+- Update to Calamares 3.1.7 fixes two regressions introduced 
+  earlier in the 3.1 series (3.1.5 or before):
+  - Netinstall was no longer compatible with the packages module, 
+    which prevented any users of netinstall from installing 
+    packages from online repositories.
+  - The bootloader installation for EFI systems used the wrong 
+    name for the bootx64.efi (or bootia32.efi) files.
+
+-------------------------------------------------------------------

Old:
----
  calamares-3.1.6.tar.gz

New:
----
  calamares-3.1.8.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ calamares.spec ++++++
--- /var/tmp/diff_new_pack.ItSMsq/_old  2017-11-24 10:56:26.959948665 +0100
+++ /var/tmp/diff_new_pack.ItSMsq/_new  2017-11-24 10:56:26.963948518 +0100
@@ -16,7 +16,7 @@
 
 %define _sover  3
 Name:           calamares
-Version:        3.1.6
+Version:        3.1.8
 Release:        0
 Summary:        Installer from a live CD/DVD/USB to disk
 Group:          System/Management

++++++ calamares-3.1.6.tar.gz -> calamares-3.1.8.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/calamares-3.1.6/CMakeLists.txt 
new/calamares-3.1.8/CMakeLists.txt
--- old/calamares-3.1.6/CMakeLists.txt  2017-10-13 21:45:37.000000000 +0200
+++ new/calamares-3.1.8/CMakeLists.txt  2017-11-14 16:18:58.000000000 +0100
@@ -166,7 +166,7 @@
 ### Bump version here
 set( CALAMARES_VERSION_MAJOR 3 )
 set( CALAMARES_VERSION_MINOR 1 )
-set( CALAMARES_VERSION_PATCH 6 )
+set( CALAMARES_VERSION_PATCH 8 )
 set( CALAMARES_VERSION_RC 0 )
 
 set( CALAMARES_VERSION 
${CALAMARES_VERSION_MAJOR}.${CALAMARES_VERSION_MINOR}.${CALAMARES_VERSION_PATCH}
 )
@@ -267,12 +267,9 @@
 endif()
 # Doesn't list mksquashfs as an optional dep, though, because it
 # hasn't been sent through the find_package() scheme.
-set_package_properties( mksquashfs PROPERTIES
-    DESCRIPTION "Create squashed filesystems"
-    URL "http://tldp.org/HOWTO/SquashFS-HOWTO/creatingandusing.html";
-    PURPOSE "Create example distro"
-    TYPE OPTIONAL
-)
+#
+# "http://tldp.org/HOWTO/SquashFS-HOWTO/creatingandusing.html";
+add_feature_info( ExampleDistro ${mksquashfs_FOUND} "Create example-distro 
target.")
 
 # add_subdirectory( thirdparty )
 add_subdirectory( src )
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/calamares-3.1.6/src/modules/bootloader/main.py 
new/calamares-3.1.8/src/modules/bootloader/main.py
--- old/calamares-3.1.6/src/modules/bootloader/main.py  2017-10-13 
21:45:37.000000000 +0200
+++ new/calamares-3.1.8/src/modules/bootloader/main.py  2017-11-14 
16:18:58.000000000 +0100
@@ -8,7 +8,7 @@
 #   Copyright 2014, Daniel Hillenbrand <[email protected]>
 #   Copyright 2014, Benjamin Vaudour <[email protected]>
 #   Copyright 2014, Kevin Kofler <[email protected]>
-#   Copyright 2015, Philip Mueller <[email protected]>
+#   Copyright 2015-2017, Philip Mueller <[email protected]>
 #   Copyright 2016-2017, Teo Mrnjavac <[email protected]>
 #   Copyright 2017, Alf Gaida <[email protected]>
 #   Copyright 2017, Adriaan de Groot <[email protected]>
@@ -266,7 +266,13 @@
                            "64": os.path.join(install_efi_directory_firmware,
                                               efi_bootloader_id,
                                               "grubx64.efi")}
-        shutil.copy2(efi_file_source[efi_bitness], install_efi_boot_directory)
+
+        efi_file_target = {"32": os.path.join(install_efi_boot_directory,
+                                              "bootia32.efi"),
+                           "64": os.path.join(install_efi_boot_directory,
+                                              "bootx64.efi")}
+
+        shutil.copy2(efi_file_source[efi_bitness], 
efi_file_target[efi_bitness])
     else:
         print("Bootloader: grub (bios)")
         if libcalamares.globalstorage.value("bootLoader") is None:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/calamares-3.1.6/src/modules/locale/LocaleViewStep.cpp 
new/calamares-3.1.8/src/modules/locale/LocaleViewStep.cpp
--- old/calamares-3.1.6/src/modules/locale/LocaleViewStep.cpp   2017-10-13 
21:45:37.000000000 +0200
+++ new/calamares-3.1.8/src/modules/locale/LocaleViewStep.cpp   2017-11-14 
16:18:58.000000000 +0100
@@ -120,7 +120,7 @@
 
             try
             {
-                YAML::Node doc = YAML::Load( reply->readAll() );
+                YAML::Node doc = YAML::Load( data );
 
                 QVariant var = CalamaresUtils::yamlToVariant( doc );
                 if ( !var.isNull() &&
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/calamares-3.1.6/src/modules/netinstall/NetInstallPage.cpp 
new/calamares-3.1.8/src/modules/netinstall/NetInstallPage.cpp
--- old/calamares-3.1.6/src/modules/netinstall/NetInstallPage.cpp       
2017-10-13 21:45:37.000000000 +0200
+++ new/calamares-3.1.8/src/modules/netinstall/NetInstallPage.cpp       
2017-11-14 16:18:58.000000000 +0100
@@ -3,6 +3,7 @@
  *   Copyright 2016, Lisa Vitolo     <[email protected]>
  *   Copyright 2017, Kyle Robbertze  <[email protected]>
  *   Copyright 2017, Adriaan de Groot <[email protected]>
+ *   Copyright 2017, Gabriel Craciunescu <[email protected]>
  *
  *   Calamares is free software: you can redistribute it and/or modify
  *   it under the terms of the GNU General Public License as published by
@@ -57,14 +58,6 @@
 }
 
 bool
-NetInstallPage::isReady()
-{
-    // nothing to wait for, the data are immediately ready
-    // if the user does not select any group nothing is installed
-    return true;
-}
-
-bool
 NetInstallPage::readGroups( const QByteArray& yamlData )
 {
     try
@@ -77,7 +70,7 @@
         m_groups = new PackageModel( groups );
         CALAMARES_RETRANSLATE(
             m_groups->setHeaderData( 0, Qt::Horizontal, tr( "Name" ) );
-            m_groups->setHeaderData( 0, Qt::Horizontal, tr( "Description" ) ); 
)
+            m_groups->setHeaderData( 1, Qt::Horizontal, tr( "Description" ) ); 
)
         return true;
 
     }
@@ -91,10 +84,13 @@
 void
 NetInstallPage::dataIsHere( QNetworkReply* reply )
 {
+    // If m_required is *false* then we still say we're ready
+    // even if the reply is corrupt or missing.
     if ( reply->error() != QNetworkReply::NoError )
     {
         cDebug() << reply->errorString();
         ui->netinst_status->setText( tr( "Network Installation. (Disabled: 
Unable to fetch package lists, check your network connection)" ) );
+        emit checkReady( !m_required );
         return;
     }
 
@@ -103,6 +99,7 @@
         cDebug() << "Netinstall groups data was received, but invalid.";
         ui->netinst_status->setText( tr( "Network Installation. (Disabled: 
Unable to fetch package lists, check your network connection)" ) );
         reply->deleteLater();
+        emit checkReady( !m_required );
         return;
     }
 
@@ -111,15 +108,23 @@
     ui->groupswidget->header()->setSectionResizeMode( 1, QHeaderView::Stretch 
);
 
     reply->deleteLater();
-    emit checkReady( isReady() );
+    emit checkReady( true );
 }
 
-QList<PackageTreeItem::ItemData> NetInstallPage::selectedPackages() const
+PackageModel::PackageItemDataList
+NetInstallPage::selectedPackages() const
 {
-    return m_groups->getPackages();
+    if ( m_groups )
+        return m_groups->getPackages();
+    else
+    {
+        cDebug() << "WARNING: no netinstall groups are available.";
+        return PackageModel::PackageItemDataList();
+    }
 }
 
-void NetInstallPage::loadGroupList()
+void
+NetInstallPage::loadGroupList()
 {
     QString confUrl(
         Calamares::JobQueue::instance()->globalStorage()->value(
@@ -138,7 +143,15 @@
     m_networkManager.get( request );
 }
 
-void NetInstallPage::onActivate()
+void
+NetInstallPage::setRequired( bool b )
+{
+    m_required = b;
+}
+
+
+void
+NetInstallPage::onActivate()
 {
     ui->groupswidget->setFocus();
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/calamares-3.1.6/src/modules/netinstall/NetInstallPage.h 
new/calamares-3.1.8/src/modules/netinstall/NetInstallPage.h
--- old/calamares-3.1.6/src/modules/netinstall/NetInstallPage.h 2017-10-13 
21:45:37.000000000 +0200
+++ new/calamares-3.1.8/src/modules/netinstall/NetInstallPage.h 2017-11-14 
16:18:58.000000000 +0100
@@ -46,17 +46,24 @@
 
     void onActivate();
 
-    bool isReady();
-
     // Retrieves the groups, with name, description and packages, from
     // the remote URL configured in the settings. Assumes the URL is already
     // in the global storage. This should be called before displaying the page.
     void loadGroupList();
 
+    // Sets the "required" state of netinstall data. Influences whether
+    // corrupt or unavailable data causes checkReady() to be emitted
+    // true (not-required) or false.
+    void setRequired( bool );
+    bool getRequired() const
+    {
+        return m_required;
+    }
+
     // Returns the list of packages belonging to groups that are
     // selected in the view in this given moment. No data is cached here, so
     // this function does not have constant time.
-    QList<PackageTreeItem::ItemData> selectedPackages() const;
+    PackageModel::PackageItemDataList selectedPackages() const;
 
 public slots:
     void dataIsHere( QNetworkReply* );
@@ -76,6 +83,7 @@
     QNetworkAccessManager m_networkManager;
 
     PackageModel* m_groups;
+    bool m_required;
 };
 
 #endif // NETINSTALLPAGE_H
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/calamares-3.1.6/src/modules/netinstall/NetInstallViewStep.cpp 
new/calamares-3.1.8/src/modules/netinstall/NetInstallViewStep.cpp
--- old/calamares-3.1.6/src/modules/netinstall/NetInstallViewStep.cpp   
2017-10-13 21:45:37.000000000 +0200
+++ new/calamares-3.1.8/src/modules/netinstall/NetInstallViewStep.cpp   
2017-11-14 16:18:58.000000000 +0100
@@ -2,6 +2,7 @@
  *   Copyright 2016, Luca Giambonini <[email protected]>
  *   Copyright 2016, Lisa Vitolo <[email protected]>
  *   Copyright 2017, Kyle Robbertze  <[email protected]>
+ *   Copyright 2017, Adriaan de Groot <[email protected]>
  *
  *   Calamares is free software: you can redistribute it and/or modify
  *   it under the terms of the GNU General Public License as published by
@@ -30,11 +31,11 @@
 NetInstallViewStep::NetInstallViewStep( QObject* parent )
     : Calamares::ViewStep( parent )
     , m_widget( new NetInstallPage() )
-    , m_nextEnabled( true )
+    , m_nextEnabled( false )
 {
     emit nextStatusChanged( true );
     connect( m_widget, &NetInstallPage::checkReady,
-             this, &NetInstallViewStep::nextStatusChanged );
+             this, &NetInstallViewStep::nextIsReady );
 }
 
 
@@ -126,18 +127,26 @@
     cDebug() << "Leaving netinstall, adding packages to be installed"
              << "to global storage";
 
-    QMap<QString, QVariant> packagesWithOperation;
-    QList<PackageTreeItem::ItemData> packages = m_widget->selectedPackages();
+    PackageModel::PackageItemDataList packages = m_widget->selectedPackages();
     QVariantList installPackages;
     QVariantList tryInstallPackages;
-    cDebug() << "Processing";
+    QVariantList packageOperations;
+
+    cDebug() << "Processing" << packages.length() << "packages from 
netinstall.";
 
     for ( auto package : packages )
     {
-        QMap<QString, QVariant> details;
-        details.insert( "pre-script", package.preScript );
-        details.insert( "package", package.packageName );
-        details.insert( "post-script", package.postScript );
+        QVariant details( package.packageName );
+        // If it's a package with a pre- or post-script, replace
+        // with the more complicated datastructure.
+        if ( !package.preScript.isEmpty() || !package.postScript.isEmpty() )
+        {
+            QMap<QString, QVariant> sdetails;
+            sdetails.insert( "pre-script", package.preScript );
+            sdetails.insert( "package", package.packageName );
+            sdetails.insert( "post-script", package.postScript );
+            details = sdetails;
+        }
         if ( package.isCritical )
             installPackages.append( details );
         else
@@ -145,14 +154,24 @@
     }
 
     if ( !installPackages.empty() )
-        packagesWithOperation.insert( "install", QVariant( installPackages ) );
+    {
+        QMap<QString, QVariant> op;
+        op.insert( "install", QVariant( installPackages ) );
+        packageOperations.append( op );
+        cDebug() << "  .." << installPackages.length() << "critical packages.";
+    }
     if ( !tryInstallPackages.empty() )
-        packagesWithOperation.insert( "try_install", QVariant( 
tryInstallPackages ) );
+    {
+        QMap<QString, QVariant> op;
+        op.insert( "try_install", QVariant( tryInstallPackages ) );
+        packageOperations.append( op );
+        cDebug() << "  .." << tryInstallPackages.length() << "non-critical 
packages.";
+    }
 
-    if ( !packagesWithOperation.isEmpty() )
+    if ( !packageOperations.isEmpty() )
     {
         Calamares::GlobalStorage* gs = 
Calamares::JobQueue::instance()->globalStorage();
-        gs->insert( "packageOperations", QVariant( packagesWithOperation ) );
+        gs->insert( "packageOperations", QVariant( packageOperations ) );
     }
 }
 
@@ -160,6 +179,11 @@
 void
 NetInstallViewStep::setConfigurationMap( const QVariantMap& configurationMap )
 {
+    m_widget->setRequired(
+        configurationMap.contains( "required" ) &&
+        configurationMap.value( "required" ).type() == QVariant::Bool &&
+        configurationMap.value( "required" ).toBool() );
+
     if ( configurationMap.contains( "groupsUrl" ) &&
             configurationMap.value( "groupsUrl" ).type() == QVariant::String )
     {
@@ -168,3 +192,10 @@
         m_widget->loadGroupList();
     }
 }
+
+void
+NetInstallViewStep::nextIsReady( bool b )
+{
+    m_nextEnabled = b;
+    emit nextStatusChanged( b );
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/calamares-3.1.6/src/modules/netinstall/NetInstallViewStep.h 
new/calamares-3.1.8/src/modules/netinstall/NetInstallViewStep.h
--- old/calamares-3.1.6/src/modules/netinstall/NetInstallViewStep.h     
2017-10-13 21:45:37.000000000 +0200
+++ new/calamares-3.1.8/src/modules/netinstall/NetInstallViewStep.h     
2017-11-14 16:18:58.000000000 +0100
@@ -60,6 +60,9 @@
 
     void setConfigurationMap( const QVariantMap& configurationMap ) override;
 
+public slots:
+    void nextIsReady( bool );
+
 private:
     NetInstallPage* m_widget;
     bool m_nextEnabled;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/calamares-3.1.6/src/modules/netinstall/PackageModel.h 
new/calamares-3.1.8/src/modules/netinstall/PackageModel.h
--- old/calamares-3.1.6/src/modules/netinstall/PackageModel.h   2017-10-13 
21:45:37.000000000 +0200
+++ new/calamares-3.1.8/src/modules/netinstall/PackageModel.h   2017-11-14 
16:18:58.000000000 +0100
@@ -1,3 +1,4 @@
+
 /* === This file is part of Calamares - <http://github.com/calamares> ===
  *
  *   Copyright (c) 2017, Kyle Robbertze <[email protected]>
@@ -28,14 +29,13 @@
 
 #include <yaml-cpp/yaml.h>
 
-// Required forward declarations
-class PackageTreeItem;
-
 class PackageModel : public QAbstractItemModel
 {
     Q_OBJECT
 
 public:
+    using PackageItemDataList = QList< PackageTreeItem::ItemData >;
+
     explicit PackageModel( const YAML::Node& data, QObject* parent = nullptr );
     ~PackageModel() override;
 
@@ -52,7 +52,7 @@
     QModelIndex parent( const QModelIndex& index ) const override;
     int rowCount( const QModelIndex& parent = QModelIndex() ) const override;
     int columnCount( const QModelIndex& parent = QModelIndex() ) const 
override;
-    QList<PackageTreeItem::ItemData> getPackages() const;
+    PackageItemDataList getPackages() const;
     QList<PackageTreeItem*> getItemPackages( PackageTreeItem* item ) const;
 
 private:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/calamares-3.1.6/src/modules/netinstall/netinstall.conf 
new/calamares-3.1.8/src/modules/netinstall/netinstall.conf
--- old/calamares-3.1.6/src/modules/netinstall/netinstall.conf  2017-10-13 
21:45:37.000000000 +0200
+++ new/calamares-3.1.8/src/modules/netinstall/netinstall.conf  2017-11-14 
16:18:58.000000000 +0100
@@ -1,2 +1,13 @@
 ---
+# This is the URL that is retrieved to get the netinstall groups-and-packages
+# data (which should be in the format described in netinstall.yaml).
 groupsUrl: http://chakraos.org/netinstall.php
+
+# If the installation can proceed without netinstall (e.g. the Live CD
+# can create a working installed system, but netinstall is preferred
+# to bring it up-to-date or extend functionality) leave this set to
+# false (the default). If set to true, the netinstall data is required.
+#
+# This only has an effect if the netinstall data cannot be retrieved,
+# or is corrupt: having "required" set, means the install cannot proceed.
+required: false
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/calamares-3.1.6/src/modules/packages/main.py 
new/calamares-3.1.8/src/modules/packages/main.py
--- old/calamares-3.1.6/src/modules/packages/main.py    2017-10-13 
21:45:37.000000000 +0200
+++ new/calamares-3.1.8/src/modules/packages/main.py    2017-11-14 
16:18:58.000000000 +0100
@@ -344,10 +344,18 @@
 
 def run_operations(pkgman, entry):
     """
-    Call package manager with given parameters.
+    Call package manager with suitable parameters for the given
+    package actions.
 
-    :param pkgman:
-    :param entry:
+    :param pkgman: PackageManager
+        This is the manager that does the actual work.
+    :param entry: dict
+        Keys are the actions -- e.g. "install" -- to take, and the values
+        are the (list of) packages to apply the action to. The actions are
+        not iterated in a specific order, so it is recommended to use only
+        one action per dictionary. The list of packages may be package
+        names (strings) or package information dictionaries with pre-
+        and post-scripts.
     """
     global group_packages, completed_packages, mode_packages
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/calamares-3.1.6/src/modules/partition/CMakeLists.txt 
new/calamares-3.1.8/src/modules/partition/CMakeLists.txt
--- old/calamares-3.1.6/src/modules/partition/CMakeLists.txt    2017-10-13 
21:45:37.000000000 +0200
+++ new/calamares-3.1.8/src/modules/partition/CMakeLists.txt    2017-11-14 
16:18:58.000000000 +0100
@@ -9,10 +9,22 @@
 find_package( KF5 REQUIRED Config I18n IconThemes KIO Service )
 
 find_package( KPMcore 3.1.50 QUIET )
-if ( ${KPMcore_FOUND} )
+if ( KPMcore_FOUND )
     add_definitions(-DWITH_KPMCORE22)
 endif()
-find_package( KPMcore 3.0.3 REQUIRED )
+find_package( KPMcore 3.0.3 QUIET )
+# 3.0.3 and newer has fixes for NVMe support; allow 3.0.2, but warn
+# about it .. needs to use a different feature name because it otherwise
+# gets reported as KPMcore (the package).
+if ( KPMcore_FOUND )
+    message( STATUS "KPMCore supports NVMe operations" )
+    add_feature_info( KPMcoreNVMe KPMcore_FOUND "KPMcore with NVMe support" )
+else()
+    find_package( KPMcore 3.0.2 REQUIRED )
+    message( WARNING "KPMCore 3.0.2 is known to have bugs with NVMe devices" )
+    add_feature_info( KPMcoreNVMe KPMcore_FOUND "Older KPMcore with no NVMe 
support" )
+endif()
+
 find_library( atasmart_LIB atasmart )
 find_library( blkid_LIB blkid )
 if( NOT atasmart_LIB )
@@ -58,7 +70,6 @@
         gui/PrettyRadioButton.cpp
         gui/ScanningDialog.cpp
         gui/ReplaceWidget.cpp
-        jobs/CheckFileSystemJob.cpp
         jobs/ClearMountsJob.cpp
         jobs/ClearTempMountsJob.cpp
         jobs/CreatePartitionJob.cpp
@@ -66,7 +77,6 @@
         jobs/DeletePartitionJob.cpp
         jobs/FillGlobalStorageJob.cpp
         jobs/FormatPartitionJob.cpp
-        jobs/MoveFileSystemJob.cpp
         jobs/PartitionJob.cpp
         jobs/ResizePartitionJob.cpp
         jobs/SetPartitionFlagsJob.cpp
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/calamares-3.1.6/src/modules/partition/jobs/CheckFileSystemJob.cpp 
new/calamares-3.1.8/src/modules/partition/jobs/CheckFileSystemJob.cpp
--- old/calamares-3.1.6/src/modules/partition/jobs/CheckFileSystemJob.cpp       
2017-10-13 21:45:37.000000000 +0200
+++ new/calamares-3.1.8/src/modules/partition/jobs/CheckFileSystemJob.cpp       
1970-01-01 01:00:00.000000000 +0100
@@ -1,83 +0,0 @@
-/* === This file is part of Calamares - <http://github.com/calamares> ===
- *
- *   Copyright 2014, Aurélien Gâteau <[email protected]>
- *   Copyright 2016, Teo Mrnjavac <[email protected]>
- *
- *   Calamares is free software: you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation, either version 3 of the License, or
- *   (at your option) any later version.
- *
- *   Calamares is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with Calamares. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "jobs/CheckFileSystemJob.h"
-
-#include <utils/Logger.h>
-
-// KPMcore
-#include <kpmcore/core/partition.h>
-#include <kpmcore/fs/filesystem.h>
-#include <kpmcore/util/report.h>
-
-#include <QThread>
-
-CheckFileSystemJob::CheckFileSystemJob( Partition* partition )
-    : PartitionJob( partition )
-{}
-
-QString
-CheckFileSystemJob::prettyName() const
-{
-    QString path = partition()->partitionPath();
-    return tr( "Checking file system on partition %1." ).arg( path );
-}
-
-
-QString
-CheckFileSystemJob::prettyStatusMessage() const
-{
-    return prettyName();
-}
-
-
-Calamares::JobResult
-CheckFileSystemJob::exec()
-{
-    FileSystem& fs = partition()->fileSystem();
-
-    // if we cannot check, assume everything is fine
-    if ( fs.supportCheck() != FileSystem::cmdSupportFileSystem )
-        return Calamares::JobResult::ok();
-
-    Report report( nullptr );
-    bool ok = fs.check( report, partition()->partitionPath() );
-    int retries = 0;
-    const int MAX_RETRIES = 10;
-    while ( !ok )
-    {
-        cDebug() << "Partition" << partition()->partitionPath()
-                 << "might not be ready yet, retrying (" << ++retries
-                 << "/" << MAX_RETRIES << ") ...";
-        QThread::sleep( 2 /*seconds*/ );
-        ok = fs.check( report, partition()->partitionPath() );
-
-        if ( retries == MAX_RETRIES )
-            break;
-    }
-
-    if ( !ok )
-        return Calamares::JobResult::error(
-                   tr( "The file system check on partition %1 failed." )
-                   .arg( partition()->partitionPath() ),
-                   report.toText()
-               );
-
-    return Calamares::JobResult::ok();
-}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/calamares-3.1.6/src/modules/partition/jobs/CheckFileSystemJob.h 
new/calamares-3.1.8/src/modules/partition/jobs/CheckFileSystemJob.h
--- old/calamares-3.1.6/src/modules/partition/jobs/CheckFileSystemJob.h 
2017-10-13 21:45:37.000000000 +0200
+++ new/calamares-3.1.8/src/modules/partition/jobs/CheckFileSystemJob.h 
1970-01-01 01:00:00.000000000 +0100
@@ -1,38 +0,0 @@
-/* === This file is part of Calamares - <http://github.com/calamares> ===
- *
- *   Copyright 2014, Aurélien Gâteau <[email protected]>
- *
- *   Calamares is free software: you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation, either version 3 of the License, or
- *   (at your option) any later version.
- *
- *   Calamares is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with Calamares. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef CHECKFILESYSTEMJOB_H
-#define CHECKFILESYSTEMJOB_H
-
-#include <jobs/PartitionJob.h>
-
-/**
- * Runs a file system check on an existing partition.
- */
-class CheckFileSystemJob : public PartitionJob
-{
-    Q_OBJECT
-public:
-    CheckFileSystemJob( Partition* partition );
-
-    QString prettyName() const override;
-    QString prettyStatusMessage() const override;
-    Calamares::JobResult exec() override;
-};
-
-#endif /* CHECKFILESYSTEMJOB_H */
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/calamares-3.1.6/src/modules/partition/jobs/MoveFileSystemJob.cpp 
new/calamares-3.1.8/src/modules/partition/jobs/MoveFileSystemJob.cpp
--- old/calamares-3.1.6/src/modules/partition/jobs/MoveFileSystemJob.cpp        
2017-10-13 21:45:37.000000000 +0200
+++ new/calamares-3.1.8/src/modules/partition/jobs/MoveFileSystemJob.cpp        
1970-01-01 01:00:00.000000000 +0100
@@ -1,239 +0,0 @@
-/* === This file is part of Calamares - <http://github.com/calamares> ===
- *
- *   Copyright 2014, Aurélien Gâteau <[email protected]>
- *
- *   Calamares is free software: you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation, either version 3 of the License, or
- *   (at your option) any later version.
- *
- *   Calamares is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with Calamares. If not, see <http://www.gnu.org/licenses/>.
- */
-
-// This class is heavily based on the MoveFileSystemJob class from KDE 
Partition
-// Manager.
-// The copyBlock functions come from Partition Manager Job class.
-// Original copyright follow:
-
-/***************************************************************************
- *   Copyright (C) 2008 by Volker Lanz <[email protected]>                       *
- *                                                                         *
- *   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 2 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, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
- ***************************************************************************/
-
-#include <jobs/MoveFileSystemJob.h>
-
-#include <utils/Logger.h>
-
-// KPMcore
-#include <kpmcore/core/copysourcedevice.h>
-#include <kpmcore/core/copytargetdevice.h>
-#include <kpmcore/core/device.h>
-#include <kpmcore/core/partition.h>
-#include <kpmcore/fs/filesystem.h>
-#include <kpmcore/util/report.h>
-
-MoveFileSystemJob::MoveFileSystemJob( Device* device, Partition* partition, 
qint64 oldFirstSector, qint64 newFirstSector, qint64 length )
-    : PartitionJob( partition )
-    , m_device( device )
-    , m_oldFirstSector( oldFirstSector )
-    , m_newFirstSector( newFirstSector )
-    , m_length( length )
-{}
-
-QString
-MoveFileSystemJob::prettyName() const
-{
-    return tr( "Move file system of partition %1." ).arg( 
partition()->partitionPath() );
-}
-
-Calamares::JobResult
-MoveFileSystemJob::exec()
-{
-    Report report( nullptr );
-    QString partitionPath = partition()->partitionPath();
-    CopySourceDevice moveSource( *m_device, m_oldFirstSector, m_oldFirstSector 
+ m_length - 1 );
-    CopyTargetDevice moveTarget( *m_device, m_newFirstSector, m_newFirstSector 
+ m_length - 1 );
-
-    if ( !moveSource.open() )
-        return Calamares::JobResult::error(
-                   QString(),
-                   tr( "Could not open file system on partition %1 for 
moving." ).arg( partitionPath )
-               );
-
-    if ( !moveTarget.open() )
-        return Calamares::JobResult::error(
-                   QString(),
-                   tr( "Could not create target for moving file system on 
partition %1." ).arg( partitionPath )
-               );
-
-    bool ok = copyBlocks( report, moveTarget, moveSource );
-    if ( !ok )
-    {
-        if ( rollbackCopyBlocks( report, moveTarget, moveSource ) )
-            return Calamares::JobResult::error(
-                       QString(),
-                       tr( "Moving of partition %1 failed, changes have been 
rolled back." ).arg( partitionPath )
-                       + '\n' + report.toText()
-                   );
-        else
-            return Calamares::JobResult::error(
-                       QString(),
-                       tr( "Moving of partition %1 failed. Roll back of the 
changes have failed." ).arg( partitionPath )
-                       + '\n' + report.toText()
-                   );
-    }
-
-    FileSystem& fs = partition()->fileSystem();
-    fs.setFirstSector( m_newFirstSector );
-    fs.setLastSector( m_newFirstSector + m_length - 1 );
-
-    if ( !fs.updateBootSector( report, partitionPath ) )
-        return Calamares::JobResult::error(
-                   QString(),
-                   tr( "Updating boot sector after the moving of partition %1 
failed." ).arg( partitionPath )
-                   + '\n' + report.toText()
-               );
-
-    return Calamares::JobResult::ok();
-}
-
-bool
-MoveFileSystemJob::copyBlocks( Report& report, CopyTargetDevice& target, 
CopySourceDevice& source )
-{
-    /** @todo copyBlocks() assumes that source.sectorSize() == 
target.sectorSize(). */
-
-    if ( source.sectorSize() != target.sectorSize() )
-    {
-        report.line() << tr( "The logical sector sizes in the source and 
target for copying are not the same. This is currently unsupported." );
-        return false;
-    }
-
-    bool rval = true;
-    const qint64 blockSize = 16065 * 8; // number of sectors per block to copy
-    const qint64 blocksToCopy = source.length() / blockSize;
-
-    qint64 readOffset = source.firstSector();
-    qint64 writeOffset = target.firstSector();
-    qint32 copyDir = 1;
-
-    if ( target.firstSector() > source.firstSector() )
-    {
-        readOffset = source.firstSector() + source.length() - blockSize;
-        writeOffset = target.firstSector() + source.length() - blockSize;
-        copyDir = -1;
-    }
-
-    qint64 blocksCopied = 0;
-
-    Q_ASSERT( blockSize > 0 );
-    Q_ASSERT( source.sectorSize() > 0 );
-    Q_ASSERT( blockSize * source.sectorSize() > 0 );
-
-    void* buffer = malloc( size_t( blockSize * source.sectorSize() ) );
-    qint64 percent = 0;
-
-    while ( blocksCopied < blocksToCopy )
-    {
-        rval = source.readSectors( buffer, readOffset + blockSize * 
blocksCopied * copyDir, blockSize );
-        if ( !rval )
-            break;
-
-        rval = target.writeSectors( buffer, writeOffset + blockSize * 
blocksCopied * copyDir, blockSize );
-        if ( !rval )
-            break;
-
-        if ( ++blocksCopied * 100 / blocksToCopy != percent )
-        {
-            percent = blocksCopied * 100 / blocksToCopy;
-            progress( percent / 100. );
-        }
-    }
-
-    const qint64 lastBlock = source.length() % blockSize;
-
-    // copy the remainder
-    if ( rval && lastBlock > 0 )
-    {
-        Q_ASSERT( lastBlock < blockSize );
-
-        const qint64 lastBlockReadOffset = copyDir > 0 ? readOffset + 
blockSize * blocksCopied : source.firstSector();
-        const qint64 lastBlockWriteOffset = copyDir > 0 ? writeOffset + 
blockSize * blocksCopied : target.firstSector();
-
-        rval = source.readSectors( buffer, lastBlockReadOffset, lastBlock );
-
-        if ( rval )
-            rval = target.writeSectors( buffer, lastBlockWriteOffset, 
lastBlock );
-
-        if ( rval )
-            emit progress( 1.0 );
-    }
-
-    free( buffer );
-
-    return rval;
-}
-
-bool
-MoveFileSystemJob::rollbackCopyBlocks( Report& report, CopyTargetDevice& 
origTarget, CopySourceDevice& origSource )
-{
-    if ( !origSource.overlaps( origTarget ) )
-    {
-        report.line() << tr( "Source and target for copying do not overlap: 
Rollback is not required." );
-        return true;
-    }
-
-    // default: use values as if we were copying from front to back.
-    qint64 undoSourceFirstSector = origTarget.firstSector();
-    qint64 undoSourceLastSector = origTarget.firstSector() + 
origTarget.sectorsWritten() - 1;
-
-    qint64 undoTargetFirstSector = origSource.firstSector();
-    qint64 undoTargetLastSector = origSource.firstSector() + 
origTarget.sectorsWritten() - 1;
-
-    if ( origTarget.firstSector() > origSource.firstSector() )
-    {
-        // we were copying from back to front
-        undoSourceFirstSector = origTarget.firstSector() + origSource.length() 
- origTarget.sectorsWritten();
-        undoSourceLastSector = origTarget.firstSector() + origSource.length() 
- 1;
-
-        undoTargetFirstSector = origSource.lastSector() - 
origTarget.sectorsWritten() + 1;
-        undoTargetLastSector = origSource.lastSector();
-    }
-
-    CopySourceDevice undoSource( origTarget.device(), undoSourceFirstSector, 
undoSourceLastSector );
-    if ( !undoSource.open() )
-    {
-        report.line() << tr( "Could not open device %1 to rollback copying." )
-                      .arg( origTarget.device().deviceNode() );
-        return false;
-    }
-
-    CopyTargetDevice undoTarget( origSource.device(), undoTargetFirstSector, 
undoTargetLastSector );
-    if ( !undoTarget.open() )
-    {
-        report.line() << tr( "Could not open device %1 to rollback copying." )
-                      .arg( origSource.device().deviceNode() );
-        return false;
-    }
-
-    return copyBlocks( report, undoTarget, undoSource );
-}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/calamares-3.1.6/src/modules/partition/jobs/MoveFileSystemJob.h 
new/calamares-3.1.8/src/modules/partition/jobs/MoveFileSystemJob.h
--- old/calamares-3.1.6/src/modules/partition/jobs/MoveFileSystemJob.h  
2017-10-13 21:45:37.000000000 +0200
+++ new/calamares-3.1.8/src/modules/partition/jobs/MoveFileSystemJob.h  
1970-01-01 01:00:00.000000000 +0100
@@ -1,76 +0,0 @@
-/* === This file is part of Calamares - <http://github.com/calamares> ===
- *
- *   Copyright 2014, Aurélien Gâteau <[email protected]>
- *
- *   Calamares is free software: you can redistribute it and/or modify
- *   it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation, either version 3 of the License, or
- *   (at your option) any later version.
- *
- *   Calamares is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with Calamares. If not, see <http://www.gnu.org/licenses/>.
- */
-
-// This class is heavily based on the MoveFileSystemJob class from KDE 
Partition
-// Manager. Original copyright follow:
-
-/***************************************************************************
- *   Copyright (C) 2008 by Volker Lanz <[email protected]>                       *
- *                                                                         *
- *   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 2 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, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
- ***************************************************************************/
-#ifndef MOVEFILESYSTEMJOB_H
-#define MOVEFILESYSTEMJOB_H
-
-#include <jobs/PartitionJob.h>
-
-class CopySourceDevice;
-class CopyTargetDevice;
-class Device;
-class Partition;
-class Report;
-
-/**
- * This job moves the data of a filesystem from one position on the disk to
- * another.
- *
- * It is used by the ResizePartitionJob.
- */
-class MoveFileSystemJob : public PartitionJob
-{
-    Q_OBJECT
-public:
-    MoveFileSystemJob( Device* device, Partition* partition, qint64 
oldFirstSector, qint64 newFirstSector, qint64 length );
-
-    QString prettyName() const override;
-
-    Calamares::JobResult exec() override;
-
-private:
-    Device* m_device;
-    qint64 m_oldFirstSector;
-    qint64 m_newFirstSector;
-    qint64 m_length;
-    bool copyBlocks( Report& report, CopyTargetDevice& target, 
CopySourceDevice& source );
-    bool rollbackCopyBlocks( Report& report, CopyTargetDevice& origTarget, 
CopySourceDevice& origSource );
-};
-
-#endif /* MOVEFILESYSTEMJOB_H */
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/calamares-3.1.6/src/modules/partition/jobs/ResizePartitionJob.cpp 
new/calamares-3.1.8/src/modules/partition/jobs/ResizePartitionJob.cpp
--- old/calamares-3.1.6/src/modules/partition/jobs/ResizePartitionJob.cpp       
2017-10-13 21:45:37.000000000 +0200
+++ new/calamares-3.1.8/src/modules/partition/jobs/ResizePartitionJob.cpp       
2017-11-14 16:18:58.000000000 +0100
@@ -2,6 +2,7 @@
  *
  *   Copyright 2014, Aurélien Gâteau <[email protected]>
  *   Copyright 2015, Teo Mrnjavac <[email protected]>
+ *   Copyright 2017, Andrius Štikonas <[email protected]>
  *
  *   Calamares is free software: you can redistribute it and/or modify
  *   it under the terms of the GNU General Public License as published by
@@ -17,156 +18,12 @@
  *   along with Calamares. If not, see <http://www.gnu.org/licenses/>.
  */
 
-// This class is heavily based on the ResizeOperation class from KDE Partition
-// Manager. Original copyright follow:
-
-/***************************************************************************
- *   Copyright (C) 2008,2012 by Volker Lanz <[email protected]>                  *
- *                                                                         *
- *   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 2 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, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
- ***************************************************************************/
-
 #include "jobs/ResizePartitionJob.h"
 
-#include "jobs/CheckFileSystemJob.h"
-#include "jobs/MoveFileSystemJob.h"
-#include "utils/Logger.h"
-
 // KPMcore
-#include <kpmcore/backend/corebackend.h>
-#include <kpmcore/backend/corebackendmanager.h>
-#include <kpmcore/backend/corebackenddevice.h>
-#include <kpmcore/backend/corebackendpartition.h>
-#include <kpmcore/backend/corebackendpartitiontable.h>
-#include <kpmcore/core/device.h>
-#include <kpmcore/core/partition.h>
-#include <kpmcore/util/report.h>
-
-// Qt
-#include <QScopedPointer>
-
-//- ResizeFileSystemJob 
--------------------------------------------------------
-class ResizeFileSystemJob : public Calamares::Job
-{
-    Q_OBJECT
-public:
-    ResizeFileSystemJob( Device* device, CoreBackendPartitionTable* 
backendPartitionTable, Partition* partition, qint64 length )
-        : m_device( device )
-        , m_backendPartitionTable( backendPartitionTable )
-        , m_partition( partition )
-        , m_length( length )
-    {}
-
-    QString prettyName() const override
-    {
-        QString path = m_partition->partitionPath();
-        return tr( "Resize file system on partition %1." ).arg( path );
-    }
-
-    Calamares::JobResult exec() override
-    {
-        Report report( nullptr );
-        FileSystem& fs = m_partition->fileSystem();
-        FileSystem::CommandSupportType support = m_length < fs.length() ? 
fs.supportShrink() : fs.supportGrow();
-
-        switch ( support )
-        {
-        case FileSystem::cmdSupportBackend:
-            if ( !backendResize( &report ) )
-                return Calamares::JobResult::error(
-                           QString(),
-                           tr( "Parted failed to resize filesystem." ) + '\n' 
+ report.toText()
-                       );
-            break;
-        case FileSystem::cmdSupportFileSystem:
-        {
-            qint64 byteLength = m_device->logicalSize() * m_length;
-            bool ok = fs.resize( report, m_partition->partitionPath(), 
byteLength );
-            if ( !ok )
-                return Calamares::JobResult::error(
-                           QString(),
-                           tr( "Failed to resize filesystem." ) + '\n' + 
report.toText()
-                       );
-            break;
-        }
-        default:
-            break;
-        }
-
-        fs.setLastSector( fs.firstSector() + m_length - 1 );
-        return Calamares::JobResult::ok();
-    }
-
-private:
-    Device* m_device;
-    CoreBackendPartitionTable* m_backendPartitionTable;
-    Partition* m_partition;
-    qint64 m_length;
-
-    bool backendResize( Report* report )
-    {
-        bool ok = m_backendPartitionTable->resizeFileSystem( *report, 
*m_partition, m_length );
-        if ( !ok )
-            return false;
-        m_backendPartitionTable->commit();
-        return true;
-    }
-};
-
-//- SetPartGeometryJob 
---------------------------------------------------------
-class SetPartGeometryJob : public Calamares::Job
-{
-    Q_OBJECT
-public:
-    SetPartGeometryJob( CoreBackendPartitionTable* backendPartitionTable, 
Partition* partition, qint64 firstSector, qint64 length )
-        : m_backendPartitionTable( backendPartitionTable )
-        , m_partition( partition )
-        , m_firstSector( firstSector )
-        , m_length( length )
-    {}
-
-    QString prettyName() const override
-    {
-        QString path = m_partition->partitionPath();
-        return tr( "Update geometry of partition %1." ).arg( path );
-    }
-
-    Calamares::JobResult exec() override
-    {
-        Report report( nullptr );
-        qint64 lastSector = m_firstSector + m_length - 1;
-        bool ok = m_backendPartitionTable->updateGeometry( report, 
*m_partition, m_firstSector, lastSector );
-        if ( !ok )
-        {
-            return Calamares::JobResult::error(
-                       QString(),
-                       tr( "Failed to change the geometry of the partition." ) 
+ '\n' + report.toText() );
-        }
-        m_partition->setFirstSector( m_firstSector );
-        m_partition->setLastSector( lastSector );
-        m_backendPartitionTable->commit();
-        return Calamares::JobResult::ok();
-    }
-
-private:
-    CoreBackendPartitionTable* m_backendPartitionTable;
-    Partition* m_partition;
-    qint64 m_firstSector;
-    qint64 m_length;
-};
+#include <core/device.h>
+#include <ops/resizeoperation.h>
+#include <util/report.h>
 
 //- ResizePartitionJob 
---------------------------------------------------------
 ResizePartitionJob::ResizePartitionJob( Device* device, Partition* partition, 
qint64 firstSector, qint64 lastSector )
@@ -194,7 +51,7 @@
     return tr( "Resize <strong>%2MB</strong> partition <strong>%1</strong> to "
                "<strong>%3MB</strong>." )
             .arg( partition()->partitionPath() )
-            .arg( ( m_oldLastSector - m_oldFirstSector ) * 
partition()->sectorSize() / 1024 / 1024 )
+            .arg( ( m_oldLastSector - m_oldFirstSector + 1 ) * 
partition()->sectorSize() / 1024 / 1024 )
             .arg( ( m_newLastSector - m_newFirstSector + 1 ) * 
partition()->sectorSize() / 1024 / 1024 );
 }
 
@@ -205,7 +62,7 @@
     return tr( "Resizing %2MB partition %1 to "
                "%3MB." )
             .arg( partition()->partitionPath() )
-            .arg( ( m_oldLastSector - m_oldFirstSector ) * 
partition()->sectorSize() / 1024 / 1024 )
+            .arg( ( m_oldLastSector - m_oldFirstSector + 1 ) * 
partition()->sectorSize() / 1024 / 1024 )
             .arg( ( m_newLastSector - m_newFirstSector + 1 ) * 
partition()->sectorSize() / 1024 / 1024 );
 }
 
@@ -213,64 +70,21 @@
 Calamares::JobResult
 ResizePartitionJob::exec()
 {
-    qint64 oldLength = m_oldLastSector - m_oldFirstSector + 1;
-    qint64 newLength = m_newLastSector - m_newFirstSector + 1;
-
-    // Assuming updatePreview() has been called, `partition` uses its new
-    // position and size. Reset it to the old values: part of the libparted
-    // backend relies on this (for example:
-    // LibPartedPartitionTable::updateGeometry())
-    // The jobs are responsible for updating the partition back when they are
-    // done.
+    Report report (nullptr);
+    // Restore partition sectors that were modified for preview
     m_partition->setFirstSector( m_oldFirstSector );
     m_partition->setLastSector( m_oldLastSector );
+    ResizeOperation op(*m_device, *m_partition, m_newFirstSector, 
m_newLastSector);
+    op.setStatus(Operation::StatusRunning);
+    connect(&op, &Operation::progress, [&](int percent) { emit 
progress(percent / 100.0); } );
+
+    QString errorMessage = tr( "The installer failed to resize partition %1 on 
disk '%2'." )
+                       .arg( m_partition->partitionPath() )
+                       .arg( m_device->name() );
+    if (op.execute(report))
+        return Calamares::JobResult::ok();
 
-    CoreBackend* backend = CoreBackendManager::self()->backend();
-    QScopedPointer<CoreBackendDevice> backendDevice( backend->openDevice( 
m_device->deviceNode() ) );
-    if ( !backendDevice.data() )
-    {
-        QString errorMessage = tr( "The installer failed to resize partition 
%1 on disk '%2'." )
-                               .arg( m_partition->partitionPath() )
-                               .arg( m_device->name() );
-        return Calamares::JobResult::error(
-                   errorMessage,
-                   tr( "Could not open device '%1'." ).arg( 
m_device->deviceNode() )
-               );
-    }
-    QScopedPointer<CoreBackendPartitionTable> backendPartitionTable( 
backendDevice->openPartitionTable() );
-
-    // Create jobs
-    QList< Calamares::job_ptr > jobs;
-    jobs << Calamares::job_ptr( new CheckFileSystemJob( partition() ) );
-    if ( m_partition->roles().has( PartitionRole::Extended ) )
-        jobs << Calamares::job_ptr( new SetPartGeometryJob( 
backendPartitionTable.data(), m_partition, m_newFirstSector, newLength ) );
-    else
-    {
-        bool shrink = newLength < oldLength;
-        bool grow = newLength > oldLength;
-        bool moveRight = m_newFirstSector > m_oldFirstSector;
-        bool moveLeft = m_newFirstSector < m_oldFirstSector;
-        if ( shrink )
-        {
-            jobs << Calamares::job_ptr( new ResizeFileSystemJob( m_device, 
backendPartitionTable.data(), m_partition, newLength ) );
-            jobs << Calamares::job_ptr( new SetPartGeometryJob( 
backendPartitionTable.data(), m_partition, m_oldFirstSector, newLength ) );
-        }
-        if ( moveRight || moveLeft )
-        {
-            // At this point, we need to set the partition's length to either 
the resized length, if it has already been
-            // shrunk, or to the original length (it may or may not then later 
be grown, we don't care here)
-            const qint64 length = shrink ? newLength : oldLength;
-            jobs << Calamares::job_ptr( new SetPartGeometryJob( 
backendPartitionTable.data(), m_partition, m_newFirstSector, length ) );
-            jobs << Calamares::job_ptr( new MoveFileSystemJob( m_device, 
m_partition, m_oldFirstSector, m_newFirstSector, length ) );
-        }
-        if ( grow )
-        {
-            jobs << Calamares::job_ptr( new SetPartGeometryJob( 
backendPartitionTable.data(), m_partition, m_newFirstSector, newLength ) );
-            jobs << Calamares::job_ptr( new ResizeFileSystemJob( m_device, 
backendPartitionTable.data(), m_partition, newLength ) );
-        }
-    }
-    jobs << Calamares::job_ptr( new CheckFileSystemJob( partition() ) );
-    return execJobList( jobs );
+    return Calamares::JobResult::error(errorMessage, report.toText());
 }
 
 void
@@ -290,31 +104,3 @@
 {
     return m_device;
 }
-
-
-Calamares::JobResult
-ResizePartitionJob::execJobList( const QList< Calamares::job_ptr >& jobs )
-{
-    QString errorMessage = tr( "The installer failed to resize partition %1 on 
disk '%2'." )
-                           .arg( m_partition->partitionPath() )
-                           .arg( m_device->name() );
-
-    int nbJobs = jobs.size();
-    int count = 0;
-    for ( Calamares::job_ptr job : jobs )
-    {
-        cLog() << "- " + job->prettyName();
-        Calamares::JobResult result = job->exec();
-        if ( !result )
-        {
-            if ( result.message().isEmpty() )
-                result.setMessage( errorMessage );
-            return result;
-        }
-        ++count;
-        progress( qreal( count ) / nbJobs );
-    }
-    return Calamares::JobResult::ok();
-}
-
-#include "ResizePartitionJob.moc"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/calamares-3.1.6/src/modules/partition/jobs/ResizePartitionJob.h 
new/calamares-3.1.8/src/modules/partition/jobs/ResizePartitionJob.h
--- old/calamares-3.1.6/src/modules/partition/jobs/ResizePartitionJob.h 
2017-10-13 21:45:37.000000000 +0200
+++ new/calamares-3.1.8/src/modules/partition/jobs/ResizePartitionJob.h 
2017-11-14 16:18:58.000000000 +0100
@@ -51,8 +51,6 @@
     qint64 m_oldLastSector;
     qint64 m_newFirstSector;
     qint64 m_newLastSector;
-
-    Calamares::JobResult execJobList( const QList< Calamares::job_ptr >& jobs 
);
 };
 
 #endif /* RESIZEPARTITIONJOB_H */
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/calamares-3.1.6/src/modules/partition/tests/CMakeLists.txt 
new/calamares-3.1.8/src/modules/partition/tests/CMakeLists.txt
--- old/calamares-3.1.6/src/modules/partition/tests/CMakeLists.txt      
2017-10-13 21:45:37.000000000 +0200
+++ new/calamares-3.1.8/src/modules/partition/tests/CMakeLists.txt      
2017-11-14 16:18:58.000000000 +0100
@@ -9,11 +9,9 @@
     ${PartitionModule_SOURCE_DIR}/core/KPMHelpers.cpp
     ${PartitionModule_SOURCE_DIR}/core/PartitionInfo.cpp
     ${PartitionModule_SOURCE_DIR}/core/PartitionIterator.cpp
-    ${PartitionModule_SOURCE_DIR}/jobs/CheckFileSystemJob.cpp
     ${PartitionModule_SOURCE_DIR}/jobs/CreatePartitionJob.cpp
     ${PartitionModule_SOURCE_DIR}/jobs/CreatePartitionTableJob.cpp
     ${PartitionModule_SOURCE_DIR}/jobs/DeletePartitionJob.cpp
-    ${PartitionModule_SOURCE_DIR}/jobs/MoveFileSystemJob.cpp
     ${PartitionModule_SOURCE_DIR}/jobs/PartitionJob.cpp
     ${PartitionModule_SOURCE_DIR}/jobs/ResizePartitionJob.cpp
     PartitionJobTests.cpp


Reply via email to