commit:     830b0a92b868ba86f500fae2f19cceb92382088d
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Tue May 20 13:41:50 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue May 20 14:06:21 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=830b0a92

dev-libs/libcgroup: add 3.2.0

Now with wired-up tests, which completes something I'd made progress
towards in 70e3169fa8441f6c76d9329edee258e6d5c44ee3. LTO is filtered
though for now as tests fail with it enabled (bug #956346).

Bug: https://bugs.gentoo.org/956346
Signed-off-by: Sam James <sam <AT> gentoo.org>

 dev-libs/libcgroup/Manifest                        |   1 +
 .../files/libcgroup-3.2.0-use-system-gtest.patch   |  33 ++++++
 dev-libs/libcgroup/libcgroup-3.2.0.ebuild          | 120 +++++++++++++++++++++
 3 files changed, 154 insertions(+)

diff --git a/dev-libs/libcgroup/Manifest b/dev-libs/libcgroup/Manifest
index 03340db8b09c..ce065bc12217 100644
--- a/dev-libs/libcgroup/Manifest
+++ b/dev-libs/libcgroup/Manifest
@@ -1 +1,2 @@
 DIST libcgroup-3.1.0.tar.gz 1223547 BLAKE2B 
3cd3ca779b4453df71aba584ad8fe654fb55478ad89b36ba5deccf46e3ef331b11dc32a9a72dfa525784558701a72fd0777e05275233e599015ae93269661534
 SHA512 
84272e811422f2105e275ccadbd333fe6da495da5504cd97acd3101718e27b52e0f56b62f847933b32d613e15c170d1b998d85a89c1591e8ce37c33043f3e00b
+DIST libcgroup-3.2.0.tar.gz 835265 BLAKE2B 
fe6075ac50691ca51cdcda0820f565ceab66b661bf6afd6e621a3d5037142cb2daa0394ada1c5cb04fcfa367b546da01c1b8aa52297e5907ef9ed3311d850a53
 SHA512 
69fb2bbb8838d97fb65183ce4811a34ea899c88bccba02b8f28522ee4435b73effddd47c40733065dc2fd291db823bd428b20a18dce5e7dc9976194c08a56aaa

diff --git a/dev-libs/libcgroup/files/libcgroup-3.2.0-use-system-gtest.patch 
b/dev-libs/libcgroup/files/libcgroup-3.2.0-use-system-gtest.patch
new file mode 100644
index 000000000000..5135cb22ff1e
--- /dev/null
+++ b/dev-libs/libcgroup/files/libcgroup-3.2.0-use-system-gtest.patch
@@ -0,0 +1,33 @@
+--- a/tests/gunit/Makefile.am
++++ b/tests/gunit/Makefile.am
+@@ -11,8 +11,6 @@ if WITH_UNITTESTS
+ AM_CPPFLAGS = -I$(top_srcdir)/include \
+             -I$(top_srcdir)/src \
+             -I$(top_srcdir)/src/tools \
+-            -I$(top_srcdir)/googletest/googletest/include \
+-            -I$(top_srcdir)/googletest/googletest \
+             -std=c++11 \
+             -Wno-write-strings \
+             -DSTATIC= \
+@@ -20,10 +18,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/include \
+ LDADD = $(top_builddir)/src/.libs/libcgroupfortesting.la \
+       $(top_builddir)/src/tools/.libs/libcgset.la
+ 
+-EXTRA_DIST = $(top_srcdir)/googletest/build/lib/libgtest.a \
+-           $(top_srcdir)/googletest/build/lib/libgtest_main.a \
+-           $(top_srcdir)/googletest/googletest/include \
+-           libcgroup_unittest.map
++EXTRA_DIST = libcgroup_unittest.map
+ 
+ check_PROGRAMS = gtest
+ TESTS = gtest
+@@ -48,8 +43,7 @@ gtest_SOURCES = gtest.cpp \
+               017-API_fuzz_test.cpp \
+               018-get_next_rule_field.cpp
+ 
+-gtest_LDFLAGS = -L$(top_srcdir)/googletest/build/lib -l:libgtest.a \
+-              -rpath $(abs_top_srcdir)/googletest/googletest
++gtest_LDFLAGS = -lgtest
+ 
+ clean-local:
+       ${RM} test-procpidcgroup

diff --git a/dev-libs/libcgroup/libcgroup-3.2.0.ebuild 
b/dev-libs/libcgroup/libcgroup-3.2.0.ebuild
new file mode 100644
index 000000000000..0baec562691c
--- /dev/null
+++ b/dev-libs/libcgroup/libcgroup-3.2.0.ebuild
@@ -0,0 +1,120 @@
+# Copyright 1999-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit autotools flag-o-matic linux-info pam systemd
+
+DESCRIPTION="Tools and libraries to configure and manage kernel control groups"
+HOMEPAGE="https://github.com/libcgroup/libcgroup";
+SRC_URI="https://github.com/libcgroup/libcgroup/releases/download/v${PV}/${P}.tar.gz";
+
+LICENSE="LGPL-2.1"
+SLOT="0"
+KEYWORDS="~amd64 ~arm ~arm64 ~ppc ~ppc64 ~riscv ~x86"
+IUSE="+daemon pam static-libs systemd test +tools"
+REQUIRED_USE="daemon? ( tools )"
+RESTRICT="!test? ( test ) "
+
+DEPEND="
+       elibc_musl? ( sys-libs/fts-standalone )
+       pam? ( sys-libs/pam )
+       systemd? ( sys-apps/systemd:= )
+"
+RDEPEND="${DEPEND}"
+BDEPEND="
+       sys-devel/bison
+       sys-devel/flex
+       test? ( dev-cpp/gtest )
+"
+
+PATCHES=(
+       "${FILESDIR}"/${PN}-3.2.0-use-system-gtest.patch
+)
+
+pkg_setup() {
+       local CONFIG_CHECK="~CGROUPS"
+       if use daemon; then
+               CONFIG_CHECK="${CONFIG_CHECK} ~CONNECTOR ~PROC_EVENTS"
+       fi
+       linux-info_pkg_setup
+}
+
+src_prepare() {
+       default
+
+       # Change rules file location
+       find src -name '*.c' -o -name '*.h' -print0 \
+               | xargs -0 sed -i '/^#define/s:/etc/cg:/etc/cgroup/cg:'
+       sed -i 's:/etc/cg:/etc/cgroup/cg:' \
+               doc/man/cg* samples/config/*.conf README* || die "sed failed"
+
+       eautoreconf
+}
+
+src_configure() {
+       if use elibc_musl; then
+               append-ldflags -lfts
+       fi
+
+       # gtest needs >=C++14, just pick gnu++17
+       append-cxxflags -std=gnu++17
+
+       # Test failures (bug #956346)
+       filter-lto
+
+       # Needs flex+bison
+       unset LEX YACC
+
+       local myconf=(
+               --disable-python
+               $(use_enable static-libs static)
+               $(use_enable daemon)
+               $(use_enable pam)
+               $(use_enable systemd)
+               $(use_enable tools)
+               $(use_enable test tests)
+               $(use_enable test unittests)
+       )
+
+       if use pam; then
+               myconf+=( "--enable-pam-module-dir=$(getpam_mod_dir)" )
+       fi
+
+       econf "${myconf[@]}"
+}
+
+src_test() {
+       # Sandboxes confuse this as it expects specific cgroup layout
+       local -x GTEST_FILTER="-CgroupProcessV1MntTest.AddV1NamedMount"
+
+       # Run just the unit tests rather than the full lot as they
+       # need fewer permissions, no containers, etc.
+       emake -C tests/gunit check
+}
+
+src_install() {
+       default
+
+       find "${ED}" -name '*.la' -delete || die
+
+       insinto /etc/cgroup
+       doins samples/config/cgconfig.conf
+       doins samples/config/cgrules.conf
+       doins samples/config/cgsnapshot_denylist.conf
+
+       keepdir /etc/cgroup/cgconfig.d
+       keepdir /etc/cgroup/cgrules.d
+
+       if use tools; then
+               newconfd "${FILESDIR}/cgconfig.confd-r2" cgconfig
+               newinitd "${FILESDIR}/cgconfig.initd-r2" cgconfig
+               systemd_dounit "${FILESDIR}/cgconfig.service"
+               systemd_dounit "${FILESDIR}/cgrules.service"
+       fi
+
+       if use daemon; then
+               newconfd "${FILESDIR}/cgred.confd-r2" cgred
+               newinitd "${FILESDIR}/cgred.initd-r1" cgred
+       fi
+}

Reply via email to