From: Johannes Schauer Marin Rodrigues Date: Tue, 3 Sep 2024 11:15:33 +0000 (+0200) Subject: Decouple --without-libarchive and HAVE_ARCHIVE_H X-Git-Tag: v1.47.2-wc1~136 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=ecfd4dd1217a;p=tools%2Fe2fsprogs.git 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 (as opaque structs) 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. Addresses-Debian-Bug: #1078693 Signed-off-by: Theodore Ts'o --- diff --git a/configure b/configure index e299be0..f9a7aa4 100755 --- a/configure +++ b/configure @@ -13750,6 +13750,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 9a3dff1..1f67604 100644 --- a/configure.ac +++ b/configure.ac @@ -1312,6 +1312,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/debian/control b/debian/control index bc582cd..2d1cfd8 100644 --- a/debian/control +++ b/debian/control @@ -2,7 +2,7 @@ Source: e2fsprogs Section: admin Priority: required Maintainer: Theodore Y. Ts'o -Build-Depends: dpkg-dev (>= 1.22.5), gettext, texinfo, pkgconf, libarchive-dev, libfuse3-dev [linux-any kfreebsd-any] , debhelper-compat (= 12), dh-exec, libblkid-dev, uuid-dev, m4, udev [linux-any], systemd [linux-any], systemd-dev [linux-any], cron [linux-any], dh-sequence-movetousr +Build-Depends: dpkg-dev (>= 1.22.5), gettext, texinfo, pkgconf, libarchive-dev , libfuse3-dev [linux-any kfreebsd-any] , debhelper-compat (= 12), dh-exec, libblkid-dev, uuid-dev, m4, udev [linux-any], systemd [linux-any], systemd-dev [linux-any], cron [linux-any], dh-sequence-movetousr Rules-Requires-Root: no Standards-Version: 4.7.0 Homepage: http://e2fsprogs.sourceforge.net diff --git a/lib/config.h.in b/lib/config.h.in index 04cec72..819c433 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 ff697f4..d14efe8 100644 --- a/misc/create_inode_libarchive.c +++ b/misc/create_inode_libarchive.c @@ -13,20 +13,50 @@ #define _GNU_SOURCE 1 #include "config.h" -#include #include "create_inode.h" #include "create_inode_libarchive.h" #include "support/nls-enable.h" -#ifdef HAVE_ARCHIVE_H +#ifdef CONFIG_DISABLE_LIBARCHIVE + +/* If ./configure was run with --without-libarchive, then only + * __populate_fs_from_tar() remains in this file and will return an error. */ +errcode_t __populate_fs_from_tar(ext2_filsys, ext2_ino_t, const char *, + ext2_ino_t, struct hdlinks_s *, + struct file_info *, + struct fs_ops_callbacks *) { + com_err(__func__, 0, + _("you need to compile e2fsprogs without --without-libarchive" + "be able to process tarballs")); + return 1; +} + +#else + +/* If ./configure was NOT run with --without-libarchive, then build with + * support for dlopen()-ing libarchive at runtime. This will also work even + * if archive.h is not available at compile-time. See the comment below. */ /* 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 +/* If archive.h was found, include it as usual. To support easier + * bootstrapping, also allow compilation without archive.h present by + * declaring the necessary opaque structs and preprocessor definitions. */ +#ifdef HAVE_ARCHIVE_H #include #include +#else +struct archive; +struct archive_entry; +#define ARCHIVE_EOF 1 /* Found end of archive. */ +#define ARCHIVE_OK 0 /* Operation was successful. */ +#include /* ssize_t */ +typedef ssize_t la_ssize_t; +#endif /* HAVE_ARCHIVE_H */ + #include #include @@ -175,7 +205,7 @@ static int libarchive_available(void) return 1; } -#endif +#endif /* CONFIG_DLOPEN_LIBARCHIVE */ static errcode_t __find_path(ext2_filsys fs, ext2_ino_t root, const char *name, ext2_ino_t *inode) @@ -541,7 +571,6 @@ static errcode_t handle_entry(ext2_filsys fs, ext2_ino_t root_ino, } return 0; } -#endif errcode_t __populate_fs_from_tar(ext2_filsys fs, ext2_ino_t root_ino, const char *source_tar, ext2_ino_t root, @@ -549,12 +578,6 @@ errcode_t __populate_fs_from_tar(ext2_filsys fs, ext2_ino_t root_ino, struct file_info *target, struct fs_ops_callbacks *fs_callbacks) { -#ifndef HAVE_ARCHIVE_H - com_err(__func__, 0, - _("you need to compile e2fsprogs with libarchive to " - "be able to process tarballs")); - return 1; -#else char *path2, *path3, *dir, *name; unsigned int dir_exists; struct archive *a; @@ -700,5 +723,6 @@ out: uselocale(old_locale); freelocale(archive_locale); return retval; -#endif } + +#endif /* CONFIG_DISABLE_LIBARCHIVE */