Skip to content

Commit 4202d87

Browse files
authored
Merge pull request #3409 from flatcar/krnowak/systemd-cleanups
overlay sys-apps/systemd: Move to portage-stable
2 parents d009345 + e5748f8 commit 4202d87

File tree

43 files changed

+1782
-2825
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1782
-2825
lines changed

.github/workflows/portage-stable-packages-list

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,7 @@ sys-apps/sed
625625
sys-apps/semodule-utils
626626
sys-apps/shadow
627627
sys-apps/smartmontools
628+
sys-apps/systemd
628629
sys-apps/texinfo
629630
sys-apps/usbutils
630631
sys-apps/util-linux
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- systemd (257.9)
Lines changed: 168 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,177 @@
1-
cros_post_src_install_timesync() {
2-
local dir="${D}$(systemd_get_systemunitdir)/systemd-timesyncd.service.d"
3-
mkdir -p "${dir}"
4-
pushd "${dir}"
5-
cat <<EOF >flatcar.conf || die
1+
flatcar_systemd_meson_args_array=(
2+
# Point to our user mailing list.
3+
-Dsupport-url='https://groups.google.com/forum/#!forum/flatcar-linux-user'
4+
5+
# Use our ntp servers.
6+
-Dntp-servers="0.flatcar.pool.ntp.org 1.flatcar.pool.ntp.org 2.flatcar.pool.ntp.org 3.flatcar.pool.ntp.org"
7+
8+
# Specify this, or meson breaks due to no /etc/login.defs.
9+
-Dsystem-gid-max=999
10+
-Dsystem-uid-max=999
11+
12+
# PAM config directory.
13+
-Dpamconfdir="${EPREFIX}/usr/share/pam.d"
14+
15+
# The CoreOS epoch, Mon Jul 1 00:00:00 UTC 2013. Used by timesyncd
16+
# as a sanity check for the minimum acceptable time. Explicitly
17+
# set to avoid using the current build time.
18+
-Dtime-epoch=1372636800
19+
20+
# No default name servers.
21+
-Ddns-servers=
22+
23+
# Disable the "First Boot Wizard", it isn't very applicable to us.
24+
-Dfirstboot=false
25+
26+
# Set latest network interface naming scheme for
27+
# https://github.com/flatcar/Flatcar/issues/36
28+
-Ddefault-net-naming-scheme=latest
29+
30+
# Combined log format: name plus description
31+
-Dstatus-unit-format-default=combined
32+
33+
# Disable multicast-dns, Link-Local Multicast Name Resolution and
34+
# dnssec
35+
-Ddefault-mdns=no
36+
-Ddefault-llmnr=no
37+
-Ddefault-dnssec=no
38+
)
39+
export MYMESONARGS="${flatcar_systemd_meson_args_array[*]@Q}"
40+
unset 'flatcar_systemd_meson_args_array'
41+
42+
# Save the original path to systemctl command, so we can use it for
43+
# presetting, even after stubbing systemctl out below.
44+
if [[ -z ${flatcar_hacked_systemctl} ]]; then
45+
flatcar_hacked_systemctl=$(command -v systemctl) || die "systemctl not found"
46+
fi
47+
# Stubbed out completely - it is being invoked in the pkg_postinst to
48+
# enable getty service and do some reexecs/reloads. None of these are
49+
# necessary for us.
50+
systemctl() {
51+
:
52+
}
53+
54+
flatcar_systemctl_preset() {
55+
local scope=${1}
56+
57+
local systemctl_scope_arg
58+
case ${scope} in
59+
system) systemctl_scope_arg=--system;;
60+
user) systemctl_scope_arg=--global;; # don't ask, using --user
61+
# results in an "invalid
62+
# argument" error
63+
*) die "wrong scope ${scope@Q}, ought to be either system or user";;
64+
esac
65+
66+
"${flatcar_hacked_systemctl}" --root="${ED}" "${systemctl_scope_arg}" --preset-mode=enable-only preset-all || die
67+
68+
local escaped_path
69+
escaped_path=$(printf '%s' "${ED}/etc/systemd/" | sed -e 's/[#\&]/\\&/g') || die
70+
71+
# make symlinks relative
72+
find "${ED}/etc/systemd/${scope}" -type l -lname "/usr/lib/systemd/${scope}/*" -printf "%l\0%p\0" | \
73+
sed -z -e "s#^/usr/lib/systemd/#${escaped_path}#" | \
74+
xargs -0 -n2 ln -sfTr || die
75+
76+
# This will print an error like:
77+
#
78+
# tar: <PATH TO /etc/systemd/${scope}: Cannot rmdir: Directory not empty
79+
#
80+
# It's fine, ignore it. We excluded .keep file from putting into
81+
# tarball, so we can preserve the toplevel directory. Avoiding the
82+
# warning only results in stupid complexity.
83+
tar --create --exclude='.keep*' --remove-files --directory "${ED}/etc/systemd/${scope}" . | \
84+
tar --extract --directory "${ED}/usr/lib/systemd/${scope}"
85+
}
86+
87+
cros_post_src_install_flatcar_stuff() {
88+
# We provide our own systemd-user config file in baselayout.
89+
#
90+
# This one is installed by systemd build system regardless of
91+
# USE=pam (the ebuild ought to pass -Dpamconfdir=no to disable the
92+
# installation).
93+
rm "${ED}/usr/share/pam.d/systemd-user" || die
94+
# This one is installed by Gentoo's systemd ebuild only if USE=pam
95+
# is enabled.
96+
if use pam; then
97+
rm "${ED}/etc/pam.d/systemd-user" || die
98+
fi
99+
100+
# Ensure journal directory has correct ownership/mode in inital
101+
# image. This is fixed by systemd-tmpfiles *but* journald starts
102+
# before that and will create the journal if the filesystem is
103+
# already read-write. Conveniently the systemd build system sets
104+
# this up completely wrong.
105+
keepdir /var/log/journal
106+
fowners root:systemd-journal /var/log/journal
107+
fperms 2755 /var/log/journal
108+
109+
keepdir /var/log/journal/remote
110+
fowners systemd-journal-remote:systemd-journal-remote /var/log/journal/remote
111+
112+
(
113+
insopts -m 0644
114+
insinto /usr/lib/tmpfiles.d
115+
# Add tmpfiles rule for resolv.conf. This path has changed
116+
# after v213 so it must be handled here instead of baselayout
117+
# now.
118+
newins - systemd-resolv.conf <<'EOF'
119+
d /run/systemd/network - - - - -
120+
L /run/systemd/network/resolv.conf - - - - ../resolve/resolv.conf
121+
EOF
122+
)
123+
124+
# Don't set any extra environment variables by default.
125+
rm "${ED}/usr/lib/environment.d/99-environment.conf" || die
126+
127+
# enable system units
128+
flatcar_systemctl_preset system
129+
# enable user units
130+
flatcar_systemctl_preset user
131+
132+
# Use an empty preset file, because systemctl preset-all puts
133+
# symlinks in /etc, not in /usr. We don't use /etc, because it is
134+
# not autoupdated. We do the "preset" above.
135+
rm "${ED}/usr/lib/systemd/system-preset/90-systemd.preset" || die
136+
rm "${ED}/usr/lib/systemd/user-preset/90-systemd.preset" || die
137+
(
138+
insinto /usr/lib/systemd/system-preset
139+
newins - 99-default.preset <<'EOF'
140+
# Do not enable any services if /etc is detected as empty.
141+
disable *
142+
EOF
143+
insinto /usr/lib/systemd/user-preset
144+
newins - 99-default.preset <<'EOF'
145+
# Do not enable any services if /etc is detected as empty.
146+
disable *
147+
EOF
148+
)
149+
150+
# Do not ship distro-specific files (nsswitch.conf pam.d). This
151+
# conflicts with our own configuration provided by baselayout.
152+
rm -r "${ED}"/usr/share/factory || die
153+
sed -i "${ED}"/usr/lib/tmpfiles.d/etc.conf \
154+
-e '/^C!* \/etc\/nsswitch\.conf/d' \
155+
-e '/^C!* \/etc\/pam\.d/d' \
156+
-e '/^C!* \/etc\/issue/d' || die
157+
158+
(
159+
# Some OEMs prefer chronyd, so allow them to replace
160+
# systemd-timesyncd with it.
161+
insinto "$(systemd_get_systemunitdir)/systemd-timesyncd.service.d"
162+
newins - flatcar.conf <<'EOF'
6163
# Allow sysexts to ship timesyncd replacements which can have
7164
# a Conflicts=systemd-timesyncd directive that would result
8165
# in systemd-timesyncd not being started.
9166
[Unit]
10167
After=ensure-sysext.service
11168
EOF
12-
popd
13-
}
169+
)
14170

15-
cros_post_src_install_udev() {
16-
insinto "$(systemd_get_systemunitdir)/systemd-udevd.service.d"
17-
newins - flatcar.conf <<EOF
171+
(
172+
# Allow @mount syscalls for systemd-udevd.service
173+
insinto "$(systemd_get_systemunitdir)/systemd-udevd.service.d"
174+
newins - flatcar.conf <<'EOF'
18175
# In Flatcar we are using modprobe helpers that run depmod in temporary
19176
# overlay. systemd-udevd.service may try to load drivers for some block devices
20177
# (e.g. ZFS), which ends up calling our helpers, which invoke mount command.
@@ -23,4 +180,5 @@ cros_post_src_install_udev() {
23180
[Service]
24181
SystemCallFilter=@mount
25182
EOF
183+
)
26184
}

sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/files/0001-wait-online-set-any-by-default.patch renamed to sdk_container/src/third_party/coreos-overlay/coreos/user-patches/sys-apps/systemd/0001-wait-online-set-any-by-default.patch

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
From 98cbd0a4576464478f0f9fcd2066efc08bef9491 Mon Sep 17 00:00:00 2001
1+
From 83043596b6cc74b6f049999fa660afd983dc493a Mon Sep 17 00:00:00 2001
22
From: David Michael <[email protected]>
33
Date: Tue, 16 Apr 2019 02:44:51 +0000
44
Subject: [PATCH 1/8] wait-online: set --any by default
@@ -15,18 +15,18 @@ earlier) for the original implementation.
1515
1 file changed, 1 insertion(+), 1 deletion(-)
1616

1717
diff --git a/src/network/wait-online/wait-online.c b/src/network/wait-online/wait-online.c
18-
index 5328bba2d8..95294df607 100644
18+
index 6f5aef903a..0acb3e76b9 100644
1919
--- a/src/network/wait-online/wait-online.c
2020
+++ b/src/network/wait-online/wait-online.c
2121
@@ -21,7 +21,7 @@ static Hashmap *arg_interfaces = NULL;
2222
static char **arg_ignore = NULL;
23-
static LinkOperationalStateRange arg_required_operstate = { _LINK_OPERSTATE_INVALID, _LINK_OPERSTATE_INVALID };
23+
static LinkOperationalStateRange arg_required_operstate = LINK_OPERSTATE_RANGE_INVALID;
2424
static AddressFamily arg_required_family = ADDRESS_FAMILY_NO;
2525
-static bool arg_any = false;
2626
+static bool arg_any = true;
2727

2828
STATIC_DESTRUCTOR_REGISTER(arg_interfaces, hashmap_free_free_freep);
2929
STATIC_DESTRUCTOR_REGISTER(arg_ignore, strv_freep);
3030
--
31-
2.34.1
31+
2.51.0
3232

sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/files/0003-needs-update-don-t-require-strictly-newer-usr.patch renamed to sdk_container/src/third_party/coreos-overlay/coreos/user-patches/sys-apps/systemd/0002-needs-update-don-t-require-strictly-newer-usr.patch

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
From 0be1b5367c24427e3285d33fb87aa4acdf3c4dce Mon Sep 17 00:00:00 2001
1+
From 3d6bfde35c8ce5c21ca55104852a319246a92bb8 Mon Sep 17 00:00:00 2001
22
From: Alex Crawford <[email protected]>
33
Date: Wed, 2 Mar 2016 10:46:33 -0800
4-
Subject: [PATCH 3/8] needs-update: don't require strictly newer usr
4+
Subject: [PATCH 2/8] needs-update: don't require strictly newer usr
55

66
Updates should be triggered whenever usr changes, not only when it is newer.
77
---
@@ -10,7 +10,7 @@ Updates should be triggered whenever usr changes, not only when it is newer.
1010
2 files changed, 4 insertions(+), 4 deletions(-)
1111

1212
diff --git a/man/systemd-update-done.service.xml b/man/systemd-update-done.service.xml
13-
index 3393010ff6..5478baca25 100644
13+
index 6b863ecff3..c166c5e7ab 100644
1414
--- a/man/systemd-update-done.service.xml
1515
+++ b/man/systemd-update-done.service.xml
1616
@@ -50,7 +50,7 @@
@@ -23,10 +23,10 @@ index 3393010ff6..5478baca25 100644
2323
This requires that updates to <filename>/usr/</filename> are always
2424
followed by an update of the modification time of
2525
diff --git a/src/shared/condition.c b/src/shared/condition.c
26-
index d3446e8a9d..3f7cc9ea58 100644
26+
index 1a03fdbe37..8577c35fa0 100644
2727
--- a/src/shared/condition.c
2828
+++ b/src/shared/condition.c
29-
@@ -793,7 +793,7 @@ static int condition_test_needs_update(Condition *c, char **env) {
29+
@@ -796,7 +796,7 @@ static int condition_test_needs_update(Condition *c, char **env) {
3030
* First, compare seconds as they are always accurate...
3131
*/
3232
if (usr.st_mtim.tv_sec != other.st_mtim.tv_sec)
@@ -35,7 +35,7 @@ index d3446e8a9d..3f7cc9ea58 100644
3535

3636
/*
3737
* ...then compare nanoseconds.
38-
@@ -804,7 +804,7 @@ static int condition_test_needs_update(Condition *c, char **env) {
38+
@@ -807,7 +807,7 @@ static int condition_test_needs_update(Condition *c, char **env) {
3939
* (otherwise the filesystem supports nsec timestamps, see stat(2)).
4040
*/
4141
if (usr.st_mtim.tv_nsec == 0 || other.st_mtim.tv_nsec > 0)
@@ -44,7 +44,7 @@ index d3446e8a9d..3f7cc9ea58 100644
4444

4545
_cleanup_free_ char *timestamp_str = NULL;
4646
r = parse_env_file(NULL, p, "TIMESTAMP_NSEC", &timestamp_str);
47-
@@ -824,7 +824,7 @@ static int condition_test_needs_update(Condition *c, char **env) {
47+
@@ -827,7 +827,7 @@ static int condition_test_needs_update(Condition *c, char **env) {
4848
return true;
4949
}
5050

@@ -54,5 +54,5 @@ index d3446e8a9d..3f7cc9ea58 100644
5454

5555
static bool in_first_boot(void) {
5656
--
57-
2.34.1
57+
2.51.0
5858

sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/files/0004-core-use-max-for-DefaultTasksMax.patch renamed to sdk_container/src/third_party/coreos-overlay/coreos/user-patches/sys-apps/systemd/0003-core-use-max-for-DefaultTasksMax.patch

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
From d21ebfcf17ffc1dba635389193f10d2b93eba730 Mon Sep 17 00:00:00 2001
1+
From 6f691278df570cc87cb863a98fe320a1997c6dad Mon Sep 17 00:00:00 2001
22
From: Adrian Vladu <[email protected]>
33
Date: Fri, 16 Feb 2024 11:22:08 +0000
4-
Subject: [PATCH 4/8] core: use max for DefaultTasksMax
4+
Subject: [PATCH 3/8] core: use max for DefaultTasksMax
55

66
Since systemd v228, systemd has a DefaultTasksMax which defaulted
77
to 512, later 15% of the system's maximum number of PIDs. This
@@ -21,10 +21,10 @@ Signed-off-by: Adrian Vladu <[email protected]>
2121
3 files changed, 3 insertions(+), 3 deletions(-)
2222

2323
diff --git a/man/systemd-system.conf.xml b/man/systemd-system.conf.xml
24-
index 3c06b65f93..71f38692b6 100644
24+
index f7b414da5c..9c07e235ab 100644
2525
--- a/man/systemd-system.conf.xml
2626
+++ b/man/systemd-system.conf.xml
27-
@@ -501,7 +501,7 @@
27+
@@ -230,7 +230,7 @@
2828
<listitem><para>Configure the default value for the per-unit <varname>TasksMax=</varname> setting. See
2929
<citerefentry><refentrytitle>systemd.resource-control</refentrytitle><manvolnum>5</manvolnum></citerefentry>
3030
for details. This setting applies to all unit types that support resource control settings, with the exception
@@ -34,10 +34,10 @@ index 3c06b65f93..71f38692b6 100644
3434
Kernel has a default value for <varname>kernel.pid_max=</varname> and an algorithm of counting in case of more than 32 cores.
3535
For example, with the default <varname>kernel.pid_max=</varname>, <varname>DefaultTasksMax=</varname> defaults to 4915,
3636
diff --git a/src/core/manager.c b/src/core/manager.c
37-
index 88eebfc626..8992c8c3e3 100644
37+
index 4ccaba9054..3ab59c5bb3 100644
3838
--- a/src/core/manager.c
3939
+++ b/src/core/manager.c
40-
@@ -114,7 +114,7 @@
40+
@@ -117,7 +117,7 @@
4141
/* How many units and jobs to process of the bus queue before returning to the event loop. */
4242
#define MANAGER_BUS_MESSAGE_BUDGET 100U
4343

@@ -47,10 +47,10 @@ index 88eebfc626..8992c8c3e3 100644
4747
static int manager_dispatch_notify_fd(sd_event_source *source, int fd, uint32_t revents, void *userdata);
4848
static int manager_dispatch_cgroups_agent_fd(sd_event_source *source, int fd, uint32_t revents, void *userdata);
4949
diff --git a/src/core/system.conf.in b/src/core/system.conf.in
50-
index 05eb681270..94d0365244 100644
50+
index 1c08aa4d22..2faea3605e 100644
5151
--- a/src/core/system.conf.in
5252
+++ b/src/core/system.conf.in
53-
@@ -58,7 +58,7 @@
53+
@@ -59,7 +59,7 @@
5454
#DefaultIPAccounting=no
5555
#DefaultMemoryAccounting={{ 'yes' if MEMORY_ACCOUNTING_DEFAULT else 'no' }}
5656
#DefaultTasksAccounting=yes
@@ -60,5 +60,5 @@ index 05eb681270..94d0365244 100644
6060
#DefaultLimitFSIZE=
6161
#DefaultLimitDATA=
6262
--
63-
2.34.1
63+
2.51.0
6464

sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/files/0005-systemd-Disable-SELinux-permissions-checks.patch renamed to sdk_container/src/third_party/coreos-overlay/coreos/user-patches/sys-apps/systemd/0004-systemd-Disable-SELinux-permissions-checks.patch

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
From 374cca5b2f9aea1c506352cf58b09db5c216a0d3 Mon Sep 17 00:00:00 2001
1+
From 78b2d8b1a6df073003d64cffa532c3a320e96ad4 Mon Sep 17 00:00:00 2001
22
From: Matthew Garrett <[email protected]>
33
Date: Tue, 20 Dec 2016 16:43:22 +0000
4-
Subject: [PATCH 5/8] systemd: Disable SELinux permissions checks
4+
Subject: [PATCH 4/8] systemd: Disable SELinux permissions checks
55

66
We don't care about the interaction between systemd and SELinux policy, so
77
let's just disable these checks rather than having to incorporate policy
@@ -12,7 +12,7 @@ to limit containers and not anything running directly on the host.
1212
1 file changed, 1 insertion(+), 1 deletion(-)
1313

1414
diff --git a/src/core/selinux-access.c b/src/core/selinux-access.c
15-
index 62181a6309..448f9211d6 100644
15+
index a67a520a3b..3365b920eb 100644
1616
--- a/src/core/selinux-access.c
1717
+++ b/src/core/selinux-access.c
1818
@@ -2,7 +2,7 @@
@@ -25,5 +25,5 @@ index 62181a6309..448f9211d6 100644
2525
#include <errno.h>
2626
#include <selinux/avc.h>
2727
--
28-
2.34.1
28+
2.51.0
2929

sdk_container/src/third_party/coreos-overlay/sys-apps/systemd/files/0006-Revert-getty-Pass-tty-to-use-by-agetty-via-stdin-257.patch renamed to sdk_container/src/third_party/coreos-overlay/coreos/user-patches/sys-apps/systemd/0005-Revert-getty-Pass-tty-to-use-by-agetty-via-stdin.patch

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
From bffb2a48796a2736d7fb7328d2a88b1cbb812b12 Mon Sep 17 00:00:00 2001
1+
From 8064e1544a2b89f8389c0469ed4879a287a045a7 Mon Sep 17 00:00:00 2001
22
From: Sayan Chowdhury <[email protected]>
33
Date: Fri, 16 Dec 2022 16:28:26 +0530
4-
Subject: [PATCH 6/8] Revert "getty: Pass tty to use by agetty via stdin"
4+
Subject: [PATCH 5/8] Revert "getty: Pass tty to use by agetty via stdin"
55

66
This reverts commit b4bf9007cbee7dc0b1356897344ae2a7890df84c.
77

@@ -90,3 +90,6 @@ index 20a5eb2754..ba4cbc0edb 100644
9090
TTYPath=/dev/%I
9191
TTYReset=yes
9292
TTYVHangup=yes
93+
--
94+
2.51.0
95+

0 commit comments

Comments
 (0)