From a3d6f4ee3bcf146ef0eef5754abb2612baf5d3f6 Mon Sep 17 00:00:00 2001 From: Krzesimir Nowak Date: Fri, 24 Oct 2025 11:28:52 +0200 Subject: [PATCH] overlay sys-apps/systemd: Move our modifications to config overrides The most significant change here is to drop our manual service enabling in favor of invoking systemctl preset-all and moving the generated symlinks to /usr. Signed-off-by: Krzesimir Nowak --- .../coreos/config/env/sys-apps/systemd | 178 ++++++++++++++++- .../sys-apps/systemd/systemd-257.7-r1.ebuild | 185 ++---------------- 2 files changed, 186 insertions(+), 177 deletions(-) diff --git a/sdk_container/src/third_party/coreos-overlay/coreos/config/env/sys-apps/systemd b/sdk_container/src/third_party/coreos-overlay/coreos/config/env/sys-apps/systemd index f5f1ad0bbb..11b7f0ce0d 100644 --- a/sdk_container/src/third_party/coreos-overlay/coreos/config/env/sys-apps/systemd +++ b/sdk_container/src/third_party/coreos-overlay/coreos/config/env/sys-apps/systemd @@ -1,20 +1,177 @@ -cros_post_src_install_timesync() { - local dir="${D}$(systemd_get_systemunitdir)/systemd-timesyncd.service.d" - mkdir -p "${dir}" - pushd "${dir}" - cat <flatcar.conf || die +flatcar_systemd_meson_args_array=( + # Point to our user mailing list. + -Dsupport-url='https://groups.google.com/forum/#!forum/flatcar-linux-user' + + # Use our ntp servers. + -Dntp-servers="0.flatcar.pool.ntp.org 1.flatcar.pool.ntp.org 2.flatcar.pool.ntp.org 3.flatcar.pool.ntp.org" + + # Specify this, or meson breaks due to no /etc/login.defs. + -Dsystem-gid-max=999 + -Dsystem-uid-max=999 + + # PAM config directory. + -Dpamconfdir="${EPREFIX}/usr/share/pam.d" + + # The CoreOS epoch, Mon Jul 1 00:00:00 UTC 2013. Used by timesyncd + # as a sanity check for the minimum acceptable time. Explicitly + # set to avoid using the current build time. + -Dtime-epoch=1372636800 + + # No default name servers. + -Ddns-servers= + + # Disable the "First Boot Wizard", it isn't very applicable to us. + -Dfirstboot=false + + # Set latest network interface naming scheme for + # https://github.com/flatcar/Flatcar/issues/36 + -Ddefault-net-naming-scheme=latest + + # Combined log format: name plus description + -Dstatus-unit-format-default=combined + + # Disable multicast-dns, Link-Local Multicast Name Resolution and + # dnssec + -Ddefault-mdns=no + -Ddefault-llmnr=no + -Ddefault-dnssec=no +) +export MYMESONARGS="${flatcar_systemd_meson_args_array[*]@Q}" +unset 'flatcar_systemd_meson_args_array' + +# Save the original path to systemctl command, so we can use it for +# presetting, even after stubbing systemctl out below. +if [[ -z ${flatcar_hacked_systemctl} ]]; then + flatcar_hacked_systemctl=$(command -v systemctl) || die "systemctl not found" +fi +# Stubbed out completely - it is being invoked in the pkg_postinst to +# enable getty service and do some reexecs/reloads. None of these are +# necessary for us. +systemctl() { + : +} + +flatcar_systemctl_preset() { + local scope=${1} + + local systemctl_scope_arg + case ${scope} in + system) systemctl_scope_arg=--system;; + user) systemctl_scope_arg=--global;; # don't ask, using --user + # results in an "invalid + # argument" error + *) die "wrong scope ${scope@Q}, ought to be either system or user";; + esac + + "${flatcar_hacked_systemctl}" --root="${ED}" "${systemctl_scope_arg}" --preset-mode=enable-only preset-all || die + + local escaped_path + escaped_path=$(printf '%s' "${ED}/etc/systemd/" | sed -e 's/[#\&]/\\&/g') || die + + # make symlinks relative + find "${ED}/etc/systemd/${scope}" -type l -lname "/usr/lib/systemd/${scope}/*" -printf "%l\0%p\0" | \ + sed -z -e "s#^/usr/lib/systemd/#${escaped_path}#" | \ + xargs -0 -n2 ln -sfTr || die + + # This will print an error like: + # + # tar: /dev/null; then - # systemctl --root="${ROOT:-/}" enable getty@.service remote-fs.target || FAIL=1 - # fi - # elog "To enable a useful set of services, run the following:" - # elog " systemctl preset-all --preset-mode=enable-only" - # fi + if [[ -z ${REPLACING_VERSIONS} ]]; then + if type systemctl &>/dev/null; then + systemctl --root="${ROOT:-/}" enable getty@.service remote-fs.target || FAIL=1 + fi + elog "To enable a useful set of services, run the following:" + elog " systemctl preset-all --preset-mode=enable-only" + fi if [[ -L ${EROOT}/var/lib/systemd/timesync ]]; then rm "${EROOT}/var/lib/systemd/timesync"