Merge ~enr0n/ubuntu/+source/systemd:ubuntu-kinetic into ~ubuntu-core-dev/ubuntu/+source/systemd:ubuntu-kinetic

Proposed by Nick Rosbrook
Status: Merged
Merged at revision: 0d0729bb3a1e61809e685c052c5ab65dd4ddf4c4
Proposed branch: ~enr0n/ubuntu/+source/systemd:ubuntu-kinetic
Merge into: ~ubuntu-core-dev/ubuntu/+source/systemd:ubuntu-kinetic
Diff against target: 180 lines (+130/-4)
4 files modified
debian/changelog (+12/-2)
debian/patches/lp1978079-pstore-Run-after-modules-are-loaded.patch (+7/-2)
debian/patches/lp1981042-core-firstboot-workaround-timezone-issues-caused-by-Ubunt.patch (+110/-0)
debian/patches/series (+1/-0)
Reviewer Review Type Date Requested Status
Lukas Märdian Approve
Review via email: mp+427302@code.launchpad.net

Description of the change

These changes are needed in kinetic ahead of a Jammy SRU.

To post a comment you must log in.
Revision history for this message
Lukas Märdian (slyon) wrote :

Thank you, Nick. This looks good to me. Please remember to mention a test build/PPA (and potential autopkgtest) of your changes for next time. I think I found a test build in your PPA for now: https://launchpad.net/~enr0n/+archive/ubuntu/systemd-251/+packages

I am a bit reluctant about adding even more /etc/writable workarounds for Ubuntu Core, but I understand that we need this now. Last time, I asked the snapd team to come up with a more sustainable solution for this issue (LP: #1953172) but I think nothing came out of this up to now.. (Thanks for also mentioning this bug in the patch headers!)

Medium term, I think we should probably move that "writable_filename()" function to a more global place inside systemd (maybe some utils file inside libsystemd, that is available to all components applying this workaround? Or a new "ubuntu-quirks.h" header that we include from all those modules?) – I'm not sure if such place exists, but it might be cleaner than copying the same static function into all those modules. We could then consolidate the 3 patches into a single, smaller one:
- debian/patches/debian/UBUNTU-Support-system-image-read-only-etc.patch
- debian/patches/debian/UBUNTU-Fix-timezone-setting-on-read-only-etc.patch
- debian/patches/lp1981042-core-firstboot-workaround-timezone-issues-caused-by-Ubunt.patch

=> But this shall not block this upload.

Long term, I still hope we (or the snapd team) get somewhere with LP: #1953172

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index 641bbcd..9d6a334 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,10 +1,20 @@
6-systemd (251.2-2ubuntu2) UNRELEASED; urgency=medium
7+systemd (251.2-2ubuntu2) kinetic; urgency=medium
8
9+ [ Lukas Märdian ]
10 * Remove restart limit on the modprobe@.service (LP: #1982462)
11 File: debian/patches/units-remove-the-restart-limit-on-the-modprobe-.service.patch
12 https://git.launchpad.net/~ubuntu-core-dev/ubuntu/+source/systemd/commit/?id=46c36d4c73df8980f6b6137142fb16ba90465a94
13
14- -- Lukas Märdian <slyon@ubuntu.com> Thu, 21 Jul 2022 11:06:52 +0200
15+ [ Nick Rosbrook ]
16+ * core,firstboot: workaround timezone issues on Ubuntu Core (LP: #1981042)
17+ Thanks to Robert Ancell for preparing the patch.
18+ File: debian/patches/lp1981042-core-firstboot-workaround-timezone-issues-caused-by-Ubunt.patch
19+ https://git.launchpad.net/~ubuntu-core-dev/ubuntu/+source/systemd/commit/?id=9a435d43e753f39531c9a5517a85e8eb259e18f1
20+ * pstore: do not try to load mtdpstore (LP: #1981622)
21+ File: debian/patches/lp1978079-pstore-Run-after-modules-are-loaded.patch
22+ https://git.launchpad.net/~ubuntu-core-dev/ubuntu/+source/systemd/commit/?id=38d8d12be924477f0eecb64f3737e07b03d73a42
23+
24+ -- Nick Rosbrook <nick.rosbrook@canonical.com> Fri, 22 Jul 2022 15:23:45 -0400
25
26 systemd (251.2-2ubuntu1) kinetic; urgency=medium
27
28diff --git a/debian/patches/lp1978079-pstore-Run-after-modules-are-loaded.patch b/debian/patches/lp1978079-pstore-Run-after-modules-are-loaded.patch
29index 7c6c737..e7b7194 100644
30--- a/debian/patches/lp1978079-pstore-Run-after-modules-are-loaded.patch
31+++ b/debian/patches/lp1978079-pstore-Run-after-modules-are-loaded.patch
32@@ -4,7 +4,12 @@ Subject: pstore: Run after modules are loaded
33
34 Origin: upstream, https://github.com/systemd/systemd/commit/70e74a5997ae2ce7ba72a74ac949c3b2dad1a1d6
35 Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1978079
36+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1981622
37+Last-Updated: 2022-07-22
38
39+The original commit has been modified to not load mtdpstore.
40+
41+---
42 The systemd-pstore service takes pstore files on boot and transfers them
43 to disk. It only does it once on boot and only if it finds any. The typical
44 location of the pstore on modern systems is the UEFI variable store.
45@@ -36,8 +41,8 @@ index 848e311..86de30a 100644
46 DefaultDependencies=no
47 Conflicts=shutdown.target
48 Before=sysinit.target shutdown.target
49-+After=modprobe@efi_pstore.service modprobe@mtdpstore.service modprobe@chromeos_pstore.service modprobe@ramoops.service modprobe@pstore_zone.service modprobe@pstore_blk.service
50-+Wants=modprobe@efi_pstore.service modprobe@mtdpstore.service modprobe@chromeos_pstore.service modprobe@ramoops.service modprobe@pstore_zone.service modprobe@pstore_blk.service
51++After=modprobe@efi_pstore.service modprobe@chromeos_pstore.service modprobe@ramoops.service modprobe@pstore_zone.service modprobe@pstore_blk.service
52++Wants=modprobe@efi_pstore.service modprobe@chromeos_pstore.service modprobe@ramoops.service modprobe@pstore_zone.service modprobe@pstore_blk.service
53
54 [Service]
55 Type=oneshot
56diff --git a/debian/patches/lp1981042-core-firstboot-workaround-timezone-issues-caused-by-Ubunt.patch b/debian/patches/lp1981042-core-firstboot-workaround-timezone-issues-caused-by-Ubunt.patch
57new file mode 100644
58index 0000000..7d64066
59--- /dev/null
60+++ b/debian/patches/lp1981042-core-firstboot-workaround-timezone-issues-caused-by-Ubunt.patch
61@@ -0,0 +1,110 @@
62+Description: Workaround timezone issues cause by Ubuntu Core's read-only /etc
63+ This is another patch in a series of existing ones working around this issue
64+ on Ubuntu Core.
65+Author: Nick Rosbrook <nick.rosbrook@canonical.com>
66+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1981042
67+Bug-Ubuntu: https://bugs.launchpad.net/snappy/+bug/1953172
68+Forwarded: not-needed (part of read-only /etc workaround)
69+Last-Update: 2022-07-20
70+---
71+diff --git a/src/core/manager.c b/src/core/manager.c
72+index 296b759..230e5c8 100644
73+--- a/src/core/manager.c
74++++ b/src/core/manager.c
75+@@ -424,6 +424,25 @@ static int manager_setup_time_change(Manager *m) {
76+ return 0;
77+ }
78+
79++/* Hack for Ubuntu Phone/Core: check if path is an existing symlink to
80++ * /etc/writable; if it is, update that instead */
81++static const char* writable_filename(const char *path) {
82++ ssize_t r;
83++ static char realfile_buf[PATH_MAX];
84++ _cleanup_free_ char *realfile = NULL;
85++ const char *result = path;
86++ int orig_errno = errno;
87++
88++ r = readlink_and_make_absolute(path, &realfile);
89++ if (r >= 0 && startswith(realfile, "/etc/writable")) {
90++ snprintf(realfile_buf, sizeof(realfile_buf), "%s", realfile);
91++ result = realfile_buf;
92++ }
93++
94++ errno = orig_errno;
95++ return result;
96++}
97++
98+ static int manager_read_timezone_stat(Manager *m) {
99+ struct stat st;
100+ bool changed;
101+@@ -431,7 +450,7 @@ static int manager_read_timezone_stat(Manager *m) {
102+ assert(m);
103+
104+ /* Read the current stat() data of /etc/localtime so that we detect changes */
105+- if (lstat("/etc/localtime", &st) < 0) {
106++ if (lstat(writable_filename("/etc/localtime"), &st) < 0) {
107+ log_debug_errno(errno, "Failed to stat /etc/localtime, ignoring: %m");
108+ changed = m->etc_localtime_accessible;
109+ m->etc_localtime_accessible = false;
110+@@ -468,7 +487,7 @@ static int manager_setup_timezone_change(Manager *m) {
111+ * Note that we create the new event source first here, before releasing the old one. This should optimize
112+ * behaviour as this way sd-event can reuse the old watch in case the inode didn't change. */
113+
114+- r = sd_event_add_inotify(m->event, &new_event, "/etc/localtime",
115++ r = sd_event_add_inotify(m->event, &new_event, writable_filename("/etc/localtime"),
116+ IN_ATTRIB|IN_MOVE_SELF|IN_CLOSE_WRITE|IN_DONT_FOLLOW, manager_dispatch_timezone_change, m);
117+ if (r == -ENOENT) {
118+ /* If the file doesn't exist yet, subscribe to /etc instead, and wait until it is created either by
119+diff --git a/src/firstboot/firstboot.c b/src/firstboot/firstboot.c
120+index 3916018..9f2d178 100644
121+--- a/src/firstboot/firstboot.c
122++++ b/src/firstboot/firstboot.c
123+@@ -462,18 +462,37 @@ static int prompt_timezone(void) {
124+ return 0;
125+ }
126+
127++/* Hack for Ubuntu Phone/Core: check if path is an existing symlink to
128++ * /etc/writable; if it is, update that instead */
129++static const char* writable_filename(const char *path) {
130++ ssize_t r;
131++ static char realfile_buf[PATH_MAX];
132++ _cleanup_free_ char *realfile = NULL;
133++ const char *result = path;
134++ int orig_errno = errno;
135++
136++ r = readlink_and_make_absolute(path, &realfile);
137++ if (r >= 0 && startswith(realfile, "/etc/writable")) {
138++ snprintf(realfile_buf, sizeof(realfile_buf), "%s", realfile);
139++ result = realfile_buf;
140++ }
141++
142++ errno = orig_errno;
143++ return result;
144++}
145++
146+ static int process_timezone(void) {
147+ const char *etc_localtime, *e;
148+ int r;
149+
150+- etc_localtime = prefix_roota(arg_root, "/etc/localtime");
151++ etc_localtime = prefix_roota(arg_root, writable_filename("/etc/localtime"));
152+ if (laccess(etc_localtime, F_OK) >= 0 && !arg_force)
153+ return 0;
154+
155+ if (arg_copy_timezone && arg_root) {
156+ _cleanup_free_ char *p = NULL;
157+
158+- r = readlink_malloc("/etc/localtime", &p);
159++ r = readlink_malloc(writable_filename("/etc/localtime"), &p);
160+ if (r != -ENOENT) {
161+ if (r < 0)
162+ return log_error_errno(r, "Failed to read host timezone: %m");
163+@@ -494,7 +513,7 @@ static int process_timezone(void) {
164+ if (isempty(arg_timezone))
165+ return 0;
166+
167+- e = strjoina("../usr/share/zoneinfo/", arg_timezone);
168++ e = strjoina("/usr/share/zoneinfo/", arg_timezone);
169+
170+ (void) mkdir_parents(etc_localtime, 0755);
171+ if (symlink(e, etc_localtime) < 0)
172diff --git a/debian/patches/series b/debian/patches/series
173index 0824f07..3cc9601 100644
174--- a/debian/patches/series
175+++ b/debian/patches/series
176@@ -49,3 +49,4 @@ hwdb-implement-root-option-for-systemd-hwdb-query.patch
177 test-increase-QEMU_MEM-for-some-tests.patch
178 test-copy-libgcc_s.so.1-to-TPM2-test-image-on-Debian-like.patch
179 units-remove-the-restart-limit-on-the-modprobe-.service.patch
180+lp1981042-core-firstboot-workaround-timezone-issues-caused-by-Ubunt.patch

Subscribers

People subscribed via source and target branches