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: 6d9cc2af0bd012b228880a9591729475e26ef172
Proposed branch: ~enr0n/ubuntu/+source/systemd:ubuntu-kinetic
Merge into: ~ubuntu-core-dev/ubuntu/+source/systemd:ubuntu-kinetic
Diff against target: 114 lines (+77/-3)
4 files modified
debian/changelog (+43/-2)
debian/systemd-resolved.postinst (+10/-0)
debian/systemd-resolved.postrm (+24/-0)
dev/null (+0/-1)
Reviewer Review Type Date Requested Status
Lukas Märdian Approve
Review via email: mp+429166@code.launchpad.net

Description of the change

Pull Debian fix for bug in systemd-resolved installation where dpkg refuses to install the symlink in chroot/container environments where /etc/resolv.conf is bind mounted.

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

The proposed changes LGTM in general!

Unfortunately, the autopkgtests somehow got lost on autopkgtest.u.c (all but armhf, which PASSed).
Working around those infrastructure issues, @enr0n was able to provide a local autopkgtest run (on amd64):

```
autopkgtest systemd --setup-commands 'apt install software-properties-common -y; apt-add-repository -y -s ppa:enr0n/systemd-251' --shell-fail -U -- qemu --ram-size=8192 --cpus=4 /home/nr/ubuntu/autopkgtest-testbeds/autopkgtest-kinetic-amd64.img
[...]
autopkgtest [10:43:41]: @@@@@@@@@@@@@@@@@@@@ summary
timedated PASS
hostnamed PASS
localed-locale PASS
localed-x11-keymap PASS
logind PASS
unit-config PASS
storage PASS
networkd-test.py PASS
build-login PASS
boot-and-services PASS
udev PASS
unit-tests PASS
tests-in-lxd PASS
upstream-1 PASS
upstream-2 PASS
boot-smoke PASS
systemd-fsckd SKIP exit status 77 and marked as skippable
qemu-system-x86_64: terminating on signal 15 from pid 46477 (/usr/bin/python3)
```

The test environment for the other architecutres (but armhf) is pretty similar to amd64, so I feel comfortable sponsoring this upload. If testing fails in -proposed, we might need to upgrade other architectures to `big_packages` (similar to amd64 & ppc64el)

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 c8ce2d4..a7df987 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,10 +1,51 @@
6-systemd (251.4-1ubuntu2) UNRELEASED; urgency=medium
7+systemd (251.4-1ubuntu2) kinetic; urgency=medium
8
9+ [ Lukas Märdian ]
10 * Provide upgrade path (Replaces:) for Jammy's systemd-repart (LP: 1897932)
11 File: debian/control
12 https://git.launchpad.net/~ubuntu-core-dev/ubuntu/+source/systemd/commit/?id=2281670aa8007179170d5cc485bb94e3bbc3b63c
13
14- -- Lukas Märdian <slyon@ubuntu.com> Tue, 30 Aug 2022 10:05:19 +0200
15+ [ Luca Boccassi ]
16+ * resolved: switch from .links to postinst/rm (LP: #1988300)
17+ dpkg refuses to install the symlink in chroot/container environments
18+ where /etc/resolv.conf is bind mounted:
19+ | Unpacking systemd-resolved (251.4-1) ...
20+ | dpkg: error processing archive /var/cache/apt/archives/systemd-resolved_251.4-1_amd64.deb (--unpack):
21+ | unable to make backup link of './etc/resolv.conf' before installing new version: Invalid cross-device link
22+ So unfortunately manual handling via maintainerscripts is necessary.
23+ Use maintainer scripts to avoid failing the installation, and provide
24+ feedback to the user if the symlink cannot be successfully installed.
25+ Also on removal, either copy /run/systemd/resolve/resolv.conf or
26+ create an empty /etc/resolv.conf.
27+ Amend to use the correct Ubuntu version string (251.4-1ubuntu2).
28+ Author: Luca Boccassi
29+ Files:
30+ - debian/systemd-resolved.links
31+ - debian/systemd-resolved.postinst
32+ - debian/systemd-resolved.postrm
33+ https://git.launchpad.net/~ubuntu-core-dev/ubuntu/+source/systemd/commit/?id=faf479a6158aac977c2cdb32fd1eaecc0862a7ef
34+ * resolv.conf: take backup as a fallback
35+ piuparts doesn't like seeing an empty resolv.conf after removing
36+ the package, so take a backup and use it in case resolved/resolv.conf
37+ is not available
38+ Author: Luca Boccassi
39+ Files:
40+ - debian/systemd-resolved.postinst
41+ - debian/systemd-resolved.postrm
42+ https://git.launchpad.net/~ubuntu-core-dev/ubuntu/+source/systemd/commit/?id=c2b15f43eb7779953a3dda7f461edbb1bf038701
43+
44+ [ Nick Rosbrook ]
45+ * debian/systemd-resolved.{postinst,postrm}: do not use DPKG_ROOT.
46+ We cherry-picked "resolved: switch from .links to postinst/rm" and
47+ "resolv.conf: take backup as a fallback" from debian/251.4-3 to fix a
48+ systemd-resolved installation issue, but we are not taking the DPKG_ROOT
49+ changes at the moment due to feature freeze.
50+ Files:
51+ - debian/systemd-resolved.postinst
52+ - debian/systemd-resolved.postrm
53+ https://git.launchpad.net/~ubuntu-core-dev/ubuntu/+source/systemd/commit/?id=5664be09ce9813cb2dd2bd71c5d325036655c312
54+
55+ -- Nick Rosbrook <nick.rosbrook@canonical.com> Wed, 31 Aug 2022 09:55:31 -0400
56
57 systemd (251.4-1ubuntu1) kinetic; urgency=medium
58
59diff --git a/debian/systemd-resolved.links b/debian/systemd-resolved.links
60deleted file mode 100644
61index 63b933a..0000000
62--- a/debian/systemd-resolved.links
63+++ /dev/null
64@@ -1 +0,0 @@
65-/run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
66diff --git a/debian/systemd-resolved.postinst b/debian/systemd-resolved.postinst
67index 17ab957..e6beb29 100644
68--- a/debian/systemd-resolved.postinst
69+++ b/debian/systemd-resolved.postinst
70@@ -25,4 +25,14 @@ if [ "$1" = configure ] && [ -z "$2" ]; then
71 _adopt_conffile /etc/systemd/resolved.conf systemd-resolved
72 fi
73
74+if [ "$1" = configure ] && dpkg --compare-versions "$2" lt 251.4-1ubuntu2; then
75+ if [ "$(readlink "/etc/resolv.conf")" != "../run/systemd/resolve/stub-resolv.conf" ] && [ "$(readlink "/etc/resolv.conf")" != "/run/systemd/resolve/stub-resolv.conf" ]; then
76+ echo "Converting /etc/resolv.conf to a symlink to /run/systemd/resolve/stub-resolv.conf..."
77+ if [ -f "/etc/resolv.conf" ]; then
78+ mv "/etc/resolv.conf" "/etc/.resolv.conf.systemd-resolved.bak" || echo "Cannot take a backup of /etc/resolv.conf."
79+ fi
80+ ln -sf ../run/systemd/resolve/stub-resolv.conf "/etc/resolv.conf" || echo "Cannot install symlink from /etc/resolv.conf to ../run/systemd/resolve/stub-resolv.conf"
81+ fi
82+fi
83+
84 #DEBHELPER#
85diff --git a/debian/systemd-resolved.postrm b/debian/systemd-resolved.postrm
86new file mode 100644
87index 0000000..9d6904f
88--- /dev/null
89+++ b/debian/systemd-resolved.postrm
90@@ -0,0 +1,24 @@
91+#!/bin/sh
92+
93+set -e
94+
95+if [ "$1" = remove ]; then
96+ if [ "$(readlink "/etc/resolv.conf")" = "../run/systemd/resolve/stub-resolv.conf" ] || [ "$(readlink "/etc/resolv.conf")" = "/run/systemd/resolve/stub-resolv.conf" ]; then
97+ echo "Removing /etc/resolv.conf symlink to /run/systemd/resolve/stub-resolv.conf..."
98+ rm -f "/etc/resolv.conf" || echo "Cannot remove /etc/resolv.conf."
99+ if [ -f "/run/systemd/resolve/resolv.conf" ]; then
100+ echo "Copying /run/systemd/resolve/resolv.conf to /etc/resolv.conf..."
101+ cp "/run/systemd/resolve/resolv.conf" "/etc/resolv.conf" || echo "Cannot copy /run/systemd/resolve/resolv.conf to /etc/resolv.conf."
102+ # We prefer a current resolv.conf rather than an older backup, if available
103+ rm -f "/etc/.resolv.conf.systemd-resolved.bak"
104+ elif [ -f "/etc/.resolv.conf.systemd-resolved.bak" ]; then
105+ echo "Restoring previous resolv.conf..."
106+ mv "/etc/.resolv.conf.systemd-resolved.bak" "/etc/resolv.conf" || echo "Cannot restore /etc/resolv.conf backup."
107+ else
108+ echo "Creating an empty /etc/resolv.conf..."
109+ touch "/etc/resolv.conf" || echo "Cannot create an empty /etc/resolv.conf."
110+ fi
111+ fi
112+fi
113+
114+#DEBHELPER#

Subscribers

People subscribed via source and target branches