Merge ~edugomez/ubuntu-release-upgrader:no-restart-wsl into ubuntu-release-upgrader:ubuntu/main

Proposed by Edu Gómez Escandell
Status: Merged
Merged at revision: 14196b3143fbbbec9cc720234708b131efa2e05b
Proposed branch: ~edugomez/ubuntu-release-upgrader:no-restart-wsl
Merge into: ubuntu-release-upgrader:ubuntu/main
Diff against target: 68 lines (+28/-3)
3 files modified
DistUpgrade/DistUpgradeController.py (+12/-3)
DistUpgrade/DistUpgradeView.py (+10/-0)
debian/changelog (+6/-0)
Reviewer Review Type Date Requested Status
Ubuntu Core Development Team Pending
Review via email: mp+425846@code.launchpad.net

Commit message

DistUpgrade: No longer attempting to reboot in WSL (LP: #1958668).

Description of the change

On WSL, at the end of a do-release-upgrade, the upgrader proposes to reboot the machine and then fails to do so. This happens because it is not possible to reboot, due to the lack of systemd. This results in an error.

There is no clean way of restarting from within WSL, so the solution is to ask the user to close all other Ubuntu WSL instances before the current one, and signal the Launcher to restart after quitting. This will kill all instances of Ubuntu WSL, hence why the user is advised to close the others first.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/DistUpgrade/DistUpgradeController.py b/DistUpgrade/DistUpgradeController.py
2index 6571ebb..7fe796e 100644
3--- a/DistUpgrade/DistUpgradeController.py
4+++ b/DistUpgrade/DistUpgradeController.py
5@@ -2026,9 +2026,14 @@ class DistUpgradeController(object):
6 self._view.updateStatus(_("System upgrade is complete."))
7 get_telemetry().done()
8 # FIXME should we look into /var/run/reboot-required here?
9- if (not inside_chroot() and
10- self._view.confirmRestart()):
11- subprocess.Popen("/sbin/reboot")
12+ if not inside_chroot():
13+ if self._inside_WSL():
14+ self._view.adviseExitOtherWSL()
15+ with open("/run/launcher-command", "w+", encoding="utf-8") as f:
16+ f.write("action: reboot\n")
17+ self._view.adviseRestartWSL()
18+ elif self._view.confirmRestart():
19+ subprocess.Popen("/sbin/reboot")
20 sys.exit(0)
21 return True
22
23@@ -2126,6 +2131,10 @@ class DistUpgradeController(object):
24
25 os.seteuid(int(uid))
26
27+ def _inside_WSL(self):
28+ return os.path.exists("/proc/sys/fs/binfmt_misc/WSLInterop")
29+
30+
31 if __name__ == "__main__":
32 from .DistUpgradeViewText import DistUpgradeViewText
33 logging.basicConfig(level=logging.DEBUG)
34diff --git a/DistUpgrade/DistUpgradeView.py b/DistUpgrade/DistUpgradeView.py
35index 3611c89..9f9f34b 100644
36--- a/DistUpgrade/DistUpgradeView.py
37+++ b/DistUpgrade/DistUpgradeView.py
38@@ -430,6 +430,16 @@ class DistUpgradeView(object):
39 "Do you want to do this "
40 "now?")
41 return self.askYesNoQuestion(summary, msg)
42+ def adviseExitOtherWSL(self):
43+ summary = _("Action required")
44+ msg = _("Exit all other instances of Ubuntu WSL before continuing.")
45+ extended = _("Unsaved progress may otherwise be lost.")
46+ return self.information(summary, msg, extended)
47+ def adviseRestartWSL(self):
48+ summary = _("WSL restart required")
49+ msg = _("Exit this instance of Ubuntu WSL.")
50+ extended = _("The upgrade will then be complete.")
51+ return self.information(summary, msg, extended)
52 def error(self, summary, msg, extended_msg=None):
53 " display a error "
54 pass
55diff --git a/debian/changelog b/debian/changelog
56index ba99ee1..66ff85a 100644
57--- a/debian/changelog
58+++ b/debian/changelog
59@@ -1,3 +1,9 @@
60+ubuntu-release-upgrader (1:22.10.5~ppa1) UNRELEASED; urgency=medium
61+
62+ * DistUpgrade: No longer attempting to reboot in WSL (LP: #1958668).
63+
64+ -- Edu Gómez Escandell <edu.gomez.escandell@canonical.com> Wed, 29 Jun 2022 09:13:09 +0200
65+
66 ubuntu-release-upgrader (1:22.10.4) kinetic; urgency=medium
67
68 * DistUpgrade: Add deb2snap entry for snapd-desktop-integration (LP: #1975747).

Subscribers

People subscribed via source and target branches