Merge ~slyon/ubuntu-release-upgrader:slyon/focal-python2-fix into ubuntu-release-upgrader:ubuntu/focal

Proposed by Lukas Märdian
Status: Merged
Approved by: Brian Murray
Approved revision: fec707f21a0420e5638a9c1ea6c67099da180b17
Merged at revision: 8768467e87a8ef12525fa59137602095a2230a4e
Proposed branch: ~slyon/ubuntu-release-upgrader:slyon/focal-python2-fix
Merge into: ubuntu-release-upgrader:ubuntu/focal
Diff against target: 91 lines (+32/-3)
2 files modified
DistUpgrade/DistUpgradeCache.py (+9/-0)
DistUpgrade/DistUpgradeQuirks.py (+23/-3)
Reviewer Review Type Date Requested Status
Brian Murray Approve
Dimitri John Ledkov lgtm Approve
Review via email: mp+387057@code.launchpad.net

Description of the change

Split the python_is_python2 quirk into a "prepare stage" (before calculating the dist-upgrade), where python-minimal is removed to avoid it producing any conflicts with packages depending on 'python' or 'python-minimal' and a "install stage" (after calculating the dist-upgrade), where the python-is-python2 package is installed to provide a clean upgrade path.

Fixes LP: #1875523

To post a comment you must log in.
Revision history for this message
Brian Murray (brian-murray) wrote :

While this looks fine, I've tested the diff on a bionic virtual machine on which I've applied the apt-clone file in bug 1875523 and I wasn't able to upgrade. Is there something else wrong with the packages in that clone file? Is there another way I can test this?

review: Needs Information
Revision history for this message
Lukas Märdian (slyon) wrote :

Hmmm... I used the apt-clone file and traced it down to this minimal reproducer:

host:~$ multipass launch -n repr bionic && multipass shell repr

guest:~$ sudo apt update && sudo apt -y upgrade && sudo apt -y install python-pyside python-gi && sudo reboot

host:~$ multipass shell repr

guest:~$ sudo do-release-upgrade -d

The patch works with this minimal reproducer.

But let my try again with the full apt-clone state...

Revision history for this message
Lukas Märdian (slyon) wrote :

I pushed a commit, which fixes the upgrade for the full apt-clone state of LP #1875523 as well.

Revision history for this message
Dimitri John Ledkov (xnox) :
review: Approve (lgtm)
Revision history for this message
Lukas Märdian (slyon) wrote :

The release notes for Focal have been updated accordingly:

https://wiki.ubuntu.com/FocalFossa/ReleaseNotes#Python3_by_default

Revision history for this message
Brian Murray (brian-murray) wrote :

This looks good to me, thanks for working on it. I think this should also be merged into the master branch for ubuntu-release-upgrader so that we have the "PreDistUpgradeCache" quirks available in the future.

review: Approve
Revision history for this message
Lukas Märdian (slyon) wrote :

Thanks for the review, Brian!

I applied the same patches to the master branch and prepared a MP for it here:

https://code.launchpad.net/~slyon/ubuntu-release-upgrader/+git/ubuntu-release-upgrader/+merge/387577

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/DistUpgrade/DistUpgradeCache.py b/DistUpgrade/DistUpgradeCache.py
index 8d9ba57..b2dd086 100644
--- a/DistUpgrade/DistUpgradeCache.py
+++ b/DistUpgrade/DistUpgradeCache.py
@@ -488,6 +488,12 @@ class MyCache(apt.Cache):
488 self._keep_installed(pkg.name, "%s KeepInstalledSection rule: %s" % (key, section))488 self._keep_installed(pkg.name, "%s KeepInstalledSection rule: %s" % (key, section))
489489
490490
491 def pre_upgrade_rule(self):
492 " run before the upgrade was done in the cache "
493 # run the quirks handlers
494 if not self.partialUpgrade:
495 self.quirks.run("PreDistUpgradeCache")
496
491 def post_upgrade_rule(self):497 def post_upgrade_rule(self):
492 " run after the upgrade was done in the cache "498 " run after the upgrade was done in the cache "
493 for (rule, action) in [("Install", self.mark_install),499 for (rule, action) in [("Install", self.mark_install),
@@ -614,6 +620,9 @@ class MyCache(apt.Cache):
614 # mvo: disabled as it casues to many errornous installs620 # mvo: disabled as it casues to many errornous installs
615 #self._apply_dselect_upgrade()621 #self._apply_dselect_upgrade()
616622
623 # run PreDistUpgradeCache quirks
624 self.pre_upgrade_rule()
625
617 # upgrade (and make sure this way that the cache is ok)626 # upgrade (and make sure this way that the cache is ok)
618 self.upgrade(True)627 self.upgrade(True)
619628
diff --git a/DistUpgrade/DistUpgradeQuirks.py b/DistUpgrade/DistUpgradeQuirks.py
index 24bd563..4c4b545 100644
--- a/DistUpgrade/DistUpgradeQuirks.py
+++ b/DistUpgrade/DistUpgradeQuirks.py
@@ -67,6 +67,8 @@ class DistUpgradeQuirks(object):
67 to set options that affect the cache67 to set options that affect the cache
68 - PostInitialUpdate: run *before* the sources.list is rewritten but68 - PostInitialUpdate: run *before* the sources.list is rewritten but
69 after an initial apt-get update69 after an initial apt-get update
70 - PreDistUpgradeCache: run *right before* the dist-upgrade is
71 calculated in the cache
70 - PostDistUpgradeCache: run *after* the dist-upgrade was calculated72 - PostDistUpgradeCache: run *after* the dist-upgrade was calculated
71 in the cache73 in the cache
72 - StartUpgrade: before the first package gets installed (but the74 - StartUpgrade: before the first package gets installed (but the
@@ -157,13 +159,19 @@ class DistUpgradeQuirks(object):
157 self._pokeScreensaver()159 self._pokeScreensaver()
158 self._stopDocvertConverter()160 self._stopDocvertConverter()
159161
162 # individual quirks handler that run *right before* the dist-upgrade
163 # is calculated in the cache
164 def PreDistUpgradeCache(self):
165 """ run right before calculating the dist-upgrade """
166 logging.debug("running Quirks.PreDistUpgradeCache")
167 self._install_python_is_python2()
168
160 # individual quirks handler that run *after* the dist-upgrade was169 # individual quirks handler that run *after* the dist-upgrade was
161 # calculated in the cache170 # calculated in the cache
162 def PostDistUpgradeCache(self):171 def PostDistUpgradeCache(self):
163 """ run after calculating the dist-upgrade """172 """ run after calculating the dist-upgrade """
164 logging.debug("running Quirks.PostDistUpgradeCache")173 logging.debug("running Quirks.PostDistUpgradeCache")
165 self._install_linux_metapackage()174 self._install_linux_metapackage()
166 self._install_python_is_python2()
167175
168 # helpers176 # helpers
169 def _get_pci_ids(self):177 def _get_pci_ids(self):
@@ -836,8 +844,9 @@ class DistUpgradeQuirks(object):
836844
837 def _install_python_is_python2(self):845 def _install_python_is_python2(self):
838 """846 """
839 Ensure the python-is-python2 is installed if python-minimal847 Ensure python is removed, before it can produce a conflict with any
840 was installed.848 other package and the python-is-python2 package is installed instead,
849 if python-minimal was installed.
841 """850 """
842 old = 'python-minimal'851 old = 'python-minimal'
843 new = 'python-is-python2'852 new = 'python-is-python2'
@@ -847,6 +856,17 @@ class DistUpgradeQuirks(object):
847 reason = "%s was installed on the system" % old856 reason = "%s was installed on the system" % old
848 if not cache.mark_install(new, reason):857 if not cache.mark_install(new, reason):
849 logging.info("failed to install %s" % new)858 logging.info("failed to install %s" % new)
859 logging.info("removing %s because %s is being installed" % (old, new))
860 reason = "%s is being installed on the system" % new
861 if not cache.mark_remove(old, reason):
862 logging.info("failed to remove %s", old)
863
864 # protect our decision to remove legacy 'python' (as a dependency
865 # of python-minimal, removed above)
866 py = 'python'
867 if py in cache and cache[py].marked_delete:
868 resolver = apt.cache.ProblemResolver(cache)
869 resolver.protect(cache[py])
850870
851 def ensure_recommends_are_installed_on_desktops(self):871 def ensure_recommends_are_installed_on_desktops(self):
852 """ ensure that on a desktop install recommends are installed872 """ ensure that on a desktop install recommends are installed

Subscribers

People subscribed via source and target branches