Merge lp:~brian-murray/ubuntu-release-upgrader/deb-to-snap into lp:ubuntu-release-upgrader

Proposed by Brian Murray
Status: Merged
Merged at revision: 3144
Proposed branch: lp:~brian-murray/ubuntu-release-upgrader/deb-to-snap
Merge into: lp:ubuntu-release-upgrader
Diff against target: 101 lines (+76/-0)
1 file modified
DistUpgrade/DistUpgradeQuirks.py (+76/-0)
To merge this branch: bzr merge lp:~brian-murray/ubuntu-release-upgrader/deb-to-snap
Reviewer Review Type Date Requested Status
Steve Langasek Approve
Review via email: mp+348916@code.launchpad.net
To post a comment you must log in.
3142. By Brian Murray

fix merge conflict

3143. By Brian Murray

really fix merge conflict

Revision history for this message
Steve Langasek (vorlon) :
review: Needs Fixing
3144. By Brian Murray

DistUpgradeQuirks.py: adjust language based on reviewer feedback, raise a dialog instead of aborting the upgrade

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

I've made most of the changes suggested.

Revision history for this message
Steve Langasek (vorlon) wrote :

The changes all look good; I think we still need to sort out the timeout on the snap downloads before pushing this through.

Revision history for this message
Steve Langasek (vorlon) wrote :

FWIW I think it would be nicer if the prompt offered to "retry" the failed snap store check, rather than being just a yes/no dialog; but I don't think that should block this MP.

3145. By Brian Murray

DistUpgradeQuirks.py: wait for the snap install to complete rather than using a timeout

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

On Thu, Jul 05, 2018 at 07:24:45PM -0000, Steve Langasek wrote:
> The changes all look good; I think we still need to sort out the timeout on the snap downloads before pushing this through.

That's sorted with my latest change.

--
Brian Murray

3146. By Brian Murray

DistUpgradeQuirks.py: modify the quirks for cosmic

Revision history for this message
Steve Langasek (vorlon) :
review: Approve
3147. By Brian Murray

clarify docstring

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'DistUpgrade/DistUpgradeController.py'
2=== modified file 'DistUpgrade/DistUpgradeQuirks.py'
3--- DistUpgrade/DistUpgradeQuirks.py 2018-07-05 23:22:00 +0000
4+++ DistUpgrade/DistUpgradeQuirks.py 2018-07-06 18:05:00 +0000
5@@ -122,6 +122,19 @@
6 """ run before the apt cache is opened the first time """
7 logging.debug("running Quirks.PreCacheOpen")
8
9+ # individual quirks handler that run *after* the cache is opened
10+ def cosmicPostInitialUpdate(self):
11+ #PreCacheOpen would be better but controller.abort fails terribly
12+ """ run after the apt cache is opened the first time """
13+ logging.debug("running Quirks.cosmicPostInitialUpdate")
14+ if self.controller.cache['ubuntu-desktop'].is_installed:
15+ self._checkStoreConnectivity()
16+
17+ def cosmicPostUpgrade(self):
18+ logging.debug("running Quirks.cosmicPostUpgrade")
19+ if self.controller.cache['ubuntu-desktop'].is_installed:
20+ self._replaceDebsWithSnaps()
21+
22 # individual quirks handler when the dpkg run is finished ---------
23 def PostCleanup(self):
24 " run after cleanup "
25@@ -129,6 +142,7 @@
26
27 # run right before the first packages get installed
28 def StartUpgrade(self):
29+ logging.debug("running Quirks.StartUpgrade")
30 self._applyPatches()
31 self._removeOldApportCrashes()
32 self._killUpdateNotifier()
33@@ -416,6 +430,68 @@
34 except Exception as e:
35 logging.warning("error during unlink of old crash files (%s)" % e)
36
37+ def _checkStoreConnectivity(self):
38+ """ check for connectivity to the snap store to install snaps"""
39+ msg = ""
40+ summary = ""
41+ connected = Popen(["snap", "debug", "connectivity"], stdout=PIPE,
42+ stderr=PIPE, universal_newlines=True).communicate()
43+ if re.search("^ \* PASS", connected[0], re.MULTILINE):
44+ return
45+ # can't connect
46+ elif re.search("^ \*.*unreachable", connected[0], re.MULTILINE):
47+ logging.error("No snap store connectivity")
48+ res = self._view.askYesNoQuestion(
49+ _("Connection to Snap Store failed"),
50+ _("Your system does not have a connection to the Snap "
51+ "Store. For the best upgrade experience make sure "
52+ "that your system can connect to api.snapcraft.io.\n"
53+ "Do you still want to continue with the upgrade?")
54+ )
55+ # debug command not available
56+ elif 'error: unknown command' in connected[1]:
57+ logging.error("snap debug command not available")
58+ res = self._view.askYesNoQuestion(
59+ _("Outdated snapd package"),
60+ _("Your system does not have the latest version of snapd. "
61+ "Please update the version of snapd on your system to "
62+ "improve the upgrade experience.\n"
63+ "Do you still want to continue with the upgrade?")
64+ )
65+ # not running as root
66+ elif 'error: access denied' in connected[1]:
67+ res = False
68+ logging.error("Not running as root!")
69+ if not res:
70+ self.controller.abort()
71+
72+ def _replaceDebsWithSnaps(self):
73+ """ install a snap and mark its corresponding package for removal """
74+ # gtk-common-themes isn't a package name but is this risky?
75+ snaps = ['gtk-common-themes', 'gnome-calculator', 'gnome-characters',
76+ 'gnome-logs', 'gnome-system-monitor']
77+ installed_snaps = subprocess.Popen(["snap", "list"], stdout=PIPE,
78+ universal_newlines=True).communicate()
79+ for snap in snaps:
80+ installed = False
81+ # check to see if the snap is already installed
82+ if re.search("^%s " % snap, installed_snaps[0], re.MULTILINE):
83+ logging.debug("Snap %s is already installed" % snap)
84+ installed = True
85+ if not installed:
86+ try:
87+ proc = subprocess.run(["snap", "install", "--channel",
88+ "stable/ubuntu-18.04", snap],
89+ stdout=subprocess.PIPE,
90+ check=True)
91+ except subprocess.CalledProcessError:
92+ logging.debug("Install of snap %s failed" % snap)
93+ if proc.returncode == 0:
94+ logging.debug("Install of snap %s succeeded" % snap)
95+ installed = True
96+ if installed:
97+ self.controller.forced_obsoletes.append(snap)
98+
99 def _checkPae(self):
100 " check PAE in /proc/cpuinfo "
101 # upgrade from Precise will fail if PAE is not in cpu flags

Subscribers

People subscribed via source and target branches