commit:     fc93e053eb3891497a24365d3dd8a0e143e8dd74
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed May 10 00:51:13 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Wed May 10 00:51:13 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=fc93e053

sys-apps/systemd-utils: fix build w/ musl-1.2.4

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

 .../files/systemd-utils-253.4-musl-lfs.patch       | 52 ++++++++++++++++++++++
 sys-apps/systemd-utils/systemd-utils-253.4.ebuild  |  7 ++-
 2 files changed, 58 insertions(+), 1 deletion(-)

diff --git a/sys-apps/systemd-utils/files/systemd-utils-253.4-musl-lfs.patch 
b/sys-apps/systemd-utils/files/systemd-utils-253.4-musl-lfs.patch
new file mode 100644
index 000000000000..312232d0b3a5
--- /dev/null
+++ b/sys-apps/systemd-utils/files/systemd-utils-253.4-musl-lfs.patch
@@ -0,0 +1,52 @@
+https://github.com/systemd/systemd/pull/27599
+
+From d096e05c625ea825eb4d781216ded717b7f71cca Mon Sep 17 00:00:00 2001
+From: Sam James <[email protected]>
+Date: Wed, 10 May 2023 01:47:13 +0100
+Subject: [PATCH] dirent: conditionalize dirent assert based on dirent64
+ existence
+
+>=musl-1.2.4 doesn't define dirent64 and its LFS friends as its "native"
+functions are already LFS-aware.
+
+Check for dirent64 in meson.build and only assert if it exists.
+
+Bug: https://bugs.gentoo.org/905900
+Closes: https://github.com/systemd/systemd/pull/25809
+--- a/meson.build
++++ b/meson.build
+@@ -544,6 +544,7 @@ assert(long_max > 100000)
+ conf.set_quoted('LONG_MAX_STR', '@0@'.format(long_max))
+ 
+ decl_headers = '''
++#include <dirent.h>
+ #include <uchar.h>
+ #include <sys/mount.h>
+ #include <sys/stat.h>
+@@ -553,6 +554,7 @@ foreach decl : ['char16_t',
+                 'char32_t',
+                 'struct mount_attr',
+                 'struct statx',
++                'struct dirent64',
+                ]
+ 
+         # We get -1 if the size cannot be determined
+--- a/src/basic/dirent-util.h
++++ b/src/basic/dirent-util.h
+@@ -36,6 +36,7 @@ struct dirent *readdir_no_dot(DIR *dirp);
+ /* Only if 64bit off_t is enabled struct dirent + struct dirent64 are 
actually the same. We require this, and
+  * we want them to be interchangeable to make getdents64() work, hence verify 
that. */
+ assert_cc(_FILE_OFFSET_BITS == 64);
++#if HAVE_STRUCT_DIRENT64
+ assert_cc(sizeof(struct dirent) == sizeof(struct dirent64));
+ assert_cc(offsetof(struct dirent, d_ino) == offsetof(struct dirent64, d_ino));
+ assert_cc(sizeof_field(struct dirent, d_ino) == sizeof_field(struct dirent64, 
d_ino));
+@@ -47,6 +48,7 @@ assert_cc(offsetof(struct dirent, d_type) == offsetof(struct 
dirent64, d_type));
+ assert_cc(sizeof_field(struct dirent, d_type) == sizeof_field(struct 
dirent64, d_type));
+ assert_cc(offsetof(struct dirent, d_name) == offsetof(struct dirent64, 
d_name));
+ assert_cc(sizeof_field(struct dirent, d_name) == sizeof_field(struct 
dirent64, d_name));
++#endif
+ 
+ #define FOREACH_DIRENT_IN_BUFFER(de, buf, sz)                           \
+         for (void *_end = (uint8_t*) ({ (de) = (buf); }) + (sz);        \
+

diff --git a/sys-apps/systemd-utils/systemd-utils-253.4.ebuild 
b/sys-apps/systemd-utils/systemd-utils-253.4.ebuild
index 4dc4e15bbe49..ad372c33f20e 100644
--- a/sys-apps/systemd-utils/systemd-utils-253.4.ebuild
+++ b/sys-apps/systemd-utils/systemd-utils-253.4.ebuild
@@ -120,7 +120,12 @@ src_prepare() {
        )
 
        if use elibc_musl; then
-               PATCHES+=( "${WORKDIR}/${MUSL_PATCHSET}" )
+               PATCHES+=(
+                       "${WORKDIR}/${MUSL_PATCHSET}"
+                       # The LFS patch should be fine unconditionally but
+                       # let's keep it conditional until merged upstream.
+                       "${FILESDIR}"/${PN}-253.4-musl-lfs.patch
+               )
        fi
        default
 

Reply via email to