Hi again,

Quoting Johannes Schauer Marin Rodrigues (2024-08-21 12:25:48)
> Quoting Helmut Grohne (2024-08-15 07:19:52)
> > On Thu, Aug 15, 2024 at 12:14:52AM -0400, Theodore Ts'o wrote:
> > > This only passes the "it builds, ship it!" test, but it appears that
> > > it might be enough to replace
> > 
> > My message was primarily targeted at getting an agreement on the
> > direction of a solution. As you imply that you are ok with this kind of
> > solution, I guess Johannes will volunteer to supply a patch for detailed
> > discussion.
> 
> please find a tested patch attached which is only little more than what was
> provided by Ted already. I built this with and without nocheck. When built 
> with
> nocheck, libarchive-dev does not get installed and attempting to use the
> resulting package will yield:
> 
> Copying files into the device: __populate_fs_from_tar: you need libarchive to
> be able to process tarballs mke2fs: Operation not permitted while populating
> file system
> 
> After installing libarchive13t64, I was able to create filesystems from
> tarballs as usual. Building without nocheck, tests pass fine.
> 
> Does this look okay?

it does not. Helmut discovered that my last patch breaks --without-libarchive.
If e2fsprogs builds fine even without archive.h present, then its existence can
no longer be used to also carry the meaning of whether to disable libarchive
support or not. Hence, my updated patch introduces a new config definition
called CONFIG_DISABLE_LIBARCHIVE which is set if --without-libarchive is
passed. In the other cases, the presence of archive.h will be used to determine
whether to include the real header or use the hard-coded forward declarations.

This was discovered because as a workaround for #1070042, e2fsprogs disables
libarchive support on mips64el in debian/rules. Since that bug is fixed, commit
018cd6e9a659917ac1374775f5a60b1cf0be182c can probably be reverted?

Thanks!

cheers, josch
>From 83ed3084ddc21cb085fbd5ffeaca30ae0741821a Mon Sep 17 00:00:00 2001
From: Johannes Schauer Marin Rodrigues <jo...@mister-muffin.de>
Date: Tue, 3 Sep 2024 13:15:33 +0200
Subject: [PATCH] misc/create_inode_libarchive.c: decouple --without-libarchive
 and HAVE_ARCHIVE_H

To aid bootstrapping, it would be useful to be able to build e2fsprogs
without archive.h as otherwise there is a build dependency loop with
libarchive. If archive.h is not present, add the missing forward
declarations and preprocessor definitions and typedefs. Since this
allows building e2fsprogs with libarchive support even without the
archive.h header present on the system, we cannot check HAVE_ARCHIVE_H
anymore to decide whether to build with libarchive support or not. So if
--without-libarchive is passed to ./configure, CONFIG_DISABLE_LIBARCHIVE
gets set and later checked to decide about libarchive support.

Closes: #1078693
---
 configure                      |  3 +++
 configure.ac                   |  2 ++
 lib/config.h.in                |  3 +++
 misc/create_inode_libarchive.c | 12 +++++++++++-
 4 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index cba3191c..3310cecc 100755
--- a/configure
+++ b/configure
@@ -13745,6 +13745,9 @@ then
 	try_libarchive=""
 	{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: Disabling libarchive support" >&5
 printf "%s\n" "Disabling libarchive support" >&6; }
+
+printf "%s\n" "#define CONFIG_DISABLE_LIBARCHIVE 1" >>confdefs.h
+
 elif test "$withval" = "direct"
 then
 	try_libarchive="direct"
diff --git a/configure.ac b/configure.ac
index 131caef3..ed5ba0aa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1307,6 +1307,8 @@ AS_HELP_STRING([--without-libarchive],[disable use of libarchive]),
 then
 	try_libarchive=""
 	AC_MSG_RESULT([Disabling libarchive support])
+	AC_DEFINE(CONFIG_DISABLE_LIBARCHIVE, 1,
+		[Define to 1 to completely disable libarchive])
 elif test "$withval" = "direct"
 then
 	try_libarchive="direct"
diff --git a/lib/config.h.in b/lib/config.h.in
index 04cec72b..819c4331 100644
--- a/lib/config.h.in
+++ b/lib/config.h.in
@@ -12,6 +12,9 @@
 /* Define to 1 for features for use by ext4 developers */
 #undef CONFIG_DEVELOPER_FEATURES
 
+/* Define to 1 to completely disable libarchive */
+#undef CONFIG_DISABLE_LIBARCHIVE
+
 /* Define to 1 if using dlopen to access libarchive */
 #undef CONFIG_DLOPEN_LIBARCHIVE
 
diff --git a/misc/create_inode_libarchive.c b/misc/create_inode_libarchive.c
index 8705eb16..15749689 100644
--- a/misc/create_inode_libarchive.c
+++ b/misc/create_inode_libarchive.c
@@ -18,15 +18,25 @@
 #include "create_inode_libarchive.h"
 #include "support/nls-enable.h"
 
-#ifdef HAVE_ARCHIVE_H
+#ifndef CONFIG_DISABLE_LIBARCHIVE
 
 /* 64KiB is the minimum blksize to best minimize system call overhead. */
 //#define COPY_FILE_BUFLEN 65536
 //#define COPY_FILE_BUFLEN 1048576
 #define COPY_FILE_BUFLEN 16777216
 
+#ifdef HAVE_ARCHIVE_H
 #include <archive.h>
 #include <archive_entry.h>
+#else
+struct archive;
+struct archive_entry;
+#define	ARCHIVE_EOF	  1	/* Found end of archive. */
+#define	ARCHIVE_OK	  0	/* Operation was successful. */
+#include <unistd.h>  /* ssize_t */
+typedef ssize_t la_ssize_t;
+#endif
+
 #include <libgen.h>
 #include <locale.h>
 
-- 
2.39.2

Attachment: signature.asc
Description: signature

Reply via email to