From 68c2de35a06094f47d2b9737a0d78362d9cb5e45 Mon Sep 17 00:00:00 2001 From: Colin Clark Date: Fri, 17 Sep 2021 16:37:10 +0100 Subject: [PATCH] Fix libarchive problems libarchive 3.4.0 is required for Ubuntu 20.04 LTS. Include ifdefs for when the library is not included. --- configure.ac | 2 +- src/layout_util.c | 13 ++++++++++--- src/misc.c | 18 +++++++++++++----- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/configure.ac b/configure.ac index c4c1bcd6..41b1f9b0 100644 --- a/configure.ac +++ b/configure.ac @@ -668,7 +668,7 @@ AC_ARG_ENABLE([archive], [libarchive=$enableval], [libarchive=auto]) if test "x${libarchive}" != "xno"; then - PKG_CHECK_MODULES(ARCHIVE, libarchive >= 3.4.3, + PKG_CHECK_MODULES(ARCHIVE, libarchive >= 3.4.0, [ HAVE_ARCHIVE=yes AC_DEFINE(HAVE_ARCHIVE, 1, [define to enable archive support]) diff --git a/src/layout_util.c b/src/layout_util.c index 9ed0e3be..d23c8ecc 100644 --- a/src/layout_util.c +++ b/src/layout_util.c @@ -903,9 +903,16 @@ static void layout_menu_open_archive_cb(GtkAction *action, gpointer data) if (fd->format_class == FORMAT_CLASS_ARCHIVE) { dest_dir = open_archive(layout_image_get_fd(lw)); - lw_new = layout_new_from_default(); - layout_set_path(lw_new, dest_dir); - g_free(dest_dir); + if (dest_dir) + { + lw_new = layout_new_from_default(); + layout_set_path(lw_new, dest_dir); + g_free(dest_dir); + } + else + { + warning_dialog(_("Cannot open archive file"), _("See the Log Window"), GTK_STOCK_DIALOG_WARNING, NULL); + } } } diff --git a/src/misc.c b/src/misc.c index 50a0a6b6..418f26b1 100644 --- a/src/misc.c +++ b/src/misc.c @@ -22,8 +22,6 @@ #include "misc.h" #include "ui_fileops.h" -#include -#include #include #include @@ -412,6 +410,17 @@ void tree_path_free_wrapper(void *data, void *useradata) /* Copied from the libarchive .repo. examples */ +#ifndef HAVE_ARCHIVE +gchar *open_archive(FileData *fd) +{ + return NULL; +} + +#else + +#include +#include + static void errmsg(const char *); static gboolean extract(const char *filename, int do_extract, int flags); static int copy_data(struct archive *, struct archive *); @@ -526,8 +535,7 @@ static gboolean extract(const char *filename, int do_extract, int flags) return(TRUE); } -static int -copy_data(struct archive *ar, struct archive *aw) +static int copy_data(struct archive *ar, struct archive *aw) { int r; const void *buff; @@ -566,5 +574,5 @@ static void errmsg(const char *m) } log_printf("%s \n", m); } - +#endif /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ -- 2.20.1