commit:     2e0a4dbc6b7753f19a8a6243603bd2792082359e
Author:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Mon Jul  1 15:12:43 2024 +0000
Commit:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Mon Jul  1 19:14:31 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2e0a4dbc

sys-apps/systemd: add pkg_pretend check for cgroup-hybrid

Bug: https://bugs.gentoo.org/935261
Signed-off-by: Mike Gilbert <floppym <AT> gentoo.org>

 ...emd-256.1-r1.ebuild => systemd-256.1-r2.ebuild} | 28 +++++++++++++++++++++-
 sys-apps/systemd/systemd-9999.ebuild               | 28 +++++++++++++++++++++-
 2 files changed, 54 insertions(+), 2 deletions(-)

diff --git a/sys-apps/systemd/systemd-256.1-r1.ebuild 
b/sys-apps/systemd/systemd-256.1-r2.ebuild
similarity index 94%
rename from sys-apps/systemd/systemd-256.1-r1.ebuild
rename to sys-apps/systemd/systemd-256.1-r2.ebuild
index d2c7ad24ef7b..178565ec7d40 100644
--- a/sys-apps/systemd/systemd-256.1-r1.ebuild
+++ b/sys-apps/systemd/systemd-256.1-r2.ebuild
@@ -33,7 +33,7 @@ HOMEPAGE="https://systemd.io/";
 LICENSE="GPL-2 LGPL-2.1 MIT public-domain"
 SLOT="0/2"
 IUSE="
-       acl apparmor audit boot cryptsetup curl +dns-over-tls elfutils
+       acl apparmor audit boot cgroup-hybrid cryptsetup curl +dns-over-tls 
elfutils
        fido2 +gcrypt gnutls homed http idn importd iptables +kernel-install 
+kmod
        +lz4 lzma +openssl pam pcre pkcs11 policykit pwquality qrcode
        +resolvconf +seccomp selinux split-usr +sysv-utils test tpm ukify 
vanilla xkb +zstd
@@ -180,12 +180,38 @@ BDEPEND="
 QA_FLAGS_IGNORED="usr/lib/systemd/boot/efi/.*"
 QA_EXECSTACK="usr/lib/systemd/boot/efi/*"
 
+check_cgroup_layout() {
+       # https://bugs.gentoo.org/935261
+       [[ ${MERGE_TYPE} != buildonly ]] || return
+       [[ -z ${ROOT} ]] || return
+       [[ -e /sys/fs/cgroup/unified ]] || return
+       grep -q 'SYSTEMD_CGROUP_ENABLE_LEGACY_FORCE=1' /proc/cmdline && return
+
+       eerror "This system appears to be booted with the 'hybrid' cgroup 
layout."
+       eerror "This layout obsolete and is disabled in systemd."
+
+       if grep -qF 'systemd.legacy_systemd_cgroup_controller' /proc/cmdline; 
then
+               eerror "Remove the systemd.legacy_systemd_cgroup_controller 
option"
+               eerror "from the kernel command line and reboot."
+               die "hybrid cgroup layout detected"
+       fi
+}
+
 pkg_pretend() {
        if use split-usr; then
                eerror "Please complete the migration to merged-usr."
                eerror "https://wiki.gentoo.org/wiki/Merge-usr";
                die "systemd no longer supports split-usr"
        fi
+
+       check_cgroup_layout
+
+       if use cgroup-hybrid; then
+               eerror "Disable the 'cgroup-hybrid' USE flag."
+               eerror "Rebuild any initramfs images after rebuilding systemd."
+               die "cgroup-hybrid is no longer supported"
+       fi
+
        if [[ ${MERGE_TYPE} != buildonly ]]; then
                local CONFIG_CHECK="~BLK_DEV_BSG ~CGROUPS
                        ~CGROUP_BPF ~DEVTMPFS ~EPOLL ~FANOTIFY ~FHANDLE

diff --git a/sys-apps/systemd/systemd-9999.ebuild 
b/sys-apps/systemd/systemd-9999.ebuild
index d2c7ad24ef7b..178565ec7d40 100644
--- a/sys-apps/systemd/systemd-9999.ebuild
+++ b/sys-apps/systemd/systemd-9999.ebuild
@@ -33,7 +33,7 @@ HOMEPAGE="https://systemd.io/";
 LICENSE="GPL-2 LGPL-2.1 MIT public-domain"
 SLOT="0/2"
 IUSE="
-       acl apparmor audit boot cryptsetup curl +dns-over-tls elfutils
+       acl apparmor audit boot cgroup-hybrid cryptsetup curl +dns-over-tls 
elfutils
        fido2 +gcrypt gnutls homed http idn importd iptables +kernel-install 
+kmod
        +lz4 lzma +openssl pam pcre pkcs11 policykit pwquality qrcode
        +resolvconf +seccomp selinux split-usr +sysv-utils test tpm ukify 
vanilla xkb +zstd
@@ -180,12 +180,38 @@ BDEPEND="
 QA_FLAGS_IGNORED="usr/lib/systemd/boot/efi/.*"
 QA_EXECSTACK="usr/lib/systemd/boot/efi/*"
 
+check_cgroup_layout() {
+       # https://bugs.gentoo.org/935261
+       [[ ${MERGE_TYPE} != buildonly ]] || return
+       [[ -z ${ROOT} ]] || return
+       [[ -e /sys/fs/cgroup/unified ]] || return
+       grep -q 'SYSTEMD_CGROUP_ENABLE_LEGACY_FORCE=1' /proc/cmdline && return
+
+       eerror "This system appears to be booted with the 'hybrid' cgroup 
layout."
+       eerror "This layout obsolete and is disabled in systemd."
+
+       if grep -qF 'systemd.legacy_systemd_cgroup_controller' /proc/cmdline; 
then
+               eerror "Remove the systemd.legacy_systemd_cgroup_controller 
option"
+               eerror "from the kernel command line and reboot."
+               die "hybrid cgroup layout detected"
+       fi
+}
+
 pkg_pretend() {
        if use split-usr; then
                eerror "Please complete the migration to merged-usr."
                eerror "https://wiki.gentoo.org/wiki/Merge-usr";
                die "systemd no longer supports split-usr"
        fi
+
+       check_cgroup_layout
+
+       if use cgroup-hybrid; then
+               eerror "Disable the 'cgroup-hybrid' USE flag."
+               eerror "Rebuild any initramfs images after rebuilding systemd."
+               die "cgroup-hybrid is no longer supported"
+       fi
+
        if [[ ${MERGE_TYPE} != buildonly ]]; then
                local CONFIG_CHECK="~BLK_DEV_BSG ~CGROUPS
                        ~CGROUP_BPF ~DEVTMPFS ~EPOLL ~FANOTIFY ~FHANDLE

Reply via email to