From 448d50f929ea41f896da0d86378e387abda9ca4c Mon Sep 17 00:00:00 2001 From: Simon Quigley Date: Wed, 11 Oct 2023 03:09:47 -0500 Subject: [PATCH] Start more of the backend implementation. --- common/modules/pkgselect/CMakeLists.txt | 1 - .../pkgselect/PackageSelectViewStep.cpp | 39 ++++++++++++++++--- .../modules/pkgselect/PackageSelectViewStep.h | 6 +-- 3 files changed, 37 insertions(+), 9 deletions(-) diff --git a/common/modules/pkgselect/CMakeLists.txt b/common/modules/pkgselect/CMakeLists.txt index 57f592a..4ca8a25 100644 --- a/common/modules/pkgselect/CMakeLists.txt +++ b/common/modules/pkgselect/CMakeLists.txt @@ -18,7 +18,6 @@ calamares_add_plugin( pkgselect EXPORT_MACRO PLUGINDLLEXPORT_PRO SOURCES PackageSelectViewStep.cpp - PackageSelectJob.cpp RESOURCES pkgselect.qrc SHARED_LIB diff --git a/common/modules/pkgselect/PackageSelectViewStep.cpp b/common/modules/pkgselect/PackageSelectViewStep.cpp index 918d9d8..5aa648c 100644 --- a/common/modules/pkgselect/PackageSelectViewStep.cpp +++ b/common/modules/pkgselect/PackageSelectViewStep.cpp @@ -1,5 +1,6 @@ #include "PackageSelectViewStep.h" -#include "PackageSelectJob.h" +#include +#include "ProcessJob.h" PackageSelectViewStep::PackageSelectViewStep( QObject* parent ) : Calamares::QmlViewStep( parent ), m_packageSelections(QVariantMap()) @@ -13,11 +14,42 @@ PackageSelectViewStep::prettyName() const return tr( "Package Selection" ); } +bool PackageSelectViewStep::exists_and_true(const QString& key) const +{ + return m_packageSelections.contains(key) && m_packageSelections[key].toBool() == true; +} + Calamares::JobList PackageSelectViewStep::jobs() const { + // Global commands to be ran across all packages + QString apt = "/bin/sh -c '/usr/bin/apt-get -y "; + QString apt_install = apt + "install "; + bool run_apt_install = false; + QString apt_remove = apt + "purge "; + bool run_apt_remove = false; + QString working_path = "/"; + bool runInChroot = true; + QList< Calamares::job_ptr > list; - list.append(Calamares::job_ptr(new PackageSelectJob())); + + // Third party media etc. drivers + if (exists_and_true("restrictedExtras")) { + apt_install += "ubuntu-restricted-extras"; + run_apt_install = true; + } + + // Install packages + if (run_apt_install) { + Calamares::Job* job = new Calamares::ProcessJob(apt_install + "", working_path, runInChroot); + list.append(Calamares::job_ptr(job)); + } + + // Run an autoremove and clean afterwards + Calamares::Job* autoremove_job = new Calamares::ProcessJob(apt + "autoremove'", working_path, runInChroot); + Calamares::Job* clean_job = new Calamares::ProcessJob(apt + "clean'", working_path, runInChroot); + list.append(Calamares::job_ptr(autoremove_job)); + list.append(Calamares::job_ptr(clean_job)); return list; } @@ -39,9 +71,6 @@ void PackageSelectViewStep::setPackageSelections(const QVariantMap &value) if (m_packageSelections != value) { m_packageSelections = value; emit packageSelectionsChanged(); - - Calamares::GlobalStorage* globalStorage = Calamares::JobQueue::instance()->globalStorage(); - globalStorage->insert("packageSelections", m_packageSelections); } } diff --git a/common/modules/pkgselect/PackageSelectViewStep.h b/common/modules/pkgselect/PackageSelectViewStep.h index fa0dbdd..0602cfe 100644 --- a/common/modules/pkgselect/PackageSelectViewStep.h +++ b/common/modules/pkgselect/PackageSelectViewStep.h @@ -7,9 +7,7 @@ #include "DllMacro.h" #include "utils/PluginFactory.h" #include "viewpages/QmlViewStep.h" - -#include "GlobalStorage.h" -#include "JobQueue.h" +#include "ProcessJob.h" class PLUGINDLLEXPORT PackageSelectViewStep : public Calamares::QmlViewStep { @@ -36,6 +34,8 @@ signals: private: QVariantMap m_packageSelections; + + bool exists_and_true(const QString& key) const; }; CALAMARES_PLUGIN_FACTORY_DECLARATION( PackageSelectViewStepFactory )