Gentoo Archives: gentoo-commits

From: Sam James <sam@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-libs/libcgroup/files/, dev-libs/libcgroup/
Date: Sat, 10 Sep 2022 13:30:09
Message-Id: 1662816593.70e3169fa8441f6c76d9329edee258e6d5c44ee3.sam@gentoo
1 commit: 70e3169fa8441f6c76d9329edee258e6d5c44ee3
2 Author: Sam James <sam <AT> gentoo <DOT> org>
3 AuthorDate: Sat Sep 10 12:47:49 2022 +0000
4 Commit: Sam James <sam <AT> gentoo <DOT> org>
5 CommitDate: Sat Sep 10 13:29:53 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=70e3169f
7
8 dev-libs/libcgroup: add 3.0.0
9
10 Closes: https://bugs.gentoo.org/830071
11 Signed-off-by: Sam James <sam <AT> gentoo.org>
12
13 dev-libs/libcgroup/Manifest | 1 +
14 .../files/libcgroup-3.0.0-configure-bashism.patch | 35 +++++++
15 .../files/libcgroup-3.0.0-musl-strerror_r.patch | 45 ++++++++
16 dev-libs/libcgroup/libcgroup-3.0.0.ebuild | 113 +++++++++++++++++++++
17 4 files changed, 194 insertions(+)
18
19 diff --git a/dev-libs/libcgroup/Manifest b/dev-libs/libcgroup/Manifest
20 index b9417a00e1e3..fc793519300c 100644
21 --- a/dev-libs/libcgroup/Manifest
22 +++ b/dev-libs/libcgroup/Manifest
23 @@ -1,2 +1,3 @@
24 DIST libcgroup-0.41.tar.bz2 500120 BLAKE2B 3410b430aa58613b5b9abedba05bef99b1b8a1fd619d55fb446ab951e052a336efc918879217055bceee886a03d97c3ff46028a87e8231212653a886cfb80521 SHA512 1aedb02cd2ce3bc2e2a328a247a92976ad0978ca4d3aee4eb671fbcc6bb270348efc78dcf84f27fc500f8bfb9bb57c7d6e4d429ef2bc69e4e5118b7cd895a6bd
25 DIST libcgroup-2.0.tar.bz2 953191 BLAKE2B d4fe008a51a4f90047210a3c8e4ce48b1c4a126111ccc7fe919404b1782ea764404894a43a651e0d6b2674d02fb031cb56cf7a689c57600d856c03536524bb63 SHA512 b2c5d1128536bf49782415df2d1530cf48bdb287e5d2abdee68f9fa780d995d9bae79f97da5f0c437130d66054c96301b319cd1631a3b0efbc5bfe1e3414dc4b
26 +DIST libcgroup-3.0.0.tar.gz 1125800 BLAKE2B 5d4999ac513de756ffe741d2e959c01d8500a2000f521dff31832e1ef545869fb9c8ae1c78d05aaa051e7e6e68266bd57a751ba3aa897966a83ff50128090ba5 SHA512 1e8a7c9a71d928ab0e354254b007b30fc159a30e441bd52a03ded142420c94e130594bb512680c62fc22f5193934fb78afc31453342b032d1db3197fd4c3e606
27
28 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
29 new file mode 100644
30 index 000000000000..1401953b53a7
31 --- /dev/null
32 +++ b/dev-libs/libcgroup/files/libcgroup-3.0.0-configure-bashism.patch
33 @@ -0,0 +1,35 @@
34 +https://github.com/libcgroup/libcgroup/pull/243
35 +
36 +From a363c163fdeb48e0536545ece856899ed97e99b2 Mon Sep 17 00:00:00 2001
37 +From: Sam James <sam@g.o>
38 +Date: Sat, 10 Sep 2022 13:52:57 +0100
39 +Subject: [PATCH] configure.ac: fix bashism
40 +
41 +configure scripts need to be runnable with a POSIX-compliant /bin/sh.
42 +
43 +On many (but not all!) systems, /bin/sh is provided by Bash, so errors
44 +like this aren't spotted. Notably Debian defaults to /bin/sh provided
45 +by dash which doesn't tolerate such bashisms as '=='.
46 +
47 +This retains compatibility with bash.
48 +
49 +Fixes configure warnings/errors like:
50 +```
51 +checking whether to build static libraries... no
52 +./configure: 14089: test: xno: unexpected operator
53 +checking for x86_64-pc-linux-gnu-g++... x86_64-pc-linux-gnu-g++
54 +```
55 +
56 +Signed-off-by: Sam James <sam@g.o>
57 +--- a/configure.ac
58 ++++ b/configure.ac
59 +@@ -137,7 +137,7 @@ AC_ARG_ENABLE([opaque-hierarchy],
60 + AC_ARG_ENABLE([tests],
61 + [AS_HELP_STRING([--enable-tests],[compile libcgroup tests [default=yes]])],
62 + [
63 +- if test "x$enableval" == xno; then
64 ++ if test "x$enableval" = xno; then
65 + with_tests=false
66 + else
67 + with_tests=true
68 +
69
70 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
71 new file mode 100644
72 index 000000000000..cc1b0688c79b
73 --- /dev/null
74 +++ b/dev-libs/libcgroup/files/libcgroup-3.0.0-musl-strerror_r.patch
75 @@ -0,0 +1,45 @@
76 +https://github.com/libcgroup/libcgroup/pull/236
77 +
78 +From d190c0c548b3219b75e4c399aa89186e77bbe270 Mon Sep 17 00:00:00 2001
79 +From: Khem Raj <raj.khem@×××××.com>
80 +Date: Tue, 23 Aug 2022 20:03:09 -0700
81 +Subject: [PATCH] api: Use GNU strerror_r when available
82 +
83 +GNU strerror_r is only available in glibc, musl impelents the XSI
84 +version which is slightly different, therefore check if GNU version is
85 +available before using it, otherwise use the XSI compliant version.
86 +
87 +Signed-off-by: Khem Raj <raj.khem@×××××.com>
88 +--- a/configure.ac
89 ++++ b/configure.ac
90 +@@ -183,6 +183,11 @@ AC_FUNC_REALLOC
91 + AC_FUNC_STAT
92 + AC_CHECK_FUNCS([getmntent hasmntopt memset mkdir rmdir strdup])
93 +
94 ++orig_CFLAGS="$CFLAGS"
95 ++CFLAGS="$CFLAGS -D_GNU_SOURCE"
96 ++AC_FUNC_STRERROR_R
97 ++CFLAGS="$orig_CFLAGS"
98 ++
99 + AC_SEARCH_LIBS(
100 + [fts_open],
101 + [fts],
102 +--- a/src/api.c
103 ++++ b/src/api.c
104 +@@ -4571,9 +4571,13 @@ const char *cgroup_strerror(int code)
105 + {
106 + int idx = code % ECGROUPNOTCOMPILED;
107 +
108 +- if (code == ECGOTHER)
109 ++ if (code == ECGOTHER) {
110 ++#ifdef STRERROR_R_CHAR_P
111 + return strerror_r(cgroup_get_last_errno(), errtext, MAXLEN);
112 +-
113 ++#else
114 ++ return strerror_r(cgroup_get_last_errno(), errtext, sizeof (errtext)) ? "unknown error" : errtext;
115 ++#endif
116 ++ }
117 + if (idx >= sizeof(cgroup_strerror_codes)/sizeof(cgroup_strerror_codes[0]))
118 + return "Invalid error code";
119 +
120 +
121
122 diff --git a/dev-libs/libcgroup/libcgroup-3.0.0.ebuild b/dev-libs/libcgroup/libcgroup-3.0.0.ebuild
123 new file mode 100644
124 index 000000000000..a5009c1da4d8
125 --- /dev/null
126 +++ b/dev-libs/libcgroup/libcgroup-3.0.0.ebuild
127 @@ -0,0 +1,113 @@
128 +# Copyright 1999-2022 Gentoo Authors
129 +# Distributed under the terms of the GNU General Public License v2
130 +
131 +EAPI=8
132 +
133 +inherit autotools flag-o-matic linux-info pam systemd
134 +
135 +DESCRIPTION="Tools and libraries to configure and manage kernel control groups"
136 +HOMEPAGE="https://github.com/libcgroup/libcgroup"
137 +SRC_URI="https://github.com/libcgroup/libcgroup/releases/download/v$(ver_cut 1-2)/${P}.tar.gz"
138 +
139 +LICENSE="LGPL-2.1"
140 +SLOT="0"
141 +KEYWORDS="~amd64 ~arm ~arm64 ~ppc ~ppc64 ~riscv ~x86"
142 +IUSE="+daemon pam static-libs test +tools"
143 +REQUIRED_USE="daemon? ( tools )"
144 +
145 +# Test failure needs investigation
146 +RESTRICT="!test? ( test ) test"
147 +
148 +BDEPEND="
149 + sys-devel/bison
150 + sys-devel/flex
151 +"
152 +DEPEND="
153 + elibc_musl? ( sys-libs/fts-standalone )
154 + pam? ( sys-libs/pam )
155 +"
156 +RDEPEND="${DEPEND}"
157 +
158 +PATCHES=(
159 + "${FILESDIR}"/${PN}-3.0.0-configure-bashism.patch
160 + "${FILESDIR}"/${PN}-3.0.0-musl-strerror_r.patch
161 +)
162 +
163 +pkg_setup() {
164 + local CONFIG_CHECK="~CGROUPS"
165 + if use daemon; then
166 + CONFIG_CHECK="${CONFIG_CHECK} ~CONNECTOR ~PROC_EVENTS"
167 + fi
168 + linux-info_pkg_setup
169 +}
170 +
171 +src_prepare() {
172 + default
173 +
174 + # Change rules file location
175 + find src -name *.c -o -name *.h \
176 + | xargs sed -i '/^#define/s:/etc/cg:/etc/cgroup/cg:'
177 + sed -i 's:/etc/cg:/etc/cgroup/cg:' \
178 + doc/man/cg* samples/config/*.conf README* || die "sed failed"
179 +
180 + # Drop native libcgconfig init config
181 + sed -i '/^man_MANS/s:cgred.conf.5::' \
182 + doc/man/Makefile.am || die "sed failed"
183 +
184 + # If we're not running tests, don't bother building them.
185 + if ! use test; then
186 + sed -i '/^SUBDIRS/s:tests::' Makefile.am || die
187 + fi
188 +
189 + eautoreconf
190 +}
191 +
192 +src_configure() {
193 + use elibc_musl && append-ldflags -lfts
194 +
195 + local my_conf=(
196 + $(use_enable static-libs static)
197 + $(use_enable daemon)
198 + $(use_enable pam)
199 + $(use_enable tools)
200 + $(use_enable test tests)
201 + )
202 +
203 + if use pam; then
204 + my_conf+=( --enable-pam-module-dir="$(getpam_mod_dir)" )
205 + fi
206 +
207 + econf "${my_conf[@]}"
208 +}
209 +
210 +src_test() {
211 + # Run just the unit tests rather than the full lot as they
212 + # need fewer permissions, no containers, etc.
213 + emake -C tests/gunit check
214 +}
215 +
216 +src_install() {
217 + default
218 +
219 + find "${ED}" -name '*.la' -delete || die
220 +
221 + insinto /etc/cgroup
222 + doins samples/config/cgconfig.conf
223 + doins samples/config/cgrules.conf
224 + doins samples/config/cgsnapshot_blacklist.conf
225 +
226 + keepdir /etc/cgroup/cgconfig.d
227 + keepdir /etc/cgroup/cgrules.d
228 +
229 + if use tools; then
230 + newconfd "${FILESDIR}"/cgconfig.confd-r1 cgconfig
231 + newinitd "${FILESDIR}"/cgconfig.initd-r1 cgconfig
232 + systemd_dounit "${FILESDIR}"/cgconfig.service
233 + systemd_dounit "${FILESDIR}"/cgrules.service
234 + fi
235 +
236 + if use daemon; then
237 + newconfd "${FILESDIR}"/cgred.confd-r2 cgred
238 + newinitd "${FILESDIR}"/cgred.initd-r1 cgred
239 + fi
240 +}