commit: af51458719512096ae181fc2d28c567a96b4dd20 Author: Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org> AuthorDate: Mon Jun 28 18:46:04 2021 +0000 Commit: Georgy Yakovlev <gyakovlev <AT> gentoo <DOT> org> CommitDate: Mon Jun 28 18:46:58 2021 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=af514587
sys-apps/systemd-tmpfiles: add musl-selinux-mallinfo patch Thanks-to: Jonathan Davies <jpds <AT> protonmail.com> Closes: https://github.com/gentoo/musl/pull/433 Signed-off-by: Georgy Yakovlev <gyakovlev <AT> gentoo.org> .../files/systemd-tmpfiles-246-musl-mallinfo.patch | 60 ++++++++++++++++++++++ .../systemd-tmpfiles/systemd-tmpfiles-246.ebuild | 7 ++- 2 files changed, 65 insertions(+), 2 deletions(-) diff --git a/sys-apps/systemd-tmpfiles/files/systemd-tmpfiles-246-musl-mallinfo.patch b/sys-apps/systemd-tmpfiles/files/systemd-tmpfiles-246-musl-mallinfo.patch new file mode 100644 index 00000000000..ea97b909022 --- /dev/null +++ b/sys-apps/systemd-tmpfiles/files/systemd-tmpfiles-246-musl-mallinfo.patch @@ -0,0 +1,60 @@ +--- a/meson.build 2021-05-13 20:47:21.487670275 +0000 ++++ b/meson.build 2021-05-13 20:53:12.977688147 +0000 +@@ -542,6 +542,12 @@ else + conf.set10('HAVE_GETRANDOM', have) + endif + ++if cc.has_function('mallinfo', prefix : '''#include <malloc.h>''') ++ conf.set10('HAVE_MALLINFO', true) ++else ++ conf.set10('HAVE_MALLINFO', false) ++endif ++ + ##################################################################### + + vcs_tagger = [project_source_root + '/tools/meson-vcs-tag.sh', +--- a/src/basic/selinux-util.c 2021-05-13 20:17:47.044246714 +0000 ++++ b/src/basic/selinux-util.c 2021-05-13 21:00:56.591045053 +0000 +@@ -75,9 +75,13 @@ void mac_selinux_retest(void) { + int mac_selinux_init(void) { + #if HAVE_SELINUX + usec_t before_timestamp, after_timestamp; ++#if defined (__GLIBC__) && defined (HAVE_MALLINFO) + struct mallinfo before_mallinfo, after_mallinfo; ++#endif + char timespan[FORMAT_TIMESPAN_MAX]; ++#ifdef HAVE_MALLINFO + int l; ++#endif + + selinux_set_callback(SELINUX_CB_POLICYLOAD, (union selinux_callback) mac_selinux_reload); + +@@ -87,7 +91,9 @@ int mac_selinux_init(void) { + if (!mac_selinux_use()) + return 0; + ++#if defined (__GLIBC__) && defined (HAVE_MALLINFO) + before_mallinfo = mallinfo(); ++#endif + before_timestamp = now(CLOCK_MONOTONIC); + + label_hnd = selabel_open(SELABEL_CTX_FILE, NULL, 0); +@@ -95,6 +101,7 @@ int mac_selinux_init(void) { + return log_enforcing_errno(errno, "Failed to initialize SELinux labeling handle: %m"); + + after_timestamp = now(CLOCK_MONOTONIC); ++#if defined (__GLIBC__) && defined (HAVE_MALLINFO) + after_mallinfo = mallinfo(); + + l = after_mallinfo.uordblks > before_mallinfo.uordblks ? after_mallinfo.uordblks - before_mallinfo.uordblks : 0; +@@ -102,6 +109,10 @@ int mac_selinux_init(void) { + log_debug("Successfully loaded SELinux database in %s, size on heap is %iK.", + format_timespan(timespan, sizeof(timespan), after_timestamp - before_timestamp, 0), + (l+1023)/1024); ++#else ++ log_debug("Successfully loaded SELinux database in %s", ++ format_timespan(timespan, sizeof(timespan), after_timestamp - before_timestamp, 0)); ++#endif + + #endif + return 0; diff --git a/sys-apps/systemd-tmpfiles/systemd-tmpfiles-246.ebuild b/sys-apps/systemd-tmpfiles/systemd-tmpfiles-246.ebuild index 7bce5591c7b..74e8fd42887 100644 --- a/sys-apps/systemd-tmpfiles/systemd-tmpfiles-246.ebuild +++ b/sys-apps/systemd-tmpfiles/systemd-tmpfiles-246.ebuild @@ -53,8 +53,11 @@ pkg_setup() { src_prepare() { # musl patchset from: # http://cgit.openembedded.org/openembedded-core/tree/meta/recipes-core/systemd/systemd - use elibc_musl && eapply "${WORKDIR}/${P}-musl" - use elibc_musl && eapply "${FILESDIR}/musl-1.2.2.patch" # https://bugs.gentoo.org/766833 + if use elibc_musl; then + eapply "${WORKDIR}/${P}-musl" + eapply "${FILESDIR}/musl-1.2.2.patch" # https://bugs.gentoo.org/766833 + use selinux && eapply "${FILESDIR}/${P}-musl-mallinfo.patch" # https://github.com/gentoo/musl/pull/433 + fi default # https://bugs.gentoo.org/767403