mirror of
https://git.launchpad.net/~ubuntu-qt-code/+git/calamares-settings-ubuntu
synced 2025-07-04 05:01:30 +00:00
Finish the prototype for pkgselect, which stores the values in GlobalStorage for later usage by a contextualprocess
This commit is contained in:
parent
448d50f929
commit
b52736fc07
@ -1,15 +0,0 @@
|
|||||||
#include "PackageSelectJob.h"
|
|
||||||
|
|
||||||
PackageSelectJob::PackageSelectJob( QObject* parent )
|
|
||||||
: CppJob( parent )
|
|
||||||
{}
|
|
||||||
|
|
||||||
QString PackageSelectJob::prettyName() const
|
|
||||||
{
|
|
||||||
return tr( "Package Selection Job" );
|
|
||||||
}
|
|
||||||
|
|
||||||
Calamares::JobResult PackageSelectJob::exec()
|
|
||||||
{
|
|
||||||
return Calamares::JobResult::ok();
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
#include <CppJob.h>
|
|
||||||
|
|
||||||
class PackageSelectJob : public Calamares::CppJob
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
PackageSelectJob( QObject* parent = nullptr );
|
|
||||||
QString prettyName() const override;
|
|
||||||
Calamares::JobResult exec() override;
|
|
||||||
};
|
|
@ -1,6 +1,8 @@
|
|||||||
#include "PackageSelectViewStep.h"
|
#include "PackageSelectViewStep.h"
|
||||||
#include <QDebug>
|
#include "JobQueue.h"
|
||||||
#include "ProcessJob.h"
|
#include "GlobalStorage.h"
|
||||||
|
|
||||||
|
#include <QVariantMap>
|
||||||
|
|
||||||
PackageSelectViewStep::PackageSelectViewStep( QObject* parent )
|
PackageSelectViewStep::PackageSelectViewStep( QObject* parent )
|
||||||
: Calamares::QmlViewStep( parent ), m_packageSelections(QVariantMap())
|
: Calamares::QmlViewStep( parent ), m_packageSelections(QVariantMap())
|
||||||
@ -11,7 +13,7 @@ PackageSelectViewStep::~PackageSelectViewStep() {}
|
|||||||
QString
|
QString
|
||||||
PackageSelectViewStep::prettyName() const
|
PackageSelectViewStep::prettyName() const
|
||||||
{
|
{
|
||||||
return tr( "Package Selection" );
|
return tr( "Customize" );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PackageSelectViewStep::exists_and_true(const QString& key) const
|
bool PackageSelectViewStep::exists_and_true(const QString& key) const
|
||||||
@ -19,53 +21,25 @@ bool PackageSelectViewStep::exists_and_true(const QString& key) const
|
|||||||
return m_packageSelections.contains(key) && m_packageSelections[key].toBool() == true;
|
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;
|
|
||||||
|
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
PackageSelectViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
|
||||||
{
|
|
||||||
Calamares::QmlViewStep::setConfigurationMap( configurationMap );
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PackageSelectViewStep::onActivate()
|
PackageSelectViewStep::onActivate()
|
||||||
{
|
{
|
||||||
setContextProperty("packageSelect", this);
|
setContextProperty("packageSelect", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PackageSelectViewStep::onLeave()
|
||||||
|
{
|
||||||
|
Calamares::GlobalStorage* gs = Calamares::JobQueue::instance()->globalStorage();
|
||||||
|
QVariantMap config;
|
||||||
|
for (auto i = m_packageSelections.begin(); i != m_packageSelections.end(); ++i) {
|
||||||
|
if (exists_and_true(i.key())) {
|
||||||
|
config.insert(i.key(), i.value());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
gs->insert("packages", config);
|
||||||
|
}
|
||||||
|
|
||||||
void PackageSelectViewStep::setPackageSelections(const QVariantMap &value)
|
void PackageSelectViewStep::setPackageSelections(const QVariantMap &value)
|
||||||
{
|
{
|
||||||
if (m_packageSelections != value) {
|
if (m_packageSelections != value) {
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
#include "DllMacro.h"
|
#include "DllMacro.h"
|
||||||
#include "utils/PluginFactory.h"
|
#include "utils/PluginFactory.h"
|
||||||
#include "viewpages/QmlViewStep.h"
|
#include "viewpages/QmlViewStep.h"
|
||||||
#include "ProcessJob.h"
|
|
||||||
|
|
||||||
class PLUGINDLLEXPORT PackageSelectViewStep : public Calamares::QmlViewStep
|
class PLUGINDLLEXPORT PackageSelectViewStep : public Calamares::QmlViewStep
|
||||||
{
|
{
|
||||||
@ -20,11 +19,8 @@ public:
|
|||||||
|
|
||||||
QString prettyName() const override;
|
QString prettyName() const override;
|
||||||
|
|
||||||
Calamares::JobList jobs() const override;
|
|
||||||
|
|
||||||
void setConfigurationMap( const QVariantMap& configurationMap ) override;
|
|
||||||
|
|
||||||
void onActivate() override;
|
void onActivate() override;
|
||||||
|
void onLeave() override;
|
||||||
|
|
||||||
QVariantMap packageSelections() const { return m_packageSelections; }
|
QVariantMap packageSelections() const { return m_packageSelections; }
|
||||||
void setPackageSelections(const QVariantMap &value);
|
void setPackageSelections(const QVariantMap &value);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
update_db: true
|
update_db: false
|
||||||
backend: apt
|
backend: apt
|
||||||
operations:
|
operations:
|
||||||
- remove:
|
- remove:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user