summaryrefslogtreecommitdiff
path: root/archivers/libarchive/files/tar
diff options
context:
space:
mode:
Diffstat (limited to 'archivers/libarchive/files/tar')
-rw-r--r--archivers/libarchive/files/tar/bsdtar.159
-rw-r--r--archivers/libarchive/files/tar/bsdtar.c10
-rw-r--r--archivers/libarchive/files/tar/bsdtar.h3
-rw-r--r--archivers/libarchive/files/tar/cmdline.c1
-rw-r--r--archivers/libarchive/files/tar/creation_set.c4
-rw-r--r--archivers/libarchive/files/tar/test/CMakeLists.txt3
-rw-r--r--archivers/libarchive/files/tar/test/list.h3
-rw-r--r--archivers/libarchive/files/tar/test/test_extract.tar.zst.uu6
-rw-r--r--archivers/libarchive/files/tar/test/test_extract_tar_zstd.c48
-rw-r--r--archivers/libarchive/files/tar/test/test_option_C_mtree.c73
-rw-r--r--archivers/libarchive/files/tar/test/test_option_acls.c4
-rw-r--r--archivers/libarchive/files/tar/test/test_option_fflags.c4
-rw-r--r--archivers/libarchive/files/tar/test/test_option_zstd.c85
-rw-r--r--archivers/libarchive/files/tar/write.c2
14 files changed, 276 insertions, 29 deletions
diff --git a/archivers/libarchive/files/tar/bsdtar.1 b/archivers/libarchive/files/tar/bsdtar.1
index cdc317b6cf4..132e1145794 100644
--- a/archivers/libarchive/files/tar/bsdtar.1
+++ b/archivers/libarchive/files/tar/bsdtar.1
@@ -25,7 +25,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd February 25, 2017
+.Dd October 1, 2017
.Dt TAR 1
.Os
.Sh NAME
@@ -302,19 +302,18 @@ containing the string
Compress the resulting archive with
.Xr xz 1 .
In extract or list modes, this option is ignored.
-Note that, unlike other
+Note that this
.Nm tar
-implementations, this implementation recognizes XZ compression
-automatically when reading archives.
+implementation recognizes XZ compression automatically when reading archives.
.It Fl j , Fl Fl bzip , Fl Fl bzip2 , Fl Fl bunzip2
(c mode only)
Compress the resulting archive with
.Xr bzip2 1 .
In extract or list modes, this option is ignored.
-Note that, unlike other
+Note that this
.Nm tar
-implementations, this implementation recognizes bzip2 compression
-automatically when reading archives.
+implementation recognizes bzip2 compression automatically when reading
+archives.
.It Fl k , Fl Fl keep-old-files
(x mode only)
Do not overwrite existing files.
@@ -337,25 +336,41 @@ Issue a warning message unless all links to each file are archived.
Compress the resulting archive with
.Xr lrzip 1 .
In extract or list modes, this option is ignored.
+Note that this
+.Nm tar
+implementation recognizes lrzip compression automatically when reading
+archives.
.It Fl Fl lz4
(c mode only)
Compress the archive with lz4-compatible compression before writing it.
-In input mode, this option is ignored; lz4 compression is recognized
-automatically on input.
+In extract or list modes, this option is ignored.
+Note that this
+.Nm tar
+implementation recognizes lz4 compression automatically when reading archives.
+.It Fl Fl zstd
+(c mode only)
+Compress the archive with zstd-compatible compression before writing it.
+In extract or list modes, this option is ignored.
+Note that this
+.Nm tar
+implementation recognizes zstd compression automatically when reading archives.
.It Fl Fl lzma
(c mode only) Compress the resulting archive with the original LZMA algorithm.
+In extract or list modes, this option is ignored.
Use of this option is discouraged and new archives should be created with
.Fl Fl xz
instead.
-Note that, unlike other
+Note that this
.Nm tar
-implementations, this implementation recognizes LZMA compression
-automatically when reading archives.
+implementation recognizes LZMA compression automatically when reading archives.
.It Fl Fl lzop
(c mode only)
Compress the resulting archive with
.Xr lzop 1 .
In extract or list modes, this option is ignored.
+Note that this
+.Nm tar
+implementation recognizes LZO compression automatically when reading archives.
.It Fl m , Fl Fl modification-time
(x mode only)
Do not extract modification time.
@@ -577,6 +592,8 @@ A decimal integer from 4 to 7 specifying the lz4 compression block size
.It Cm lz4:block-dependence
Use the previous block of the block being compressed for
a compression dictionary to improve compression ratio.
+.It Cm zstd:compression-level
+A decimal integer from 1 to 22 specifying the zstd compression level.
.It Cm lzop:compression-level
A decimal integer from 1 to 9 specifying the lzop compression level.
.It Cm xz:compression-level
@@ -826,28 +843,28 @@ is run in x mode as root.
Compress the resulting archive with
.Xr bzip2 1 .
In extract or list modes, this option is ignored.
-Note that, unlike other
+Note that this
.Nm tar
-implementations, this implementation recognizes bzip2 compression
-automatically when reading archives.
+implementation recognizes bzip2 compression automatically when reading
+archives.
.It Fl Z , Fl Fl compress , Fl Fl uncompress
(c mode only)
Compress the resulting archive with
.Xr compress 1 .
In extract or list modes, this option is ignored.
-Note that, unlike other
+Note that this
.Nm tar
-implementations, this implementation recognizes compress compression
-automatically when reading archives.
+implementation recognizes compress compression automatically when reading
+archives.
.It Fl z , Fl Fl gunzip , Fl Fl gzip
(c mode only)
Compress the resulting archive with
.Xr gzip 1 .
In extract or list modes, this option is ignored.
-Note that, unlike other
+Note that this
.Nm tar
-implementations, this implementation recognizes gzip compression
-automatically when reading archives.
+implementation recognizes gzip compression automatically when reading
+archives.
.El
.Sh ENVIRONMENT
The following environment variables affect the execution of
diff --git a/archivers/libarchive/files/tar/bsdtar.c b/archivers/libarchive/files/tar/bsdtar.c
index 9fc68332e5d..963bd4f9ad5 100644
--- a/archivers/libarchive/files/tar/bsdtar.c
+++ b/archivers/libarchive/files/tar/bsdtar.c
@@ -419,6 +419,7 @@ main(int argc, char **argv)
case OPTION_LZIP: /* GNU tar beginning with 1.23 */
case OPTION_LZMA: /* GNU tar beginning with 1.20 */
case OPTION_LZOP: /* GNU tar beginning with 1.21 */
+ case OPTION_ZSTD:
if (compression != '\0')
lafe_errc(1, 0,
"Can't specify both -%c and -%c", opt,
@@ -427,9 +428,10 @@ main(int argc, char **argv)
switch (opt) {
case OPTION_LRZIP: compression_name = "lrzip"; break;
case OPTION_LZ4: compression_name = "lz4"; break;
- case OPTION_LZIP: compression_name = "lzip"; break;
- case OPTION_LZMA: compression_name = "lzma"; break;
- case OPTION_LZOP: compression_name = "lzop"; break;
+ case OPTION_LZIP: compression_name = "lzip"; break;
+ case OPTION_LZMA: compression_name = "lzma"; break;
+ case OPTION_LZOP: compression_name = "lzop"; break;
+ case OPTION_ZSTD: compression_name = "zstd"; break;
}
break;
case 'm': /* SUSv2 */
@@ -918,7 +920,7 @@ usage(void)
static void
version(void)
{
- printf("bsdtar %s - %s\n",
+ printf("bsdtar %s - %s \n",
BSDTAR_VERSION_STRING,
archive_version_details());
exit(0);
diff --git a/archivers/libarchive/files/tar/bsdtar.h b/archivers/libarchive/files/tar/bsdtar.h
index 10a2cf2f9bd..543a228c907 100644
--- a/archivers/libarchive/files/tar/bsdtar.h
+++ b/archivers/libarchive/files/tar/bsdtar.h
@@ -181,7 +181,8 @@ enum {
OPTION_USE_COMPRESS_PROGRAM,
OPTION_UUENCODE,
OPTION_VERSION,
- OPTION_XATTRS
+ OPTION_XATTRS,
+ OPTION_ZSTD,
};
int bsdtar_getopt(struct bsdtar *);
diff --git a/archivers/libarchive/files/tar/cmdline.c b/archivers/libarchive/files/tar/cmdline.c
index e36c545b333..66cf4c2d196 100644
--- a/archivers/libarchive/files/tar/cmdline.c
+++ b/archivers/libarchive/files/tar/cmdline.c
@@ -160,6 +160,7 @@ static const struct bsdtar_option {
{ "version", 0, OPTION_VERSION },
{ "xattrs", 0, OPTION_XATTRS },
{ "xz", 0, 'J' },
+ { "zstd", 0, OPTION_ZSTD },
{ NULL, 0, 0 }
};
diff --git a/archivers/libarchive/files/tar/creation_set.c b/archivers/libarchive/files/tar/creation_set.c
index 24cf3fcdd4e..bdc607daeb2 100644
--- a/archivers/libarchive/files/tar/creation_set.c
+++ b/archivers/libarchive/files/tar/creation_set.c
@@ -80,9 +80,10 @@ get_filter_code(const char *suffix)
{ ".lzma", "lzma" },
{ ".uu", "uuencode" },
{ ".xz", "xz" },
+ { ".zst", "zstd"},
{ NULL, NULL }
};
-
+
return get_suffix_code(filters, suffix);
}
@@ -121,6 +122,7 @@ decompose_alias(const char *suffix)
{ ".tzo", ".tar.lzo" },
{ ".taZ", ".tar.Z" },
{ ".tZ", ".tar.Z" },
+ { ".tzst", ".tar.zst" },
{ NULL, NULL }
};
diff --git a/archivers/libarchive/files/tar/test/CMakeLists.txt b/archivers/libarchive/files/tar/test/CMakeLists.txt
index abd43b0f4b2..d7de42d6ab6 100644
--- a/archivers/libarchive/files/tar/test/CMakeLists.txt
+++ b/archivers/libarchive/files/tar/test/CMakeLists.txt
@@ -22,11 +22,13 @@ IF(ENABLE_TAR AND ENABLE_TEST)
test_extract_tar_lzma.c
test_extract_tar_lzo.c
test_extract_tar_xz.c
+ test_extract_tar_zstd.c
test_format_newc.c
test_help.c
test_leading_slash.c
test_missing_file.c
test_option_C_upper.c
+ test_option_C_mtree.c
test_option_H_upper.c
test_option_L_upper.c
test_option_O_upper.c
@@ -61,6 +63,7 @@ IF(ENABLE_TAR AND ENABLE_TEST)
test_option_xattrs.c
test_option_xz.c
test_option_z.c
+ test_option_zstd.c
test_patterns.c
test_print_longpath.c
test_stdio.c
diff --git a/archivers/libarchive/files/tar/test/list.h b/archivers/libarchive/files/tar/test/list.h
index 2b28490e779..b5397fae8ec 100644
--- a/archivers/libarchive/files/tar/test/list.h
+++ b/archivers/libarchive/files/tar/test/list.h
@@ -12,6 +12,7 @@ DEFINE_TEST(test_extract_tar_lzma)
DEFINE_TEST(test_extract_tar_lzo)
DEFINE_TEST(test_extract_tar_xz)
DEFINE_TEST(test_extract_tar_Z)
+DEFINE_TEST(test_extract_tar_zstd)
DEFINE_TEST(test_format_newc)
DEFINE_TEST(test_help)
DEFINE_TEST(test_leading_slash)
@@ -20,6 +21,7 @@ DEFINE_TEST(test_option_a)
DEFINE_TEST(test_option_acls)
DEFINE_TEST(test_option_b64encode)
DEFINE_TEST(test_option_b)
+DEFINE_TEST(test_option_C_mtree)
DEFINE_TEST(test_option_C_upper)
DEFINE_TEST(test_option_exclude)
DEFINE_TEST(test_option_fflags)
@@ -51,6 +53,7 @@ DEFINE_TEST(test_option_xattrs)
DEFINE_TEST(test_option_X_upper)
DEFINE_TEST(test_option_xz)
DEFINE_TEST(test_option_z)
+DEFINE_TEST(test_option_zstd)
DEFINE_TEST(test_patterns)
DEFINE_TEST(test_print_longpath)
DEFINE_TEST(test_stdio)
diff --git a/archivers/libarchive/files/tar/test/test_extract.tar.zst.uu b/archivers/libarchive/files/tar/test/test_extract.tar.zst.uu
new file mode 100644
index 00000000000..3df0caf5475
--- /dev/null
+++ b/archivers/libarchive/files/tar/test/test_extract.tar.zst.uu
@@ -0,0 +1,6 @@
+begin 644 test_extract.tar.zst
+M*+4O_010S0,`<L40$Z`5.(2U_RNV_[]L4V;Z_/R@1:7Y$3;9E`8$D$WI:W1)
+M'58'D3->Y+>!0*5E/PM"$7^K^1VI3SS-AX&_W0KQWY!-Z1(`_4$%[$"]<T!A
+L(*`#I!DXC4[J!6J8$!DJ$D"9$T*L]#G-$$/A`#`I`-(`UUKAU$Z@"`UXII``
+`
+end
diff --git a/archivers/libarchive/files/tar/test/test_extract_tar_zstd.c b/archivers/libarchive/files/tar/test/test_extract_tar_zstd.c
new file mode 100644
index 00000000000..d67170ce343
--- /dev/null
+++ b/archivers/libarchive/files/tar/test/test_extract_tar_zstd.c
@@ -0,0 +1,48 @@
+/*-
+ * Copyright (c) 2017 Sean Purcell
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD$");
+
+DEFINE_TEST(test_extract_tar_zstd)
+{
+ const char *reffile = "test_extract.tar.zst";
+ int f;
+
+ extract_reference_file(reffile);
+ f = systemf("%s -tf %s >test.out 2>test.err", testprog, reffile);
+ if (f == 0 || canZstd()) {
+ assertEqualInt(0, systemf("%s -xf %s >test.out 2>test.err",
+ testprog, reffile));
+
+ assertFileExists("file1");
+ assertTextFileContents("contents of file1.\n", "file1");
+ assertFileExists("file2");
+ assertTextFileContents("contents of file2.\n", "file2");
+ assertEmptyFile("test.out");
+ assertEmptyFile("test.err");
+ } else {
+ skipping("It seems zstd is not supported on this platform");
+ }
+}
diff --git a/archivers/libarchive/files/tar/test/test_option_C_mtree.c b/archivers/libarchive/files/tar/test/test_option_C_mtree.c
new file mode 100644
index 00000000000..caf8044bf93
--- /dev/null
+++ b/archivers/libarchive/files/tar/test/test_option_C_mtree.c
@@ -0,0 +1,73 @@
+/*-
+ * Copyright (c) 2018 The FreeBSD Foundation
+ * All rights reserved.
+ *
+ * This software was developed by Arshan Khanifar <arshankhanifar@gmail.com>
+ * under sponsorship from the FreeBSD Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD$");
+
+DEFINE_TEST(test_option_C_mtree)
+{
+ char *p0;
+ size_t s;
+ int r;
+ p0 = NULL;
+ char *content = "./foo type=file uname=root gname=root mode=0755\n";
+ char *filename = "output.tar";
+
+ /* an absolute path to mtree file */
+ char *mtree_file = "/METALOG.mtree";
+ char *absolute_path = malloc(strlen(testworkdir) + strlen(mtree_file) + 1);
+ strcpy(absolute_path, testworkdir);
+ strcat(absolute_path, mtree_file );
+
+ /* Create an archive using an mtree file. */
+ assertMakeFile(absolute_path, 0777, content);
+ assertMakeDir("bar", 0775);
+ assertMakeFile("bar/foo", 0777, "abc");
+
+ r = systemf("%s -cf %s -C bar \"@%s\" >step1.out 2>step1.err", testprog, filename, absolute_path);
+
+ failure("Error invoking %s -cf %s -C bar @%s", testprog, filename, absolute_path);
+ assertEqualInt(r, 0);
+ assertEmptyFile("step1.out");
+ assertEmptyFile("step1.err");
+
+ /* Do validation of the constructed archive. */
+
+ p0 = slurpfile(&s, "output.tar");
+ if (!assert(p0 != NULL))
+ goto done;
+ if (!assert(s >= 2048))
+ goto done;
+ assertEqualMem(p0 + 0, "./foo", 5);
+ assertEqualMem(p0 + 512, "abc", 3);
+ assertEqualMem(p0 + 1024, "\0\0\0\0\0\0\0\0", 8);
+ assertEqualMem(p0 + 1536, "\0\0\0\0\0\0\0\0", 8);
+done:
+ free(p0);
+}
+
+
diff --git a/archivers/libarchive/files/tar/test/test_option_acls.c b/archivers/libarchive/files/tar/test/test_option_acls.c
index f2d51d661ab..f7451c8eb36 100644
--- a/archivers/libarchive/files/tar/test/test_option_acls.c
+++ b/archivers/libarchive/files/tar/test/test_option_acls.c
@@ -85,7 +85,9 @@ static const acl_flag_t acl_flags[] = {
ACL_ENTRY_INHERIT_ONLY,
ACL_ENTRY_SUCCESSFUL_ACCESS,
ACL_ENTRY_FAILED_ACCESS,
+#ifdef ACL_ENTRY_INHERITED
ACL_ENTRY_INHERITED
+#endif
#endif /* ARCHIVE_ACL_FREEBSD_NFS4 */
};
#endif /* ARCHIVE_ACL_DARWIN || ARCHIVE_ACL_FREEBSD_NFS4 */
@@ -483,7 +485,7 @@ DEFINE_TEST(test_option_acls)
r = compare_acls("f", "acls_acls/f");
assertEqualInt(r, 1);
- /* Extractl acls without acls */
+ /* Extract acls without acls */
assertMakeDir("acls_noacls", 0755);
clear_inheritance_flags("acls_noacls", acltype);
r = systemf("%s -x -C acls_noacls -p --no-acls -f acls.tar >acls_noacls.out 2>acls_noacls.err", testprog);
diff --git a/archivers/libarchive/files/tar/test/test_option_fflags.c b/archivers/libarchive/files/tar/test/test_option_fflags.c
index 77a4e3e19f0..f223feb1906 100644
--- a/archivers/libarchive/files/tar/test/test_option_fflags.c
+++ b/archivers/libarchive/files/tar/test/test_option_fflags.c
@@ -25,6 +25,10 @@
#include "test.h"
__FBSDID("$FreeBSD$");
+#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__BORLANDC__)
+#define chmod _chmod
+#endif
+
static void
clear_fflags(const char *pathname)
{
diff --git a/archivers/libarchive/files/tar/test/test_option_zstd.c b/archivers/libarchive/files/tar/test/test_option_zstd.c
new file mode 100644
index 00000000000..73965e33f3a
--- /dev/null
+++ b/archivers/libarchive/files/tar/test/test_option_zstd.c
@@ -0,0 +1,85 @@
+/*-
+ * Copyright (c) 2017 Sean Purcell
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "test.h"
+__FBSDID("$FreeBSD$");
+
+DEFINE_TEST(test_option_zstd)
+{
+ char *p;
+ int r;
+ size_t s;
+
+ /* Create a file. */
+ assertMakeFile("f", 0644, "a");
+
+ /* Archive it with lz4 compression. */
+ r = systemf("%s -cf - --zstd f >archive.out 2>archive.err",
+ testprog);
+ p = slurpfile(&s, "archive.err");
+ p[s] = '\0';
+ if (r != 0) {
+ if (strstr(p, "Unsupported compression") != NULL) {
+ skipping("This version of bsdtar was compiled "
+ "without zstd support");
+ goto done;
+ }
+ /* POSIX permits different handling of the spawnp
+ * system call used to launch the subsidiary
+ * program: */
+ /* Some systems fail immediately to spawn the new process. */
+ if (strstr(p, "Can't launch") != NULL && !canZstd()) {
+ skipping("This version of bsdtar uses an external zstd program "
+ "but no such program is available on this system.");
+ goto done;
+ }
+ /* Some systems successfully spawn the new process,
+ * but fail to exec a program within that process.
+ * This results in failure at the first attempt to
+ * write. */
+ if (strstr(p, "Can't write") != NULL && !canZstd()) {
+ skipping("This version of bsdtar uses an external zstd program "
+ "but no such program is available on this system.");
+ goto done;
+ }
+ /* On some systems the error won't be detected until closing
+ time, by a 127 exit error returned by waitpid. */
+ if (strstr(p, "Error closing") != NULL && !canZstd()) {
+ skipping("This version of bsdcpio uses an external zstd program "
+ "but no such program is available on this system.");
+ return;
+ }
+ failure("--zstd option is broken: %s", p);
+ assertEqualInt(r, 0);
+ goto done;
+ }
+ free(p);
+ /* Check that the archive file has an lz4 signature. */
+ p = slurpfile(&s, "archive.out");
+ assert(s > 2);
+ assertEqualMem(p, "\x28\xb5\x2f\xfd", 4);
+
+done:
+ free(p);
+}
diff --git a/archivers/libarchive/files/tar/write.c b/archivers/libarchive/files/tar/write.c
index 9c245662527..e15cc06ccfc 100644
--- a/archivers/libarchive/files/tar/write.c
+++ b/archivers/libarchive/files/tar/write.c
@@ -503,7 +503,7 @@ write_archive(struct archive *a, struct bsdtar *bsdtar)
}
set_chdir(bsdtar, arg);
} else {
- if (*arg != '/' && (arg[0] != '@' || arg[1] != '/'))
+ if (*arg != '/')
do_chdir(bsdtar); /* Handle a deferred -C */
if (*arg == '@') {
if (append_archive_filename(bsdtar, a,