Merge lp:~sil2100/update-manager/ignore_prompt_lts_for_non-lts into lp:update-manager

Proposed by Łukasz Zemczak on 2018-08-28
Status: Merged
Merged at revision: 2827
Proposed branch: lp:~sil2100/update-manager/ignore_prompt_lts_for_non-lts
Merge into: lp:update-manager
Diff against target: 92 lines (+37/-4)
4 files modified
UpdateManager/Core/MetaRelease.py (+12/-4)
debian/changelog (+8/-0)
debian/control (+1/-0)
tests/test_meta_release_core.py (+16/-0)
To merge this branch: bzr merge lp:~sil2100/update-manager/ignore_prompt_lts_for_non-lts
Reviewer Review Type Date Requested Status
Brian Murray 2018-08-28 Approve on 2018-08-28
Review via email: mp+353851@code.launchpad.net

Commit message

Ignore Prompt=lts for non-LTS series. This way if a user is on a non-LTS and has Prompt=lts, he/she will be upgraded to the next supported series until finally reaching an LTS.

Description of the change

Ignore Prompt=lts for non-LTS series. This way if a user is on a non-LTS and has Prompt=lts, he/she will be upgraded to the next supported series until finally reaching an LTS.

As mentioned by Brian, this will probably require some dependency changes in the ubuntu-release-upgrader as well since now MetaReleaseCore is using distro_info to check for the lts status.

To post a comment you must log in.
Brian Murray (brian-murray) wrote :

This looks good to me, I just have a couple of in-line comments.

review: Approve
2828. By Łukasz Zemczak on 2018-08-29

Small correction in a comment.

2829. By Łukasz Zemczak on 2018-08-29

Stop using 'type' as a variable name. It's a bad python variable name.

Łukasz Zemczak (sil2100) wrote :

Done! Thanks for the review!

2830. By Łukasz Zemczak on 2018-08-30

Proposition: since MetaRelease.py uses distro-info now, I guess it's most logical to make it depend on it?

Brian Murray (brian-murray) wrote :

MetaRelease.py is included in the package python3-update-manager and python3-distupgrade so I think both of those should depend on distro-info.

Łukasz Zemczak (sil2100) wrote :

Ok, so leaving this as is - will you merge it once you have a moment today?

I can provide a dep addition to ubuntu-release-upgrader although I personally don't think it's needed. I didn't do it before as python3-distupgrade already depends on python3-update-manager, which after this merge lands will be pulling in the dependency of distro-info already. But I can understand if you want to add an explicit dep for clarity though.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'UpdateManager/Core/MetaRelease.py'
2--- UpdateManager/Core/MetaRelease.py 2018-03-15 10:22:01 +0000
3+++ UpdateManager/Core/MetaRelease.py 2018-08-30 08:12:18 +0000
4@@ -24,6 +24,7 @@
5
6 import apt
7 import apt_pkg
8+import distro_info
9 try:
10 import configparser
11 except ImportError:
12@@ -143,14 +144,21 @@
13 return
14 # now check which specific url to use
15 if parser.has_option("DEFAULT", "Prompt"):
16- type = parser.get("DEFAULT", "Prompt").lower()
17- if (type == "never" or type == "no"):
18+ prompt = parser.get("DEFAULT", "Prompt").lower()
19+ if (prompt == "never" or prompt == "no"):
20 # nothing to do for this object
21 # FIXME: what about no longer supported?
22 self.downloaded.set()
23 return
24- elif type == "lts":
25- self.METARELEASE_URI = self.METARELEASE_URI_LTS
26+ elif prompt == "lts":
27+ # the Prompt=lts setting only makes sense when running on
28+ # a LTS, otherwise it would result in users not receiving
29+ # any distro upgrades
30+ di = distro_info.UbuntuDistroInfo()
31+ if di.is_lts(self.current_dist_name):
32+ self.METARELEASE_URI = self.METARELEASE_URI_LTS
33+ else:
34+ self._debug("Prompt=lts for non-LTS, ignoring")
35 # needed for the _tryUpgradeSelf() code in DistUpgradeController
36 if forceLTS:
37 self.METARELEASE_URI = self.METARELEASE_URI_LTS
38
39=== modified file 'debian/changelog'
40--- debian/changelog 2018-06-27 12:16:47 +0000
41+++ debian/changelog 2018-08-30 08:12:18 +0000
42@@ -1,3 +1,11 @@
43+update-manager (1:18.10.4) UNRELEASED; urgency=medium
44+
45+ * Ignore Prompt=lts for non-LTS series. This way if a user is on a non-LTS
46+ and has Prompt=lts, he/she will be upgraded to the next supported series
47+ until finally reaching an LTS. (LP: #1783328)
48+
49+ -- Łukasz 'sil2100' Zemczak <lukasz.zemczak@ubuntu.com> Tue, 28 Aug 2018 13:20:08 +0200
50+
51 update-manager (1:18.10.3) cosmic; urgency=medium
52
53 * Add support for HTTPS proxies; this breaks UpdateManager.Core.utils.init_proxy()
54
55=== modified file 'debian/control'
56--- debian/control 2018-04-12 18:06:59 +0000
57+++ debian/control 2018-08-30 08:12:18 +0000
58@@ -45,6 +45,7 @@
59 Depends: ${python3:Depends},
60 ${misc:Depends},
61 python3-apt (>= 0.8.5~),
62+ python3-distro-info,
63 python3-distupgrade,
64 lsb-release,
65 Suggests: python3-launchpadlib,
66
67=== modified file 'tests/test_meta_release_core.py'
68--- tests/test_meta_release_core.py 2017-08-07 23:14:56 +0000
69+++ tests/test_meta_release_core.py 2018-08-30 08:12:18 +0000
70@@ -166,6 +166,22 @@
71 self.assertTrue("<html>" in data)
72
73 @patch("UpdateManager.Core.MetaRelease.MetaReleaseCore.download")
74+ @patch("UpdateManager.Core.MetaRelease.distro_info.UbuntuDistroInfo"
75+ ".is_lts")
76+ def test_prompt_lts_ignored_for_non_lts(self, mock_is_lts, mock_download):
77+ with tempfile.NamedTemporaryFile() as f:
78+ # for non-LTS, Prompt=lts should not change the METARELEASE_URI
79+ mock_is_lts.return_value = False
80+ f.write("""
81+[DEFAULT]
82+Prompt=lts
83+""".encode("utf-8"))
84+ f.flush()
85+ with patch.object(MetaReleaseCore, "CONF", f.name):
86+ meta = MetaReleaseCore()
87+ self.assertNotEqual(meta.METARELEASE_URI, meta.METARELEASE_URI_LTS)
88+
89+ @patch("UpdateManager.Core.MetaRelease.MetaReleaseCore.download")
90 def test_parse_fails_for_all_non_tagfiles(self, mock_download):
91 meta = MetaReleaseCore()
92 with tempfile.TemporaryFile() as f:

Subscribers

People subscribed via source and target branches

to status/vote changes: