clitar: cope with functions of older versions of libarchive
authorBjörn Jacke <bj@sernet.de>
Thu, 28 May 2015 12:55:28 +0000 (14:55 +0200)
committerBjoern Jacke <bj@sernet.de>
Thu, 3 Dec 2015 15:09:08 +0000 (16:09 +0100)
the feature of automatic decompression in extract mode is only supported in
libarchive 3, so we use this only when available now.

The changed config checks for that also fix this bug:

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11296

Signed-off-by: Bjoern Jacke <bj@sernet.de>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Björn Jacke <bj@sernet.de>
Autobuild-Date(master): Thu Dec  3 16:09:08 CET 2015 on sn-devel-104

source3/client/clitar.c
source3/wscript
source3/wscript_build

index b4f914f5c8cd70719b1effbc0c73007f63e1aa1f..8703f6b9a746585d6af7458825343bad42c306e0 100644 (file)
@@ -720,7 +720,11 @@ out_close:
                }
        }
 out:
+#ifdef HAVE_ARCHIVE_READ_FREE
        archive_write_free(t->archive);
+#else
+       archive_write_finish(t->archive);
+#endif
        talloc_free(ctx);
        return err;
 }
@@ -1002,7 +1006,9 @@ static int tar_extract(struct tar *t)
 
        t->archive = archive_read_new();
        archive_read_support_format_all(t->archive);
+#ifdef HAVE_ARCHIVE_READ_SUPPORT_FILTER_ALL
        archive_read_support_filter_all(t->archive);
+#endif
 
        if (strequal(t->tar_path, "-")) {
                r = archive_read_open_fd(t->archive, STDIN_FILENO, bsize);
@@ -1053,7 +1059,11 @@ static int tar_extract(struct tar *t)
        }
 
 out:
+#ifdef HAVE_ARCHIVE_READ_FREE
        r = archive_read_free(t->archive);
+#else
+       r = archive_read_finish(t->archive);
+#endif
        if (r != ARCHIVE_OK) {
                DBG(0, ("Can't close %s : %s\n", t->tar_path,
                                        archive_error_string(t->archive)));
index 990afcdfa01af9b259ae6bf93be8396f0fea992f..8741d192ea915406467d4b6faf3350dfac63997b 100644 (file)
@@ -212,14 +212,14 @@ main() {
 
     # check for libarchive (tar command in smbclient)
     # None means autodetect, True/False means enable/disable
-    conf.env['archive_lib'] = ''
+    conf.SET_TARGET_TYPE('archive', 'EMPTY')
     if Options.options.with_libarchive is not False:
         libarchive_mandatory = Options.options.with_libarchive == True
         Logs.info("Checking for libarchive existence")
-        if conf.CHECK_BUNDLED_SYSTEM('libarchive', minversion='3.1.2'):
-            conf.env['archive_lib'] = 'libarchive'
+        if conf.CHECK_HEADERS('archive.h') and conf.CHECK_LIB('archive', shlib=True):
+            conf.CHECK_FUNCS_IN('archive_read_support_filter_all archive_read_free', 'archive')
         elif libarchive_mandatory:
-            conf.fatal('libarchive support requested, but no suitable pkgconfig found')
+            conf.fatal('libarchive support requested, but not found')
 
     # check for DMAPI libs
     if Options.options.with_dmapi == False:
index 236a4527e26373de1ff730f0e2359e6b4624b9a4..e66e89fa79837755e4c52f6b288cb794b462e24c 100755 (executable)
@@ -1071,7 +1071,8 @@ bld.SAMBA3_BINARY('client/smbclient',
                  msrpc3
                  RPC_NDR_SRVSVC
                  cli_smb_common
-                 ''' + bld.env['archive_lib'])
+                archive
+                 ''')
 
 bld.SAMBA3_BINARY('net',
                  source='''utils/net.c