[PATCH] clitar: cope with functions of older versions of libarchive

Björn Jacke bj at sernet.de
Wed Dec 2 14:24:46 UTC 2015


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 at sernet.de>
---
 source3/client/clitar.c | 10 ++++++++++
 source3/wscript         |  8 ++++----
 source3/wscript_build   |  3 ++-
 3 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/source3/client/clitar.c b/source3/client/clitar.c
index b4f914f..8703f6b 100644
--- a/source3/client/clitar.c
+++ b/source3/client/clitar.c
@@ -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)));
diff --git a/source3/wscript b/source3/wscript
index 990afcd..8741d19 100644
--- a/source3/wscript
+++ b/source3/wscript
@@ -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:
diff --git a/source3/wscript_build b/source3/wscript_build
index 236a452..e66e89f 100755
--- a/source3/wscript_build
+++ b/source3/wscript_build
@@ -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
-- 
2.6.0




More information about the samba-technical mailing list