[07/15] libarchive: Fix build with glibc 2.36

Message ID 20220815171753.1858688-7-michael.tremer@ipfire.org
State Accepted
Commit 03d57d8f1e7cd3aef6be6c4a71e44227f329a68e
Headers
Series [01/15] sysvinit: Fix build against glibc 2.36 |

Commit Message

Michael Tremer Aug. 15, 2022, 5:17 p.m. UTC
  Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
---
 lfs/libarchive                                |  1 +
 ...ibarchive-3.6-fix-glibc-2.36-headers.patch | 41 +++++++++++++++++++
 2 files changed, 42 insertions(+)
 create mode 100644 src/patches/libarchive-3.6-fix-glibc-2.36-headers.patch
  

Patch

diff --git a/lfs/libarchive b/lfs/libarchive
index 42040b6db..f22bbd481 100644
--- a/lfs/libarchive
+++ b/lfs/libarchive
@@ -74,6 +74,7 @@  $(subst %,%_BLAKE2,$(objects)) :
 $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
 	@$(PREBUILD)
 	@rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE)
+	cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/libarchive-3.6-fix-glibc-2.36-headers.patch
 	cd $(DIR_APP) && ./configure --prefix=/usr --disable-static
 	cd $(DIR_APP) && make $(MAKETUNING)
 	cd $(DIR_APP) && make install
diff --git a/src/patches/libarchive-3.6-fix-glibc-2.36-headers.patch b/src/patches/libarchive-3.6-fix-glibc-2.36-headers.patch
new file mode 100644
index 000000000..7c88ca1b1
--- /dev/null
+++ b/src/patches/libarchive-3.6-fix-glibc-2.36-headers.patch
@@ -0,0 +1,41 @@ 
+From a2f68263a1da5ad227bcb9cd8fa91b93c8b6c99f Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Mon, 25 Jul 2022 10:56:53 -0700
+Subject: [PATCH] libarchive: Do not include sys/mount.h when linux/fs.h is
+ present
+
+These headers are in conflict and only one is needed by
+archive_read_disk_posix.c therefore include linux/fs.h if it exists
+otherwise include sys/mount.h
+
+It also helps compiling with glibc 2.36
+where sys/mount.h conflicts with linux/mount.h see [1]
+
+[1] https://sourceware.org/glibc/wiki/Release/2.36
+---
+ libarchive/archive_read_disk_posix.c | 5 ++---
+ 1 file changed, 2 insertions(+), 3 deletions(-)
+
+diff --git a/libarchive/archive_read_disk_posix.c b/libarchive/archive_read_disk_posix.c
+index 2b39e672b..a96008db7 100644
+--- a/libarchive/archive_read_disk_posix.c
++++ b/libarchive/archive_read_disk_posix.c
+@@ -34,9 +34,6 @@ __FBSDID("$FreeBSD$");
+ #ifdef HAVE_SYS_PARAM_H
+ #include <sys/param.h>
+ #endif
+-#ifdef HAVE_SYS_MOUNT_H
+-#include <sys/mount.h>
+-#endif
+ #ifdef HAVE_SYS_STAT_H
+ #include <sys/stat.h>
+ #endif
+@@ -54,6 +51,8 @@ __FBSDID("$FreeBSD$");
+ #endif
+ #ifdef HAVE_LINUX_FS_H
+ #include <linux/fs.h>
++#elif HAVE_SYS_MOUNT_H
++#include <sys/mount.h>
+ #endif
+ /*
+  * Some Linux distributions have both linux/ext2_fs.h and ext2fs/ext2_fs.h.