diff -Nru ubiquity-20.04.15.4/debian/changelog ubiquity-20.04.15.5/debian/changelog --- ubiquity-20.04.15.4/debian/changelog 2021-01-21 14:29:03.000000000 +0000 +++ ubiquity-20.04.15.5/debian/changelog 2021-01-25 18:28:35.000000000 +0000 @@ -1,3 +1,17 @@ +ubiquity (20.04.15.5) focal; urgency=medium + + [ Mauricio Faria de Oliveira ] + * Add preseed option 'ubiquity/prepare_automatic' (default: false) to + include the prepare page in automatic mode. (LP: #1895351) + - debian/ubiquity.templates: add ubiquity/prepare_automatic. + - ubiquity/plugins/ubi-prepare.py: do not bail if it's true. + + [ Shih-Yuan Lee (FourDollars) ] + * install_misc.py: Use another mechanism to install the packages. (LP: + #1908023) + + -- Iain Lane Mon, 25 Jan 2021 18:28:35 +0000 + ubiquity (20.04.15.4) focal; urgency=medium * Backport Dimitri's misc.py change from groovy: unset gsd keys to trigger diff -Nru ubiquity-20.04.15.4/debian/ubiquity.templates ubiquity-20.04.15.5/debian/ubiquity.templates --- ubiquity-20.04.15.4/debian/ubiquity.templates 2021-01-21 14:26:36.000000000 +0000 +++ ubiquity-20.04.15.5/debian/ubiquity.templates 2021-01-25 18:28:35.000000000 +0000 @@ -1063,6 +1063,12 @@ Type: text _Description: Connect to this network +Template: ubiquity/prepare_automatic +Type: boolean +Default: false +Description: for internal use; can be preseeded + Include the prepare plugin in automatic mode. + Template: ubiquity/use_nonfree Type: boolean Default: false diff -Nru ubiquity-20.04.15.4/ubiquity/install_misc.py ubiquity-20.04.15.5/ubiquity/install_misc.py --- ubiquity-20.04.15.4/ubiquity/install_misc.py 2021-01-21 14:26:36.000000000 +0000 +++ ubiquity-20.04.15.5/ubiquity/install_misc.py 2021-01-25 18:28:35.000000000 +0000 @@ -38,6 +38,7 @@ from apt.cache import Cache from apt.progress.base import InstallProgress from apt.progress.text import AcquireProgress +import apt import apt_pkg import debconf @@ -524,33 +525,46 @@ return brokenpkgs -def mark_install(cache, pkg): - cachedpkg = get_cache_pkg(cache, pkg) - if cachedpkg is None: - return - if not cachedpkg.is_installed or cachedpkg.is_upgradable: - apt_error = False - try: - cachedpkg.mark_install() - except SystemError: - apt_error = True - if cache._depcache.broken_count > 0 or apt_error: - brokenpkgs = broken_packages(cache) - while brokenpkgs: - for brokenpkg in brokenpkgs: - get_cache_pkg(cache, brokenpkg).mark_keep() - new_brokenpkgs = broken_packages(cache) - if brokenpkgs == new_brokenpkgs: - break # we can do nothing more - brokenpkgs = new_brokenpkgs +def mark_install(cache, to_install): + to_install = sorted(to_install) - if cache._depcache.broken_count > 0: - # We have a conflict we couldn't solve - cache.clear() - raise InstallStepError( - "Unable to install '%s' due to conflicts." % pkg) - else: - cachedpkg.mark_auto(False) + for pkg in to_install: + cachedpkg = get_cache_pkg(cache, pkg) + if cachedpkg is None: + continue + if not cachedpkg.is_installed: + cachedpkg.mark_install(auto_fix=False, auto_inst=False, from_user=False) + elif cachedpkg.is_upgradable: + auto = cachedpkg.is_auto_installed + cachedpkg.mark_install(auto_fix=False, auto_inst=False, from_user=False) + cachedpkg.mark_auto(auto) + + for pkg in to_install: + cachedpkg = get_cache_pkg(cache, pkg) + if cachedpkg is None: + continue + if not cachedpkg.is_installed: + cachedpkg.mark_install(auto_fix=False, auto_inst=True, from_user=False) + elif cachedpkg.is_upgradable: + auto = cachedpkg.is_auto_installed + cachedpkg.mark_install(auto_fix=False, auto_inst=True, from_user=False) + cachedpkg.mark_auto(auto) + + if cache.broken_count > 0: + brokenpkgs = ", ".join(sorted(broken_packages(cache))) + syslog.syslog(syslog.LOG_WARNING, f"Try to fix these broken packages: {brokenpkgs}.") + for pkg in cache: + if pkg.marked_delete: + pkg.mark_keep() + apt.ProblemResolver(cache).resolve_by_keep() + + if cache.broken_count > 0: + brokenpkgs = ", ".join(sorted(broken_packages(cache))) + to_install = ", ".join(to_install) + # We have a conflict we couldn't solve + cache.clear() + raise InstallStepError( + f"Unable to install {to_install} due to the broken packages: {brokenpkgs}.") def expand_dependencies_simple(cache, keep, to_remove, recommends=True): @@ -934,8 +948,7 @@ return with cache.actiongroup(): - for pkg in to_install: - mark_install(cache, pkg) + mark_install(cache, to_install) self.db.progress('SET', 1) self.progress_region(1, 10) diff -Nru ubiquity-20.04.15.4/ubiquity/plugins/ubi-prepare.py ubiquity-20.04.15.5/ubiquity/plugins/ubi-prepare.py --- ubiquity-20.04.15.4/ubiquity/plugins/ubi-prepare.py 2021-01-21 14:26:36.000000000 +0000 +++ ubiquity-20.04.15.5/ubiquity/plugins/ubi-prepare.py 2021-01-25 18:28:35.000000000 +0000 @@ -73,15 +73,40 @@ self.rst_title_text = i18n.get_string('rst_header', lang) return + def db_get(self, question): + # This is a hack wrapper to use db.get() not available in PageGtk/PageKde. + + # These are safety nets for the controller attribute (which both have set) + # and also _wizard (which is set in its class constructor), just in case. + controller = self.get('controller') + if controller is None or controller._wizard is None: + return None + + # The db should be set when PageGtk/PageKde class constructors run, since + # their Wizard's class constructors initialize BaseFrontend, and it calls + # start_debconf(), before Wizard instantiates PageGtk/PageKde to get here. + # But again, just in case. + wizard = controller._wizard + db_old = wizard.db + if db_old is None: + wizard.start_debconf() + answer = wizard.db.get(question) + if db_old is None: + wizard.stop_debconf() + return answer + class PageGtk(PreparePageBase): restricted_package_name = 'ubuntu-restricted-addons' def __init__(self, controller, *args, **kwargs): - if self.is_automatic: + self.controller = controller + prepare_automatic = self.db_get('ubiquity/prepare_automatic') + if self.is_automatic and prepare_automatic != 'true': + self.debug('prepare: not included in automatic mode') self.page = None return - self.controller = controller + from ubiquity.gtkwidgets import Builder builder = Builder() self.controller.add_builder(builder) @@ -292,10 +317,13 @@ def __init__(self, controller, *args, **kwargs): from ubiquity.qtwidgets import StateBox - if self.is_automatic: + self.controller = controller + prepare_automatic = self.db_get('ubiquity/prepare_automatic') + if self.is_automatic and prepare_automatic != 'true': + self.debug('prepare: not included in automatic mode') self.page = None return - self.controller = controller + try: from PyQt5 import uic from PyQt5 import QtGui