diff options
author | joerg <joerg@pkgsrc.org> | 2019-09-22 09:47:00 +0000 |
---|---|---|
committer | joerg <joerg@pkgsrc.org> | 2019-09-22 09:47:00 +0000 |
commit | 3d58b3c8e51f686500fbe08fc5fea947dfa036b4 (patch) | |
tree | 54a4af7c883e75c1a11634a0a7f52e5bdc174484 /archivers/libarchive/files/cpio | |
parent | 8ebf4e7079542370a0dd5eba7eed1790d20c7f96 (diff) | |
download | pkgsrc-3d58b3c8e51f686500fbe08fc5fea947dfa036b4.tar.gz |
Import libarchive-3.3.3 as should have done originally.
Diffstat (limited to 'archivers/libarchive/files/cpio')
-rw-r--r-- | archivers/libarchive/files/cpio/bsdcpio.1 | 5 | ||||
-rw-r--r-- | archivers/libarchive/files/cpio/cmdline.c | 1 | ||||
-rw-r--r-- | archivers/libarchive/files/cpio/cpio.c | 6 | ||||
-rw-r--r-- | archivers/libarchive/files/cpio/cpio.h | 3 | ||||
-rw-r--r-- | archivers/libarchive/files/cpio/test/CMakeLists.txt | 2 | ||||
-rw-r--r-- | archivers/libarchive/files/cpio/test/list.h | 2 | ||||
-rw-r--r-- | archivers/libarchive/files/cpio/test/test_basic.c | 60 | ||||
-rw-r--r-- | archivers/libarchive/files/cpio/test/test_extract.cpio.zst.uu | 6 | ||||
-rw-r--r-- | archivers/libarchive/files/cpio/test/test_extract_cpio_zstd.c | 48 | ||||
-rw-r--r-- | archivers/libarchive/files/cpio/test/test_format_newc.c | 40 | ||||
-rw-r--r-- | archivers/libarchive/files/cpio/test/test_option_zstd.c | 85 |
11 files changed, 229 insertions, 29 deletions
diff --git a/archivers/libarchive/files/cpio/bsdcpio.1 b/archivers/libarchive/files/cpio/bsdcpio.1 index e52546e6f76..786a717097e 100644 --- a/archivers/libarchive/files/cpio/bsdcpio.1 +++ b/archivers/libarchive/files/cpio/bsdcpio.1 @@ -187,6 +187,11 @@ In input mode, this option is ignored. Compress the archive with lz4-compatible compression before writing it. In input mode, this option is ignored; lz4 compression is recognized automatically on input. +.It Fl Fl zstd +(o mode only) +Compress the archive with zstd-compatible compression before writing it. +In input mode, this option is ignored; zstd compression is recognized +automatically on input. .It Fl Fl lzma (o mode only) Compress the file with lzma-compatible compression before writing it. diff --git a/archivers/libarchive/files/cpio/cmdline.c b/archivers/libarchive/files/cpio/cmdline.c index 0c10b2cdcf8..c8fc30ea773 100644 --- a/archivers/libarchive/files/cpio/cmdline.c +++ b/archivers/libarchive/files/cpio/cmdline.c @@ -92,6 +92,7 @@ static const struct option { { "verbose", 0, 'v' }, { "version", 0, OPTION_VERSION }, { "xz", 0, 'J' }, + { "zstd", 0, OPTION_ZSTD }, { NULL, 0, 0 } }; diff --git a/archivers/libarchive/files/cpio/cpio.c b/archivers/libarchive/files/cpio/cpio.c index 5beedd0d16b..4b8ce79296f 100644 --- a/archivers/libarchive/files/cpio/cpio.c +++ b/archivers/libarchive/files/cpio/cpio.c @@ -269,6 +269,7 @@ main(int argc, char *argv[]) case OPTION_LZ4: case OPTION_LZMA: /* GNU tar, others */ case OPTION_LZOP: /* GNU tar, others */ + case OPTION_ZSTD: cpio->compress = opt; break; case 'm': /* POSIX 1997 */ @@ -498,7 +499,7 @@ long_help(void) static void version(void) { - fprintf(stdout,"bsdcpio %s - %s\n", + fprintf(stdout,"bsdcpio %s - %s \n", BSDCPIO_VERSION_STRING, archive_version_details()); exit(0); @@ -546,6 +547,9 @@ mode_out(struct cpio *cpio) case OPTION_LZOP: r = archive_write_add_filter_lzop(cpio->archive); break; + case OPTION_ZSTD: + r = archive_write_add_filter_zstd(cpio->archive); + break; case 'j': case 'y': r = archive_write_add_filter_bzip2(cpio->archive); break; diff --git a/archivers/libarchive/files/cpio/cpio.h b/archivers/libarchive/files/cpio/cpio.h index 1036dece93b..abf3628bfae 100644 --- a/archivers/libarchive/files/cpio/cpio.h +++ b/archivers/libarchive/files/cpio/cpio.h @@ -111,7 +111,8 @@ enum { OPTION_PRESERVE_OWNER, OPTION_QUIET, OPTION_UUENCODE, - OPTION_VERSION + OPTION_VERSION, + OPTION_ZSTD, }; int cpio_getopt(struct cpio *cpio); diff --git a/archivers/libarchive/files/cpio/test/CMakeLists.txt b/archivers/libarchive/files/cpio/test/CMakeLists.txt index 4c3fb88a61f..d0927a81e8a 100644 --- a/archivers/libarchive/files/cpio/test/CMakeLists.txt +++ b/archivers/libarchive/files/cpio/test/CMakeLists.txt @@ -23,6 +23,7 @@ IF(ENABLE_CPIO AND ENABLE_TEST) test_extract_cpio_lzma test_extract_cpio_lzo test_extract_cpio_xz + test_extract_cpio_zstd test_format_newc.c test_gcpio_compat.c test_missing_file.c @@ -53,6 +54,7 @@ IF(ENABLE_CPIO AND ENABLE_TEST) test_option_xz.c test_option_y.c test_option_z.c + test_option_zstd.c test_owner_parse.c test_passthrough_dotdot.c test_passthrough_reverse.c diff --git a/archivers/libarchive/files/cpio/test/list.h b/archivers/libarchive/files/cpio/test/list.h index 9968c4d9d97..92f9ec82ed1 100644 --- a/archivers/libarchive/files/cpio/test/list.h +++ b/archivers/libarchive/files/cpio/test/list.h @@ -11,6 +11,7 @@ DEFINE_TEST(test_extract_cpio_lzma) DEFINE_TEST(test_extract_cpio_lzo) DEFINE_TEST(test_extract_cpio_xz) DEFINE_TEST(test_extract_cpio_Z) +DEFINE_TEST(test_extract_cpio_zstd) DEFINE_TEST(test_format_newc) DEFINE_TEST(test_gcpio_compat) DEFINE_TEST(test_missing_file) @@ -40,6 +41,7 @@ DEFINE_TEST(test_option_version) DEFINE_TEST(test_option_xz) DEFINE_TEST(test_option_y) DEFINE_TEST(test_option_z) +DEFINE_TEST(test_option_zstd) DEFINE_TEST(test_option_Z_upper) DEFINE_TEST(test_owner_parse) DEFINE_TEST(test_passthrough_dotdot) diff --git a/archivers/libarchive/files/cpio/test/test_basic.c b/archivers/libarchive/files/cpio/test/test_basic.c index f3a048002a5..6e45d185698 100644 --- a/archivers/libarchive/files/cpio/test/test_basic.c +++ b/archivers/libarchive/files/cpio/test/test_basic.c @@ -144,49 +144,79 @@ DEFINE_TEST(test_basic) /* File with 10 bytes content. */ assertMakeFile("file", 0644, "1234567890"); fprintf(filelist, "file\n"); - if (is_LargeInode("file")) + if (is_LargeInode("file")) { strncat(result, - "bsdcpio: file: large inode number truncated: " - "Numerical result out of range\n", + "bsdcpio: file: large inode number truncated: ", sizeof(result) - strlen(result) -1); + strncat(result, + strerror(ERANGE), + sizeof(result) - strlen(result) -1); + strncat(result, + "\n", + sizeof(result) - strlen(result) -1); + } /* hardlink to above file. */ assertMakeHardlink("linkfile", "file"); fprintf(filelist, "linkfile\n"); - if (is_LargeInode("linkfile")) + if (is_LargeInode("linkfile")) { + strncat(result, + "bsdcpio: linkfile: large inode number truncated: ", + sizeof(result) - strlen(result) -1); + strncat(result, + strerror(ERANGE), + sizeof(result) - strlen(result) -1); strncat(result, - "bsdcpio: linkfile: large inode number truncated: " - "Numerical result out of range\n", + "\n", sizeof(result) - strlen(result) -1); + } /* Symlink to above file. */ if (canSymlink()) { assertMakeSymlink("symlink", "file"); fprintf(filelist, "symlink\n"); - if (is_LargeInode("symlink")) + if (is_LargeInode("symlink")) { + strncat(result, + "bsdcpio: symlink: large inode number truncated: ", + sizeof(result) - strlen(result) -1); strncat(result, - "bsdcpio: symlink: large inode number truncated: " - "Numerical result out of range\n", + strerror(ERANGE), sizeof(result) - strlen(result) -1); + strncat(result, + "\n", + sizeof(result) - strlen(result) -1); + } } /* Another file with different permissions. */ assertMakeFile("file2", 0777, "1234567890"); fprintf(filelist, "file2\n"); - if (is_LargeInode("file2")) + if (is_LargeInode("file2")) { + strncat(result, + "bsdcpio: file2: large inode number truncated: ", + sizeof(result) - strlen(result) -1); + strncat(result, + strerror(ERANGE), + sizeof(result) - strlen(result) -1); strncat(result, - "bsdcpio: file2: large inode number truncated: " - "Numerical result out of range\n", + "\n", sizeof(result) - strlen(result) -1); + } /* Directory. */ assertMakeDir("dir", 0775); fprintf(filelist, "dir\n"); - if (is_LargeInode("dir")) + if (is_LargeInode("dir")) { + strncat(result, + "bsdcpio: dir: large inode number truncated: ", + sizeof(result) - strlen(result) -1); strncat(result, - "bsdcpio: dir: large inode number truncated: " - "Numerical result out of range\n", + strerror(ERANGE), sizeof(result) - strlen(result) -1); + strncat(result, + "\n", + sizeof(result) - strlen(result) -1); + } strncat(result, "2 blocks\n", sizeof(result) - strlen(result) -1); /* All done. */ diff --git a/archivers/libarchive/files/cpio/test/test_extract.cpio.zst.uu b/archivers/libarchive/files/cpio/test/test_extract.cpio.zst.uu new file mode 100644 index 00000000000..5ec854b85d2 --- /dev/null +++ b/archivers/libarchive/files/cpio/test/test_extract.cpio.zst.uu @@ -0,0 +1,6 @@ +begin 644 test_extract.cpio.zst +M*+4O_01090,`,@41%X")&@#'G6T\K16_MR)#=DK)5:.1,2J0HY2"!(1!`!7R +M$(UB`2"*D41;J2UF&)<0!Y7X'TU<%W.\W^R]GO-WW^OO^QX0`%P<]30-!#U` +?!KD!`#XP,_`U4`HT3+RF:#!7Y\V@R)5"7P"^;WEUK@`` +` +end diff --git a/archivers/libarchive/files/cpio/test/test_extract_cpio_zstd.c b/archivers/libarchive/files/cpio/test/test_extract_cpio_zstd.c new file mode 100644 index 00000000000..289f33d0583 --- /dev/null +++ b/archivers/libarchive/files/cpio/test/test_extract_cpio_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_cpio_zstd) +{ + const char *reffile = "test_extract.cpio.zst"; + int f; + + extract_reference_file(reffile); + f = systemf("%s -it < %s >test.out 2>test.err", testprog, reffile); + if (f == 0 || canZstd()) { + assertEqualInt(0, systemf("%s -i < %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"); + assertTextFileContents("1 block\n", "test.err"); + } else { + skipping("It seems zstd is not supported on this platform"); + } +} diff --git a/archivers/libarchive/files/cpio/test/test_format_newc.c b/archivers/libarchive/files/cpio/test/test_format_newc.c index d2daa46ab71..258640443fe 100644 --- a/archivers/libarchive/files/cpio/test/test_format_newc.c +++ b/archivers/libarchive/files/cpio/test/test_format_newc.c @@ -124,26 +124,42 @@ DEFINE_TEST(test_format_newc) /* Setup result message. */ memset(result, 0, sizeof(result)); - if (is_LargeInode("file1")) + if (is_LargeInode("file1")) { strncat(result, - "bsdcpio: file1: large inode number truncated: " - "Numerical result out of range\n", + "bsdcpio: file1: large inode number truncated: ", sizeof(result) - strlen(result) -1); - if (canSymlink() && is_LargeInode("symlink")) + strncat(result, strerror(ERANGE), + sizeof(result) - strlen(result) -1); + strncat(result, "\n", + sizeof(result) - strlen(result) -1); + } + if (canSymlink() && is_LargeInode("symlink")) { strncat(result, - "bsdcpio: symlink: large inode number truncated: " - "Numerical result out of range\n", + "bsdcpio: symlink: large inode number truncated: ", sizeof(result) - strlen(result) -1); - if (is_LargeInode("dir")) + strncat(result, strerror(ERANGE), + sizeof(result) - strlen(result) -1); + strncat(result, "\n", + sizeof(result) - strlen(result) -1); + } + if (is_LargeInode("dir")) { strncat(result, - "bsdcpio: dir: large inode number truncated: " - "Numerical result out of range\n", + "bsdcpio: dir: large inode number truncated: ", sizeof(result) - strlen(result) -1); - if (is_LargeInode("hardlink")) + strncat(result, strerror(ERANGE), + sizeof(result) - strlen(result) -1); + strncat(result, "\n", + sizeof(result) - strlen(result) -1); + } + if (is_LargeInode("hardlink")) { strncat(result, - "bsdcpio: hardlink: large inode number truncated: " - "Numerical result out of range\n", + "bsdcpio: hardlink: large inode number truncated: ", sizeof(result) - strlen(result) -1); + strncat(result, strerror(ERANGE), + sizeof(result) - strlen(result) -1); + strncat(result, "\n", + sizeof(result) - strlen(result) -1); + } /* Record some facts about what we just created: */ now = time(NULL); /* They were all created w/in last two seconds. */ diff --git a/archivers/libarchive/files/cpio/test/test_option_zstd.c b/archivers/libarchive/files/cpio/test/test_option_zstd.c new file mode 100644 index 00000000000..29b8c78b94a --- /dev/null +++ b/archivers/libarchive/files/cpio/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 zstd compression. */ + r = systemf("echo f | %s -o --zstd >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 bsdcpio 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 bsdcpio 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 bsdcpio 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 zstd signature. */ + p = slurpfile(&s, "archive.out"); + assert(s > 2); + assertEqualMem(p, "\x28\xb5\x2f\xfd", 4); + +done: + free(p); +} |