diff --git a/src/libcalamares/PythonHelper.cpp b/src/libcalamares/PythonHelper.cpp index a207fe8cd..1f680699e 100644 --- a/src/libcalamares/PythonHelper.cpp +++ b/src/libcalamares/PythonHelper.cpp @@ -234,7 +234,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() ) diff --git a/src/modules/packages/main.py b/src/modules/packages/main.py index bbee9c32d..60ede34fa 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) @@ -422,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"): + libcalamares.utils.debug( "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 6e3af05a8..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 # @@ -29,9 +40,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 +61,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 +86,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 #