commit:     70e3169fa8441f6c76d9329edee258e6d5c44ee3
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Sat Sep 10 12:47:49 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Sep 10 13:29:53 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=70e3169f

dev-libs/libcgroup: add 3.0.0

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

 dev-libs/libcgroup/Manifest                        |   1 +
 .../files/libcgroup-3.0.0-configure-bashism.patch  |  35 +++++++
 .../files/libcgroup-3.0.0-musl-strerror_r.patch    |  45 ++++++++
 dev-libs/libcgroup/libcgroup-3.0.0.ebuild          | 113 +++++++++++++++++++++
 4 files changed, 194 insertions(+)

diff --git a/dev-libs/libcgroup/Manifest b/dev-libs/libcgroup/Manifest
index b9417a00e1e3..fc793519300c 100644
--- a/dev-libs/libcgroup/Manifest
+++ b/dev-libs/libcgroup/Manifest
@@ -1,2 +1,3 @@
 DIST libcgroup-0.41.tar.bz2 500120 BLAKE2B 
3410b430aa58613b5b9abedba05bef99b1b8a1fd619d55fb446ab951e052a336efc918879217055bceee886a03d97c3ff46028a87e8231212653a886cfb80521
 SHA512 
1aedb02cd2ce3bc2e2a328a247a92976ad0978ca4d3aee4eb671fbcc6bb270348efc78dcf84f27fc500f8bfb9bb57c7d6e4d429ef2bc69e4e5118b7cd895a6bd
 DIST libcgroup-2.0.tar.bz2 953191 BLAKE2B 
d4fe008a51a4f90047210a3c8e4ce48b1c4a126111ccc7fe919404b1782ea764404894a43a651e0d6b2674d02fb031cb56cf7a689c57600d856c03536524bb63
 SHA512 
b2c5d1128536bf49782415df2d1530cf48bdb287e5d2abdee68f9fa780d995d9bae79f97da5f0c437130d66054c96301b319cd1631a3b0efbc5bfe1e3414dc4b
+DIST libcgroup-3.0.0.tar.gz 1125800 BLAKE2B 
5d4999ac513de756ffe741d2e959c01d8500a2000f521dff31832e1ef545869fb9c8ae1c78d05aaa051e7e6e68266bd57a751ba3aa897966a83ff50128090ba5
 SHA512 
1e8a7c9a71d928ab0e354254b007b30fc159a30e441bd52a03ded142420c94e130594bb512680c62fc22f5193934fb78afc31453342b032d1db3197fd4c3e606

diff --git a/dev-libs/libcgroup/files/libcgroup-3.0.0-configure-bashism.patch 
b/dev-libs/libcgroup/files/libcgroup-3.0.0-configure-bashism.patch
new file mode 100644
index 000000000000..1401953b53a7
--- /dev/null
+++ b/dev-libs/libcgroup/files/libcgroup-3.0.0-configure-bashism.patch
@@ -0,0 +1,35 @@
+https://github.com/libcgroup/libcgroup/pull/243
+
+From a363c163fdeb48e0536545ece856899ed97e99b2 Mon Sep 17 00:00:00 2001
+From: Sam James <[email protected]>
+Date: Sat, 10 Sep 2022 13:52:57 +0100
+Subject: [PATCH] configure.ac: fix bashism
+
+configure scripts need to be runnable with a POSIX-compliant /bin/sh.
+
+On many (but not all!) systems, /bin/sh is provided by Bash, so errors
+like this aren't spotted. Notably Debian defaults to /bin/sh provided
+by dash which doesn't tolerate such bashisms as '=='.
+
+This retains compatibility with bash.
+
+Fixes configure warnings/errors like:
+```
+checking whether to build static libraries... no
+./configure: 14089: test: xno: unexpected operator
+checking for x86_64-pc-linux-gnu-g++... x86_64-pc-linux-gnu-g++
+```
+
+Signed-off-by: Sam James <[email protected]>
+--- a/configure.ac
++++ b/configure.ac
+@@ -137,7 +137,7 @@ AC_ARG_ENABLE([opaque-hierarchy],
+ AC_ARG_ENABLE([tests],
+       [AS_HELP_STRING([--enable-tests],[compile libcgroup tests 
[default=yes]])],
+       [
+-              if test "x$enableval" == xno; then
++              if test "x$enableval" = xno; then
+                       with_tests=false
+               else
+                       with_tests=true
+

diff --git a/dev-libs/libcgroup/files/libcgroup-3.0.0-musl-strerror_r.patch 
b/dev-libs/libcgroup/files/libcgroup-3.0.0-musl-strerror_r.patch
new file mode 100644
index 000000000000..cc1b0688c79b
--- /dev/null
+++ b/dev-libs/libcgroup/files/libcgroup-3.0.0-musl-strerror_r.patch
@@ -0,0 +1,45 @@
+https://github.com/libcgroup/libcgroup/pull/236
+
+From d190c0c548b3219b75e4c399aa89186e77bbe270 Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Tue, 23 Aug 2022 20:03:09 -0700
+Subject: [PATCH] api: Use GNU strerror_r when available
+
+GNU strerror_r is only available in glibc, musl impelents the XSI
+version which is slightly different, therefore check if GNU version is
+available before using it, otherwise use the XSI compliant version.
+
+Signed-off-by: Khem Raj <[email protected]>
+--- a/configure.ac
++++ b/configure.ac
+@@ -183,6 +183,11 @@ AC_FUNC_REALLOC
+ AC_FUNC_STAT
+ AC_CHECK_FUNCS([getmntent hasmntopt memset mkdir rmdir strdup])
+ 
++orig_CFLAGS="$CFLAGS"
++CFLAGS="$CFLAGS -D_GNU_SOURCE"
++AC_FUNC_STRERROR_R
++CFLAGS="$orig_CFLAGS"
++
+ AC_SEARCH_LIBS(
+       [fts_open],
+       [fts],
+--- a/src/api.c
++++ b/src/api.c
+@@ -4571,9 +4571,13 @@ const char *cgroup_strerror(int code)
+ {
+       int idx = code % ECGROUPNOTCOMPILED;
+ 
+-      if (code == ECGOTHER)
++      if (code == ECGOTHER) {
++#ifdef STRERROR_R_CHAR_P
+               return strerror_r(cgroup_get_last_errno(), errtext, MAXLEN);
+-
++#else
++              return strerror_r(cgroup_get_last_errno(), errtext, sizeof 
(errtext)) ? "unknown error" : errtext;
++#endif
++      }
+       if (idx >= 
sizeof(cgroup_strerror_codes)/sizeof(cgroup_strerror_codes[0]))
+               return "Invalid error code";
+ 
+

diff --git a/dev-libs/libcgroup/libcgroup-3.0.0.ebuild 
b/dev-libs/libcgroup/libcgroup-3.0.0.ebuild
new file mode 100644
index 000000000000..a5009c1da4d8
--- /dev/null
+++ b/dev-libs/libcgroup/libcgroup-3.0.0.ebuild
@@ -0,0 +1,113 @@
+# Copyright 1999-2022 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$(ver_cut 
1-2)/${P}.tar.gz"
+
+LICENSE="LGPL-2.1"
+SLOT="0"
+KEYWORDS="~amd64 ~arm ~arm64 ~ppc ~ppc64 ~riscv ~x86"
+IUSE="+daemon pam static-libs test +tools"
+REQUIRED_USE="daemon? ( tools )"
+
+# Test failure needs investigation
+RESTRICT="!test? ( test ) test"
+
+BDEPEND="
+       sys-devel/bison
+       sys-devel/flex
+"
+DEPEND="
+       elibc_musl? ( sys-libs/fts-standalone )
+       pam? ( sys-libs/pam )
+"
+RDEPEND="${DEPEND}"
+
+PATCHES=(
+       "${FILESDIR}"/${PN}-3.0.0-configure-bashism.patch
+       "${FILESDIR}"/${PN}-3.0.0-musl-strerror_r.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 \
+               | xargs 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"
+
+       # Drop native libcgconfig init config
+       sed -i '/^man_MANS/s:cgred.conf.5::' \
+               doc/man/Makefile.am || die "sed failed"
+
+       # If we're not running tests, don't bother building them.
+       if ! use test; then
+               sed -i '/^SUBDIRS/s:tests::' Makefile.am || die
+       fi
+
+       eautoreconf
+}
+
+src_configure() {
+       use elibc_musl && append-ldflags -lfts
+
+       local my_conf=(
+               $(use_enable static-libs static)
+               $(use_enable daemon)
+               $(use_enable pam)
+               $(use_enable tools)
+               $(use_enable test tests)
+       )
+
+       if use pam; then
+               my_conf+=( --enable-pam-module-dir="$(getpam_mod_dir)" )
+       fi
+
+       econf "${my_conf[@]}"
+}
+
+src_test() {
+       # 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_blacklist.conf
+
+       keepdir /etc/cgroup/cgconfig.d
+       keepdir /etc/cgroup/cgrules.d
+
+       if use tools; then
+               newconfd "${FILESDIR}"/cgconfig.confd-r1 cgconfig
+               newinitd "${FILESDIR}"/cgconfig.initd-r1 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