Merge ~jibel/ubuntu-release-upgrader:fix_deb2snap_lp1856862 into ubuntu-release-upgrader:ubuntu/master

Proposed by Jean-Baptiste Lallement
Status: Merged
Merged at revision: 6283cb63d74b8c7b58813b6f38a947a464607bf7
Proposed branch: ~jibel/ubuntu-release-upgrader:fix_deb2snap_lp1856862
Merge into: ubuntu-release-upgrader:ubuntu/master
Diff against target: 91 lines (+28/-5)
5 files modified
DistUpgrade/DistUpgradeCache.py (+2/-1)
DistUpgrade/DistUpgradeQuirks.py (+14/-2)
DistUpgrade/DistUpgradeViewGtk3.py (+1/-1)
DistUpgrade/DistUpgradeViewKDE.py (+1/-1)
debian/changelog (+10/-0)
Reviewer Review Type Date Requested Status
Brian Murray Approve
Ubuntu Core Development Team Pending
Review via email: mp+376999@code.launchpad.net

Commit message

Fixes for upgrade to focal:
- Release number 19.04 -> 20.04 on UI
- Do not install snaps during upgrade if corresponding deb package is not installed
- Fixed a crash when a snap is installed but not the deb.

To post a comment you must log in.
Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :

I tested the following scenarios in an upgrade from 19.10 to 20.04:
- No snap installed (only core and core18)
- Snap package is preinstalled (refresh)
- Snap and deb are not installed (no-op)
- Deb is install but not snap (migration from deb to snap)

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

Thanks for working on this!

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

I should have tested this before merging it but I believe your changes cause the following test failure.

======================================================================
ERROR: test_prepare_snap_replacement_data (test_quirks.TestSnapQuirks)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/mock/mock.py", line 1330, in patched
    return func(*args, **keywargs)
  File "/home/bdmurray/source-trees/ubuntu-release-upgrader/ubuntu-release-upgrader/tests/test_quirks.py", line 354, in test_prepare_snap_replacement_data
    q._prepare_snap_replacement_data()
  File "/home/bdmurray/source-trees/ubuntu-release-upgrader/ubuntu-release-upgrader/DistUpgrade/DistUpgradeQuirks.py", line 857, in _prepare_snap_replacement_data
    if (snap not in cache or (snap in cache and
TypeError: argument of type 'Mock' is not iterable

Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :

I tested and the tests passed. Although I didn't try with autopkgtest. I'll do that.

Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :

$ nosetests3 test_quirks:TestSnapQuirks -v
test_calculate_snap_size_requirements (test_quirks.TestSnapQuirks) ... ok
test_get_from_and_to_version (test_quirks.TestSnapQuirks) ... ok
test_prepare_snap_replacement_data (test_quirks.TestSnapQuirks) ... ok
test_replace_debs_with_snaps (test_quirks.TestSnapQuirks) ... ok

----------------------------------------------------------------------
Ran 4 tests in 0.031s

OK

On which release do you see this failure?

Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :

I can reproduce the error in autopkgtest.

Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/DistUpgrade/DistUpgradeCache.py b/DistUpgrade/DistUpgradeCache.py
2index 5597039..0689329 100644
3--- a/DistUpgrade/DistUpgradeCache.py
4+++ b/DistUpgrade/DistUpgradeCache.py
5@@ -939,7 +939,8 @@ class MyCache(apt.Cache):
6 return False
7 # ensure we honor KeepInstalledSection here as well
8 for section in self.config.getlist("Distro", "KeepInstalledSection"):
9- if pkgname in self and self[pkgname].installed.section == section:
10+ if (pkgname in self and self[pkgname].installed and
11+ self[pkgname].installed.section == section):
12 logging.debug("skipping '%s' (in KeepInstalledSection)" % pkgname)
13 return False
14 # if we don't have the package anyway, we are fine (this can
15diff --git a/DistUpgrade/DistUpgradeQuirks.py b/DistUpgrade/DistUpgradeQuirks.py
16index 3ae7ea7..6c832b3 100644
17--- a/DistUpgrade/DistUpgradeQuirks.py
18+++ b/DistUpgrade/DistUpgradeQuirks.py
19@@ -841,14 +841,26 @@ class DistUpgradeQuirks(object):
20 if re.search("^installed: ", snap_info[0], re.MULTILINE):
21 logging.debug("Snap %s is installed" % snap)
22 # its not tracking the release channel so don't refresh
23- if not re.search("^tracking:.*%s" % from_channel,
24+ if not re.search(r"^tracking:.*%s" % from_channel,
25 snap_info[0], re.MULTILINE):
26 logging.debug("Snap %s is not tracking the release channel"
27 % snap)
28 continue
29 snap_object['command'] = 'refresh'
30 else:
31- match = re.search("snap-id:\s*(\w*)", snap_info[0])
32+ # Do not replace packages not installed
33+ # core18, gnome-3-28-1804 and gtk-common-themes do not match
34+ # any deb package so never marked for installation but
35+ # they'll be installed by dependency when the first gnome
36+ # package is installed
37+ cache = self.controller.cache
38+ if (snap not in cache or (snap in cache and
39+ not cache[snap].is_installed)):
40+ logging.debug("Deb package %s is not installed. Skipping "
41+ "snap package installation" % snap)
42+ continue
43+
44+ match = re.search(r"snap-id:\s*(\w*)", snap_info[0])
45 if not match:
46 logging.debug("Could not parse snap-id for the %s snap"
47 % snap)
48diff --git a/DistUpgrade/DistUpgradeViewGtk3.py b/DistUpgrade/DistUpgradeViewGtk3.py
49index 5b7fe9c..56a807b 100644
50--- a/DistUpgrade/DistUpgradeViewGtk3.py
51+++ b/DistUpgrade/DistUpgradeViewGtk3.py
52@@ -477,7 +477,7 @@ class DistUpgradeViewGtk3(DistUpgradeView,SimpleGtkbuilderApp):
53 pass
54
55 title_string = self.label_title.get_label()
56- title_string = title_string.replace("%s", "19.10")
57+ title_string = title_string.replace("%s", "20.04")
58 self.label_title.set_label(title_string)
59
60 # terminal stuff
61diff --git a/DistUpgrade/DistUpgradeViewKDE.py b/DistUpgrade/DistUpgradeViewKDE.py
62index 7930b63..1fd8f32 100644
63--- a/DistUpgrade/DistUpgradeViewKDE.py
64+++ b/DistUpgrade/DistUpgradeViewKDE.py
65@@ -641,7 +641,7 @@ class DistUpgradeViewKDE(DistUpgradeView):
66 name = "Kubuntu"
67 title_string = self.window_main.label_title.text()
68 title_string = title_string.replace("Ubuntu", name)
69- title_string = title_string.replace("%s", "19.10")
70+ title_string = title_string.replace("%s", "20.04")
71 self.window_main.label_title.setText(title_string)
72
73 # setup terminal text in hidden by default spot
74diff --git a/debian/changelog b/debian/changelog
75index f2e9bb0..cf12fd9 100644
76--- a/debian/changelog
77+++ b/debian/changelog
78@@ -1,3 +1,13 @@
79+ubuntu-release-upgrader (1:20.04.8) UNRELEASED; urgency=medium
80+
81+ * Do not install a snap package if the corresponding debian package is not
82+ installed (LP: #1856996)
83+ * Fixed crash when checking a section of a package when the package is a
84+ snap (LP: #1856862)
85+ * Update release to 20.04 in UI (LP: #1856948)
86+
87+ -- Jean-Baptiste Lallement <jean-baptiste.lallement@ubuntu.com> Thu, 19 Dec 2019 15:29:54 +0100
88+
89 ubuntu-release-upgrader (1:20.04.7) focal; urgency=medium
90
91 * debian/release-upgrade-motd: Fix typo preventing the update of the cached info.

Subscribers

People subscribed via source and target branches