From 9c457f944904d3e0fb490fcab3fe1ef7a35b124b Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 12 Oct 2020 23:11:00 +0200 Subject: [PATCH 1/5] [shellprocess] Improve documentation and examples --- src/modules/shellprocess/shellprocess.conf | 36 +++++++++++++++++++--- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/src/modules/shellprocess/shellprocess.conf b/src/modules/shellprocess/shellprocess.conf index 00d88851f..44b6d145a 100644 --- a/src/modules/shellprocess/shellprocess.conf +++ b/src/modules/shellprocess/shellprocess.conf @@ -24,16 +24,42 @@ # # The value of *script* may be: # - a single string; this is one command that is executed. -# - a list of strings; these are executed one at a time, by +# - a single object (this is not useful). +# - a list of items; these are executed one at a time, by # separate shells (/bin/sh -c is invoked for each command). -# - an object, specifying a key *command* and (optionally) -# a key *timeout* to set the timeout for this specific -# command differently from the global setting. +# Each list item may be: +# - a single string; this is one command that is executed. +# - a single object, specifying a key *command* and (optionally) +# a key *timeout* to set the timeout for this specific +# command differently from the global setting. +# +# Using a single object is not useful because the same effect can +# be obtained with a single string and a global timeout, but when +# there are multiple commands to execute, one of them might have +# a different timeout than the others. --- dontChroot: false timeout: 10 + +# Script may be a single string (because false returns an error exit +# code, this will trigger a failure in the installation): +# +# script: "/usr/bin/false" + +# Script may be a list of strings (because false returns an error exit +# code, **but** the command starts with a "-", the error exit is +# ignored and installation continues): +# +# script: +# - "-/usr/bin/false" +# - "/bin/ls" +# - "/usr/bin/true" + +# Script may be a lit of items (if the touch command fails, it is +# ignored; the slowloris command has a different timeout from the +# other commands in the list): script: - "-touch @@ROOT@@/tmp/thingy" - - "/usr/bin/false" + - "/usr/bin/true" - command: "/usr/local/bin/slowloris" timeout: 3600 From 2f83d85e29754915c49dc465942fcc43884e8885 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 12 Oct 2020 23:19:15 +0200 Subject: [PATCH 2/5] [libcalamares] Explain process failure in debug log a bit better --- src/libcalamares/utils/CalamaresUtilsSystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcalamares/utils/CalamaresUtilsSystem.cpp b/src/libcalamares/utils/CalamaresUtilsSystem.cpp index 8be7a16f9..dad6e5b12 100644 --- a/src/libcalamares/utils/CalamaresUtilsSystem.cpp +++ b/src/libcalamares/utils/CalamaresUtilsSystem.cpp @@ -127,7 +127,7 @@ System::runCommand( System::RunLocation location, if ( ( location == System::RunLocation::RunInTarget ) && ( !gs || !gs->contains( "rootMountPoint" ) ) ) { - cWarning() << "No rootMountPoint in global storage"; + cWarning() << "No rootMountPoint in global storage, while RunInTarget is specified"; return ProcessResult::Code::NoWorkingDirectory; } From 86fd014bbd9aadda44b5a8d5d948c3912ba860ac Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 13 Oct 2020 00:00:37 +0200 Subject: [PATCH 3/5] [libcalamares] Fallback from status -> description -> name for progress --- src/libcalamares/JobQueue.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/libcalamares/JobQueue.cpp b/src/libcalamares/JobQueue.cpp index 526cd70bf..1637f0719 100644 --- a/src/libcalamares/JobQueue.cpp +++ b/src/libcalamares/JobQueue.cpp @@ -177,6 +177,18 @@ private: const auto& jobitem = m_runningJobs->at( m_jobIndex ); progress = ( jobitem.cumulative + jobitem.weight * percentage ) / m_overallQueueWeight; message = jobitem.job->prettyStatusMessage(); + // In progress reports at the start of a job (e.g. when the queue + // starts the job, or if the job itself reports 0.0) be more + // accepting in what gets reported: jobs with no status fall + // back to description and name, whichever is non-empty. + if ( percentage == 0.0 && message.isEmpty() ) + { + message = jobitem.job->prettyDescription(); + if ( message.isEmpty() ) + { + message = jobitem.job->prettyName(); + } + } } else { From 21598ef4b3ab48ea847a6781c29bad4c0e208a00 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 13 Oct 2020 00:22:22 +0200 Subject: [PATCH 4/5] [libcalamaresui] Update progress message only if it is non-empty This improves the situation for jobs that do not provide a status: their blank status does not overwrite the status bar, and since (previous commit) the description or name is used to start the job if the status is empty, at least **something** is displayed. SEE #1528 --- src/libcalamaresui/viewpages/ExecutionViewStep.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libcalamaresui/viewpages/ExecutionViewStep.cpp b/src/libcalamaresui/viewpages/ExecutionViewStep.cpp index fe90e1ec3..e3498c62d 100644 --- a/src/libcalamaresui/viewpages/ExecutionViewStep.cpp +++ b/src/libcalamaresui/viewpages/ExecutionViewStep.cpp @@ -191,7 +191,10 @@ void ExecutionViewStep::updateFromJobQueue( qreal percent, const QString& message ) { m_progressBar->setValue( int( percent * m_progressBar->maximum() ) ); - m_label->setText( message ); + if ( !message.isEmpty() ) + { + m_label->setText( message ); + } } void From 6221c6497a73e4a16afc4a3c7412b8adf7f5c0b5 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 13 Oct 2020 00:59:47 +0200 Subject: [PATCH 5/5] [shellprocess] Allow customizing the name of the job --- src/modules/shellprocess/ShellProcessJob.cpp | 14 ++++++++++++++ src/modules/shellprocess/ShellProcessJob.h | 2 ++ src/modules/shellprocess/shellprocess.conf | 14 ++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/src/modules/shellprocess/ShellProcessJob.cpp b/src/modules/shellprocess/ShellProcessJob.cpp index ab00a0bdd..6e3db62aa 100644 --- a/src/modules/shellprocess/ShellProcessJob.cpp +++ b/src/modules/shellprocess/ShellProcessJob.cpp @@ -34,6 +34,10 @@ ShellProcessJob::~ShellProcessJob() {} QString ShellProcessJob::prettyName() const { + if ( m_name ) + { + return m_name->get(); + } return tr( "Shell Processes Job" ); } @@ -75,6 +79,16 @@ ShellProcessJob::setConfigurationMap( const QVariantMap& configurationMap ) { cWarning() << "No script given for ShellProcessJob" << moduleInstanceKey(); } + + bool labels_ok = false; + auto labels = CalamaresUtils::getSubMap( configurationMap, "i18n", labels_ok ); + if ( labels_ok ) + { + if ( labels.contains( "name" ) ) + { + m_name = std::make_unique< CalamaresUtils::Locale::TranslatedString >( labels, "name" ); + } + } } CALAMARES_PLUGIN_FACTORY_DEFINITION( ShellProcessJobFactory, registerPlugin< ShellProcessJob >(); ) diff --git a/src/modules/shellprocess/ShellProcessJob.h b/src/modules/shellprocess/ShellProcessJob.h index 468aded59..a931d1e1a 100644 --- a/src/modules/shellprocess/ShellProcessJob.h +++ b/src/modules/shellprocess/ShellProcessJob.h @@ -13,6 +13,7 @@ #include "CppJob.h" #include "DllMacro.h" +#include "locale/TranslatableConfiguration.h" #include "utils/CommandList.h" #include "utils/PluginFactory.h" @@ -37,6 +38,7 @@ public: private: std::unique_ptr< CalamaresUtils::CommandList > m_commands; + std::unique_ptr< CalamaresUtils::Locale::TranslatedString > m_name; }; CALAMARES_PLUGIN_FACTORY_DECLARATION( ShellProcessJobFactory ) diff --git a/src/modules/shellprocess/shellprocess.conf b/src/modules/shellprocess/shellprocess.conf index 44b6d145a..5d8a12d26 100644 --- a/src/modules/shellprocess/shellprocess.conf +++ b/src/modules/shellprocess/shellprocess.conf @@ -37,6 +37,8 @@ # be obtained with a single string and a global timeout, but when # there are multiple commands to execute, one of them might have # a different timeout than the others. +# +# To change the description of the job, set the *name* entries in *i18n*. --- dontChroot: false timeout: 10 @@ -63,3 +65,15 @@ script: - "/usr/bin/true" - command: "/usr/local/bin/slowloris" timeout: 3600 + +# You can change the description of the job (as it is displayed in the +# progress bar during installation) by defining an *i18n* key, which +# has a *name* field and optionally, translations as *name[lang]*. +# +# Without a translation here, the default name from the source code +# is used, "Shell Processes Job". +# +# i18n: +# name: "Shell process" +# name[nl]: "Schelpenpad" +# name[en_GB]: "Just a moment"