Merge ~enr0n/ubuntu-release-upgrader:lp.1968607 into ubuntu-release-upgrader:ubuntu/main

Proposed by Nick Rosbrook
Status: Merged
Merged at revision: b183299b7b57d6b19f472c59ceb964632b6268d5
Proposed branch: ~enr0n/ubuntu-release-upgrader:lp.1968607
Merge into: ubuntu-release-upgrader:ubuntu/main
Diff against target: 160 lines (+72/-17)
4 files modified
DistUpgrade/DistUpgradeController.py (+12/-10)
data/do-release-upgrade.8 (+28/-7)
debian/changelog (+9/-0)
do-release-upgrade (+23/-0)
Reviewer Review Type Date Requested Status
Brian Murray Approve
Review via email: mp+419332@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Brian Murray (brian-murray) :
review: Approve

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 34b806f..29002e6 100644
3--- a/DistUpgrade/DistUpgradeController.py
4+++ b/DistUpgrade/DistUpgradeController.py
5@@ -2092,24 +2092,26 @@ class DistUpgradeController(object):
6 screensaver = dbus.Interface(proxy, dbus_interface='org.freedesktop.ScreenSaver')
7 screensaver.Inhibit('ubuntu-release-upgrader', 'Upgrading Ubuntu')
8
9- self._view.information(_("Lock screen disabled"),
10- _("Your lock screen has been "
11- "disabled and will remain "
12- "disabled during the upgrade."))
13+ summary = _("Lock screen disabled")
14+ message = _("Your lock screen has been "
15+ "disabled and will remain "
16+ "disabled during the upgrade.")
17 except dbus.exceptions.DBusException as e:
18 if not os.getenv('XDG_SESSION_TYPE'):
19 return
20
21 logging.debug('failed to inhibit screensaver: ' + str(e))
22- self._view.information(_("Unable to disable lock screen"),
23- _("It is highly recommended that the "
24- "lock screen be disabled during the "
25- "upgrade to prevent later issues. "
26- "Please ensure your screen lock is "
27- "disabled before continuing."))
28+ summary = _("Unable to disable lock screen")
29+ message = _("It is highly recommended that the "
30+ "lock screen be disabled during the "
31+ "upgrade to prevent later issues. "
32+ "Please ensure your screen lock is "
33+ "disabled before continuing.")
34 finally:
35 os.seteuid(os.getuid())
36
37+ self._view.information(summary, message)
38+
39 def _setNonRootEUID(self):
40 if os.getuid() != 0:
41 return
42diff --git a/data/do-release-upgrade.8 b/data/do-release-upgrade.8
43index ea3dd8f..9873d6f 100644
44--- a/data/do-release-upgrade.8
45+++ b/data/do-release-upgrade.8
46@@ -11,12 +11,18 @@ This is the preferred command if the machine has no graphic environment or if th
47 .SH "OPTIONS"
48 .TP
49 \fB\-h\fR, \fB\-\-help\fR
50-show help message and exit
51-.TP
52+show this help message and exit
53+.TP
54+\fB\-V\fR, \fB\-\-version\fR
55+Show version and exit
56+.TP
57 \fB\-d\fR, \fB\-\-devel\-release\fR
58-If using the latest supported release, upgrade to
59-the development release
60-.TP
61+If using the latest supported release, upgrade to the
62+development release
63+.TP
64+\fB\-\-data\-dir\fR=\fI\,DATA_DIR\/\fR
65+Directory that contains the data files
66+.TP
67 \fB\-p\fR, \fB\-\-proposed\fR
68 Try upgrading to the latest release using the upgrader
69 from Ubuntu\-proposed
70@@ -25,8 +31,23 @@ from Ubuntu\-proposed
71 Run in a special upgrade mode. Currently "desktop" for
72 regular upgrades of a desktop system and "server" for
73 server systems are supported.
74-.TP
75-\fB\-f\fR FRONTEND, \fB\-\-frontend\fR=\fIFRONTEND\fR
76+.TP
77+\fB\-f\fR FRONTEND, \fB\-\-frontend\fR=\fI\,FRONTEND\/\fR
78 Run the specified frontend
79+.TP
80+\fB\-c\fR, \fB\-\-check\-dist\-upgrade\-only\fR
81+Check only if a new distribution release is available
82+and report the result via the exit code
83+.TP
84+\fB\-\-allow\-third\-party\fR
85+Try the upgrade with third party mirrors and
86+repositories enabled instead of commenting them out.
87+.HP
88+\fB\-q\fR, \fB\-\-quiet\fR
89+.TP
90+\fB\-e\fR ENV, \fB\-\-env\fR=\fI\,ENV\/\fR
91+A comma\-seprated list of environment variables (e.g.
92+VAR1=VALUE1,VAR2=VALUE2) that should be set during the
93+upgrade.
94 .SH "SEE ALSO"
95 \fBupdate\-manager\fR(8), \fBapt\-get\fR(8)
96diff --git a/debian/changelog b/debian/changelog
97index b95ff88..fcae744 100644
98--- a/debian/changelog
99+++ b/debian/changelog
100@@ -1,3 +1,12 @@
101+ubuntu-release-upgrader (1:22.04.9) UNRELEASED; urgency=medium
102+
103+ * do-release-upgrade: Preserve env vars needed for screen lock prevention (LP: #1968607).
104+ * data: Update do-release-upgrade man page.
105+ * DistUpgrade/DistUpgradeController.py: Do not make UI dialog calls while
106+ EUID != 0.
107+
108+ -- Nick Rosbrook <nick.rosbrook@canonical.com> Tue, 12 Apr 2022 15:00:49 -0400
109+
110 ubuntu-release-upgrader (1:22.04.8) jammy; urgency=medium
111
112 [ Brian Murray ]
113diff --git a/do-release-upgrade b/do-release-upgrade
114index 44680c4..a395bc1 100755
115--- a/do-release-upgrade
116+++ b/do-release-upgrade
117@@ -110,6 +110,10 @@ if __name__ == "__main__":
118 "instead of commenting them out."))
119 parser.add_option ("-q", "--quiet", default=False, action="store_true",
120 dest="quiet")
121+ parser.add_option ("-e", "--env",
122+ help=_("A comma-seprated list of environment variables "
123+ "(e.g. VAR1=VALUE1,VAR2=VALUE2) that should be set "
124+ "during the upgrade."))
125
126 (options, args) = parser.parse_args()
127
128@@ -216,6 +220,15 @@ if __name__ == "__main__":
129 # the env variable is used by code in the dist-upgrader tarball
130 os.environ["RELEASE_UPGRADER_ALLOW_THIRD_PARTY"] = "True"
131
132+ if options.env:
133+ for env in options.env.split(','):
134+ parts = env.split('=')
135+ if len(parts) < 2:
136+ continue
137+
138+ # The value itself may contain '='.
139+ os.environ[parts[0]] = '='.join(parts[1:])
140+
141 # GTK 3 fetcher starts setting up the the GUI and KDE GUI needs to start GUI
142 # later, too.
143 if (options.frontend in {"DistUpgradeViewGtk3", "DistUpgradeViewKDE"} and
144@@ -225,6 +238,16 @@ if __name__ == "__main__":
145 # this is needed because pkexec doesn't pass on the env
146 if 'RELEASE_UPGRADER_ALLOW_THIRD_PARTY' in os.environ:
147 sys.argv.append('--allow-third-party')
148+
149+ # Some extra environment variables need to be passed, but we need
150+ # to do this explicitly with do-release-upgrade because pkexec
151+ # does not provide such functionality.
152+ extra_env_vars = [
153+ 'DBUS_SESSION_BUS_ADDRESS=%s' % os.getenv('DBUS_SESSION_BUS_ADDRESS', ''),
154+ 'XDG_SESSION_TYPE=%s' % os.getenv('XDG_SESSION_TYPE', ''),
155+ ]
156+ sys.argv.append('--env=%s' % ','.join(extra_env_vars))
157+
158 os.execv("/usr/bin/pkexec", ["pkexec"] + sys.argv)
159
160 fetcher = get_fetcher(options.frontend, m.new_dist, options.data_dir)

Subscribers

People subscribed via source and target branches