From fe61925f31379a17de498248ff60ab9d9f80b952 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 1 Dec 2017 13:46:59 -0500 Subject: [PATCH 1/7] [packages] Update module documentation --- src/modules/packages/packages.conf | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/modules/packages/packages.conf b/src/modules/packages/packages.conf index 6e3af05a8..6cccfc490 100644 --- a/src/modules/packages/packages.conf +++ b/src/modules/packages/packages.conf @@ -29,9 +29,10 @@ update_db: true # packages that need to be installed or removed can run before # this one. Distro developers may want to install locale packages # or remove drivers not needed on the installed system. -# This job will populate a list of dictionaries in the global -# storage called "packageOperations" and it is processed -# after the static list in the job configuration. +# Such a job would populate a list of dictionaries in the global +# storage called "packageOperations" and that list is processed +# after the static list in the job configuration (i.e. the list +# that is in this configuration file). # # Allowed package operations are: # - install, try_install: will call the package manager to @@ -49,7 +50,7 @@ update_db: true # while try_remove carries on. Packages may be listed as # (localized) names. # -# There are two formats for naming packages: as a name # or as package-data, +# There are two formats for naming packages: as a name or as package-data, # which is an object notation providing package-name, as well as pre- and # post-install scripts. # @@ -74,15 +75,16 @@ update_db: true # # - if the system locale is English (generally US English; en_GB is a valid # localization), then the package is not installed at all, -# - otherwise LOCALE is replaced by the Bcp47 name of the selected system -# locale, e.g. nl_BE. +# - otherwise $LOCALE or ${LOCALE} is replaced by the Bcp47 name of the selected +# system locale, e.g. nl_BE. Note that just plain LOCALE will not be replaced, +# so foo-LOCALE will be unchanged, while foo-$LOCALE will be changed. # # The following installs localizations for vi, if they are relevant; if # there is no localization, installation continues normally. # # - install -# - vi-LOCALE -# - package: vi-LOCALE +# - vi-$LOCALE +# - package: vi-${LOCALE} # pre-script: touch /tmp/installing-vi # post-script: rm -f /tmp/installing-vi # From 517dbfab06cd78838e1f504fbe05369bd2989009 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 1 Dec 2017 16:42:56 -0500 Subject: [PATCH 2/7] [libcalamares] The script namespace is actually a dict Use dict methods, in particular d.get(k, v), to retrieve the pretty_name() function (or None if it isn't there). Using getattr() on a dict will not return values in the dict. --- src/libcalamares/PythonHelper.cpp | 2 +- src/libcalamares/PythonHelper.h | 2 +- src/libcalamares/PythonJob.cpp | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/libcalamares/PythonHelper.cpp b/src/libcalamares/PythonHelper.cpp index bb698ba55..ab5802076 100644 --- a/src/libcalamares/PythonHelper.cpp +++ b/src/libcalamares/PythonHelper.cpp @@ -233,7 +233,7 @@ Helper::~Helper() {} -boost::python::object +boost::python::dict Helper::createCleanNamespace() { // To make sure we run each script with a clean namespace, we only fetch the diff --git a/src/libcalamares/PythonHelper.h b/src/libcalamares/PythonHelper.h index a77ab80b2..be1ab8544 100644 --- a/src/libcalamares/PythonHelper.h +++ b/src/libcalamares/PythonHelper.h @@ -51,7 +51,7 @@ public: explicit Helper( QObject* parent = nullptr ); virtual ~Helper(); - boost::python::object createCleanNamespace(); + boost::python::dict createCleanNamespace(); QString handleLastError(); diff --git a/src/libcalamares/PythonJob.cpp b/src/libcalamares/PythonJob.cpp index 1a8a9701a..006fd86b6 100644 --- a/src/libcalamares/PythonJob.cpp +++ b/src/libcalamares/PythonJob.cpp @@ -216,10 +216,10 @@ BOOST_PYTHON_MODULE( libcalamares ) "in the original string." ); - - bp::def( - "gettext_languages", - &CalamaresPython::gettext_languages, + + bp::def( + "gettext_languages", + &CalamaresPython::gettext_languages, "Returns list of languages (most to least-specific) for gettext." ); @@ -296,7 +296,7 @@ PythonJob::exec() try { - bp::object scriptNamespace = helper()->createCleanNamespace(); + bp::dict scriptNamespace = helper()->createCleanNamespace(); bp::object calamaresModule = bp::import( "libcalamares" ); bp::dict calamaresNamespace = bp::extract< bp::dict >( calamaresModule.attr( "__dict__" ) ); @@ -310,7 +310,7 @@ PythonJob::exec() scriptNamespace ); bp::object entryPoint = scriptNamespace[ "run" ]; - bp::object prettyNameFunc = bp::getattr(scriptNamespace, "pretty_name", bp::object()); + bp::object prettyNameFunc = scriptNamespace.get("pretty_name", bp::object()); cDebug() << "Job file" << scriptFI.absoluteFilePath(); if ( !prettyNameFunc.is_none() ) From 7b145c2a36b0185877bdde243b05cc5b177d7494 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Fri, 1 Dec 2017 16:48:02 -0500 Subject: [PATCH 3/7] [packages] Improve message when no packages are processed at all. --- src/modules/packages/main.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/modules/packages/main.py b/src/modules/packages/main.py index bbee9c32d..9555a0433 100644 --- a/src/modules/packages/main.py +++ b/src/modules/packages/main.py @@ -55,8 +55,12 @@ def _change_mode(mode): def pretty_name(): if not group_packages: - # Outside the context of an operation - s = _("Processing packages (%(count)d / %(total)d)") + if (total_packages > 0): + # Outside the context of an operation + s = _("Processing packages (%(count)d / %(total)d)") + else: + s = _("Install packages.") + elif mode_packages is INSTALL: s = _n("Installing one package.", "Installing %(num)d packages.", group_packages) From 150007c138aa7fcaadfdedfa635d9a8681240018 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sat, 2 Dec 2017 05:04:30 -0500 Subject: [PATCH 4/7] [packages] Feature: skip if no internet. Update documentation, add a new key *skip_if_no_internet* to support systems that **recommend** having an internet connection (but don't require it), and which also use the packages module. This prevents a long delay while the package manager tries to access the internet and times out (repeatedly). Existing configurations are unchanged. --- src/modules/packages/main.py | 5 +++++ src/modules/packages/packages.conf | 17 ++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/modules/packages/main.py b/src/modules/packages/main.py index 9555a0433..49f3ea2ff 100644 --- a/src/modules/packages/main.py +++ b/src/modules/packages/main.py @@ -426,6 +426,11 @@ def run(): else: return "Bad backend", "backend=\"{}\"".format(backend) + skip_this = libcalamares.job.configuration.get("skip_if_no_internet", false) + if skip_this and not libcalamares.globalstorage.value("hasInternet"): + cDebug() << "WARNING: packages installation has been skipped: no internet"; + return None + update_db = libcalamares.job.configuration.get("update_db", False) if update_db and libcalamares.globalstorage.value("hasInternet"): pkgman.update_db() diff --git a/src/modules/packages/packages.conf b/src/modules/packages/packages.conf index 6cccfc490..2d6ca116f 100644 --- a/src/modules/packages/packages.conf +++ b/src/modules/packages/packages.conf @@ -14,9 +14,20 @@ # backend: dummy -# If set to true, a package-manager specific update procedure -# is run first (only if there is internet) to update the list -# of packages and dependencies. +# Often package installation needs an internet connection. +# Since you may allow system installation without a connection +# and want to offer **optional** package installation, it's +# possible to have no internet, yet have this packages module +# enabled in settings. +# +# You can skip the whole module when there is no internet +# by setting *skip_if_no_internet* to true. +# +# You can run a package-manager specific update procedure +# before installing packages (for instance, to update the +# list of packages and dependencies); this is done only if there +# is an internet connection. Set *update_db* to true to do so. +skip_if_no_internet: false update_db: true # From 3e3cd08ff355394f3638b8ca0ffeb45405a901b0 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sat, 2 Dec 2017 05:20:13 -0500 Subject: [PATCH 5/7] [packages] Fix previous (false vs False) --- src/modules/packages/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/packages/main.py b/src/modules/packages/main.py index 49f3ea2ff..64560082d 100644 --- a/src/modules/packages/main.py +++ b/src/modules/packages/main.py @@ -426,7 +426,7 @@ def run(): else: return "Bad backend", "backend=\"{}\"".format(backend) - skip_this = libcalamares.job.configuration.get("skip_if_no_internet", false) + skip_this = libcalamares.job.configuration.get("skip_if_no_internet", False) if skip_this and not libcalamares.globalstorage.value("hasInternet"): cDebug() << "WARNING: packages installation has been skipped: no internet"; return None From 65a236cd6037e555b01689292efe0796bca1c4a3 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Sat, 2 Dec 2017 06:14:17 -0500 Subject: [PATCH 6/7] [packages] Fix previous. This, kids, is why you don't switch writing C++ and Python too often. The C++ code isn't a syntax error in Python, although this would fail at runtime. --- src/modules/packages/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/packages/main.py b/src/modules/packages/main.py index 64560082d..60ede34fa 100644 --- a/src/modules/packages/main.py +++ b/src/modules/packages/main.py @@ -428,7 +428,7 @@ def run(): skip_this = libcalamares.job.configuration.get("skip_if_no_internet", False) if skip_this and not libcalamares.globalstorage.value("hasInternet"): - cDebug() << "WARNING: packages installation has been skipped: no internet"; + libcalamares.utils.debug( "WARNING: packages installation has been skipped: no internet" ) return None update_db = libcalamares.job.configuration.get("update_db", False) From 011646530310ef720314f3bc1d156c8f9deeba4b Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 7 Dec 2017 08:42:49 -0500 Subject: [PATCH 7/7] CMake: bump version --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dce53b416..960f9a734 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -166,7 +166,7 @@ set( CALAMARES_TRANSLATION_LANGUAGES ar ast bg ca cs_CZ da de el en en_GB es_MX ### Bump version here set( CALAMARES_VERSION_MAJOR 3 ) set( CALAMARES_VERSION_MINOR 1 ) -set( CALAMARES_VERSION_PATCH 9 ) +set( CALAMARES_VERSION_PATCH 10 ) set( CALAMARES_VERSION_RC 0 ) set( CALAMARES_VERSION ${CALAMARES_VERSION_MAJOR}.${CALAMARES_VERSION_MINOR}.${CALAMARES_VERSION_PATCH} )