From 19e90b8b2b65d2d8cd1dae36c100bccdc88d4779 Mon Sep 17 00:00:00 2001 From: Cory Forsstrom Date: Thu, 7 Nov 2024 14:16:51 -0800 Subject: [PATCH] Fix feedback --- packages/f/file-roller/package.yml | 2 +- packages/f/file-roller/pspec_x86_64.xml | 2 +- packages/l/libarchive/abi_symbols | 4 - packages/l/libarchive/abi_symbols32 | 4 - packages/l/libarchive/abi_used_symbols | 4 +- packages/l/libarchive/abi_used_symbols32 | 4 +- .../files/0001-Add-stone-read-support.patch | 772 ++++++++++++++++++ packages/l/libarchive/package.yml | 9 +- packages/l/libarchive/pspec_x86_64.xml | 8 +- 9 files changed, 786 insertions(+), 23 deletions(-) create mode 100644 packages/l/libarchive/files/0001-Add-stone-read-support.patch diff --git a/packages/f/file-roller/package.yml b/packages/f/file-roller/package.yml index 336047076e8e..9bfef4f92470 100644 --- a/packages/f/file-roller/package.yml +++ b/packages/f/file-roller/package.yml @@ -20,7 +20,7 @@ builddeps : rundeps : - unrar setup : | - %apply_patches + %patch -p1 -i $pkgfiles/0001-stone-mime.patch %meson_configure -Dpackagekit=false build : | diff --git a/packages/f/file-roller/pspec_x86_64.xml b/packages/f/file-roller/pspec_x86_64.xml index ded2fcfcd36b..13090bda3d5c 100644 --- a/packages/f/file-roller/pspec_x86_64.xml +++ b/packages/f/file-roller/pspec_x86_64.xml @@ -543,7 +543,7 @@ - 2024-11-05 + 2024-11-07 44.3 Packaging update Cory Forsstrom diff --git a/packages/l/libarchive/abi_symbols b/packages/l/libarchive/abi_symbols index 442027e130f5..672a2959d279 100644 --- a/packages/l/libarchive/abi_symbols +++ b/packages/l/libarchive/abi_symbols @@ -426,10 +426,6 @@ libarchive.so.13:archive_write_set_options libarchive.so.13:archive_write_set_passphrase libarchive.so.13:archive_write_set_passphrase_callback libarchive.so.13:archive_write_set_skip_file -libarchive.so.13:archive_write_zip_set_compression_bzip2 libarchive.so.13:archive_write_zip_set_compression_deflate -libarchive.so.13:archive_write_zip_set_compression_lzma libarchive.so.13:archive_write_zip_set_compression_store -libarchive.so.13:archive_write_zip_set_compression_xz -libarchive.so.13:archive_write_zip_set_compression_zstd libarchive.so.13:archive_zlib_version diff --git a/packages/l/libarchive/abi_symbols32 b/packages/l/libarchive/abi_symbols32 index 442027e130f5..672a2959d279 100644 --- a/packages/l/libarchive/abi_symbols32 +++ b/packages/l/libarchive/abi_symbols32 @@ -426,10 +426,6 @@ libarchive.so.13:archive_write_set_options libarchive.so.13:archive_write_set_passphrase libarchive.so.13:archive_write_set_passphrase_callback libarchive.so.13:archive_write_set_skip_file -libarchive.so.13:archive_write_zip_set_compression_bzip2 libarchive.so.13:archive_write_zip_set_compression_deflate -libarchive.so.13:archive_write_zip_set_compression_lzma libarchive.so.13:archive_write_zip_set_compression_store -libarchive.so.13:archive_write_zip_set_compression_xz -libarchive.so.13:archive_write_zip_set_compression_zstd libarchive.so.13:archive_zlib_version diff --git a/packages/l/libarchive/abi_used_symbols b/packages/l/libarchive/abi_used_symbols index 2b4797c3fc2c..03cfd25e80f0 100644 --- a/packages/l/libarchive/abi_used_symbols +++ b/packages/l/libarchive/abi_used_symbols @@ -278,6 +278,7 @@ libstone.so.0.24:stone_reader_destroy libstone.so.0.24:stone_reader_header_v1 libstone.so.0.24:stone_reader_next_payload libstone.so.0.24:stone_reader_read_content_payload +libxml2.so.2:UTF8Toisolat1 libxml2.so.2:xmlBufferCreate libxml2.so.2:xmlBufferFree libxml2.so.2:xmlCleanupParser @@ -300,8 +301,8 @@ libxml2.so.2:xmlTextWriterStartDocument libxml2.so.2:xmlTextWriterStartElement libxml2.so.2:xmlTextWriterWriteAttribute libxml2.so.2:xmlTextWriterWriteBase64 +libxml2.so.2:xmlTextWriterWriteFormatAttribute libxml2.so.2:xmlTextWriterWriteString -libxml2.so.2:xmlTextWriterWriteVFormatAttribute libz.so.1:adler32 libz.so.1:crc32 libz.so.1:deflate @@ -321,7 +322,6 @@ libzstd.so.1:ZSTD_CStreamOutSize libzstd.so.1:ZSTD_DStreamOutSize libzstd.so.1:ZSTD_cParam_getBounds libzstd.so.1:ZSTD_compressStream -libzstd.so.1:ZSTD_compressStream2 libzstd.so.1:ZSTD_createCStream libzstd.so.1:ZSTD_createDStream libzstd.so.1:ZSTD_decompressStream diff --git a/packages/l/libarchive/abi_used_symbols32 b/packages/l/libarchive/abi_used_symbols32 index 0092a6219a85..2d3411581fc1 100644 --- a/packages/l/libarchive/abi_used_symbols32 +++ b/packages/l/libarchive/abi_used_symbols32 @@ -206,6 +206,7 @@ liblzo2.so.2:lzo1x_decompress_safe liblzo2.so.2:lzo_adler32 liblzo2.so.2:lzo_version liblzo2.so.2:lzo_version_string +libxml2.so.2:UTF8Toisolat1 libxml2.so.2:xmlBufferCreate libxml2.so.2:xmlBufferFree libxml2.so.2:xmlCleanupParser @@ -228,8 +229,8 @@ libxml2.so.2:xmlTextWriterStartDocument libxml2.so.2:xmlTextWriterStartElement libxml2.so.2:xmlTextWriterWriteAttribute libxml2.so.2:xmlTextWriterWriteBase64 +libxml2.so.2:xmlTextWriterWriteFormatAttribute libxml2.so.2:xmlTextWriterWriteString -libxml2.so.2:xmlTextWriterWriteVFormatAttribute libz.so.1:adler32 libz.so.1:crc32 libz.so.1:deflate @@ -249,7 +250,6 @@ libzstd.so.1:ZSTD_CStreamOutSize libzstd.so.1:ZSTD_DStreamOutSize libzstd.so.1:ZSTD_cParam_getBounds libzstd.so.1:ZSTD_compressStream -libzstd.so.1:ZSTD_compressStream2 libzstd.so.1:ZSTD_createCStream libzstd.so.1:ZSTD_createDStream libzstd.so.1:ZSTD_decompressStream diff --git a/packages/l/libarchive/files/0001-Add-stone-read-support.patch b/packages/l/libarchive/files/0001-Add-stone-read-support.patch new file mode 100644 index 000000000000..f0e723ae44ed --- /dev/null +++ b/packages/l/libarchive/files/0001-Add-stone-read-support.patch @@ -0,0 +1,772 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Cory Forsstrom +Date: Mon, 4 Nov 2024 14:34:16 -0800 +Subject: [PATCH] Add stone read support + +--- + CMakeLists.txt | 34 ++ + Makefile.am | 1 + + build/cmake/config.h.in | 6 + + configure.ac | 8 + + libarchive/CMakeLists.txt | 1 + + libarchive/archive.h | 3 + + libarchive/archive_read_private.h | 2 +- + libarchive/archive_read_set_format.c | 3 + + libarchive/archive_read_support_format_all.c | 2 + + .../archive_read_support_format_by_code.c | 3 + + .../archive_read_support_format_stone.c | 552 ++++++++++++++++++ + 11 files changed, 614 insertions(+), 1 deletion(-) + create mode 100644 libarchive/archive_read_support_format_stone.c + +diff --git a/CMakeLists.txt b/CMakeLists.txt +index bfe68acd..05aa56d0 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -241,6 +241,7 @@ OPTION(ENABLE_EXPAT "Enable the use of the system EXPAT library if found" ON) + OPTION(ENABLE_PCREPOSIX "Enable the use of the system PCREPOSIX library if found" ON) + OPTION(ENABLE_PCRE2POSIX "Enable the use of the system PCRE2POSIX library if found" ON) + OPTION(ENABLE_LIBGCC "Enable the use of the system LibGCC library if found" ON) ++OPTION(ENABLE_LIBSTONE "Enable the use of the system stone library if found" OFF) + # CNG is used for encrypt/decrypt Zip archives on Windows. + OPTION(ENABLE_CNG "Enable the use of CNG(Crypto Next Generation)" ON) + +@@ -689,6 +690,39 @@ IF(ZSTD_FOUND) + ENDIF(ZSTD_FOUND) + MARK_AS_ADVANCED(CLEAR ZSTD_INCLUDE_DIR) + MARK_AS_ADVANCED(CLEAR ZSTD_LIBRARY) ++# ++# Find libstone ++# ++IF(ENABLE_LIBSTONE) ++ IF (LIBSTONE_INCLUDE_DIR) ++ # Already in cache, be silent ++ SET(LIBSTONE_FIND_QUIETLY TRUE) ++ ENDIF (LIBSTONE_INCLUDE_DIR) ++ ++ IF(UNIX) ++ FIND_PACKAGE(PkgConfig QUIET) ++ PKG_SEARCH_MODULE(PC_LIBSTONE libstone) ++ ENDIF() ++ ++ FIND_PATH(LIBSTONE_INCLUDE_DIR stone.h HINTS ${PC_LIBSTONE_INCLUDEDIR} ${PC_LIBSTONE_INCLUDE_DIRS}) ++ FIND_LIBRARY(LIBSTONE_LIBRARY NAMES stone libstone HINTS ${PC_LIBSTONE_LIBDIR} ${PC_LIBSTONE_LIBRARY_DIRS}) ++ INCLUDE(FindPackageHandleStandardArgs) ++ FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBSTONE DEFAULT_MSG LIBSTONE_LIBRARY LIBSTONE_INCLUDE_DIR) ++ELSE(ENABLE_LIBSTONE) ++ SET(LIBSTONE_FOUND FALSE) # Override cached value ++ENDIF(ENABLE_LIBSTONE) ++IF(LIBSTONE_FOUND) ++ SET(HAVE_STONE_H 1) ++ INCLUDE_DIRECTORIES(${LIBSTONE_INCLUDE_DIR}) ++ LIST(APPEND ADDITIONAL_LIBS ${LIBSTONE_LIBRARY}) ++ CMAKE_PUSH_CHECK_STATE() ++ SET(CMAKE_REQUIRED_LIBRARIES ${LIBSTONE_LIBRARY}) ++ SET(CMAKE_REQUIRED_INCLUDES ${LIBSTONE_INCLUDE_DIR}) ++ CHECK_FUNCTION_EXISTS(stone_read HAVE_LIBSTONE) ++ CMAKE_POP_CHECK_STATE() ++ENDIF(LIBSTONE_FOUND) ++MARK_AS_ADVANCED(CLEAR LIBSTONE_INCLUDE_DIR) ++MARK_AS_ADVANCED(CLEAR LIBSTONE_LIBRARY) + + + # +diff --git a/Makefile.am b/Makefile.am +index a36126c4..eb96906d 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -193,6 +193,7 @@ libarchive_la_SOURCES= \ + libarchive/archive_read_support_format_warc.c \ + libarchive/archive_read_support_format_xar.c \ + libarchive/archive_read_support_format_zip.c \ ++ libarchive/archive_read_support_format_stone.c \ + libarchive/archive_string.c \ + libarchive/archive_string.h \ + libarchive/archive_string_composition.h \ +diff --git a/build/cmake/config.h.in b/build/cmake/config.h.in +index d6e54879..f8f99360 100644 +--- a/build/cmake/config.h.in ++++ b/build/cmake/config.h.in +@@ -777,6 +777,9 @@ typedef uint64_t uintmax_t; + /* Define to 1 if you have the ZSTD_compressStream function. */ + #cmakedefine HAVE_ZSTD_compressStream 1 + ++/* Define to 1 if you have the `stone' library (-lstone). */ ++#cmakedefine HAVE_LIBSTONE 1 ++ + /* Define to 1 if you have the header file. */ + #cmakedefine HAVE_LIMITS_H 1 + +@@ -1271,6 +1274,9 @@ typedef uint64_t uintmax_t; + /* Define to 1 if you have the header file. */ + #cmakedefine HAVE_ZSTD_H 1 + ++/* Define to 1 if you have the header file. */ ++#cmakedefine HAVE_STONE_H 1 ++ + /* Define to 1 if you have the `ctime_s' function. */ + #cmakedefine HAVE_CTIME_S 1 + +diff --git a/configure.ac b/configure.ac +index 9cdaee50..0b9e85de 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -485,6 +485,14 @@ if test "x$with_zstd" != "xno"; then + AC_DEFINE([HAVE_ZSTD_compressStream], [1], [Define to 1 if you have the `zstd' library (-lzstd) with compression support.])) + fi + ++AC_ARG_WITH([libstone], ++ AS_HELP_STRING([--with-libstone], [Build with stone support from libstone])) ++ ++if test "x$with_libstone" = "xyes"; then ++ AC_CHECK_HEADERS([stone.h]) ++ AC_CHECK_LIB(stone,stone_read) ++fi ++ + AC_ARG_WITH([lzma], + AS_HELP_STRING([--without-lzma], [Don't build support for xz through lzma])) + +diff --git a/libarchive/CMakeLists.txt b/libarchive/CMakeLists.txt +index dd0b2808..c19831a8 100644 +--- a/libarchive/CMakeLists.txt ++++ b/libarchive/CMakeLists.txt +@@ -113,6 +113,7 @@ SET(libarchive_SOURCES + archive_read_support_format_warc.c + archive_read_support_format_xar.c + archive_read_support_format_zip.c ++ archive_read_support_format_stone.c + archive_string.c + archive_string.h + archive_string_composition.h +diff --git a/libarchive/archive.h b/libarchive/archive.h +index 5b65475f..aff8fc05 100644 +--- a/libarchive/archive.h ++++ b/libarchive/archive.h +@@ -344,6 +344,7 @@ typedef const char *archive_passphrase_callback(struct archive *, + #define ARCHIVE_FORMAT_7ZIP 0xE0000 + #define ARCHIVE_FORMAT_WARC 0xF0000 + #define ARCHIVE_FORMAT_RAR_V5 0x100000 ++#define ARCHIVE_FORMAT_STONE 0x200000 + + /* + * Codes returned by archive_read_format_capabilities(). +@@ -469,6 +470,8 @@ __LA_DECL int archive_read_support_format_zip_streamable(struct archive *); + /* Reads starting from central directory; requires seekable input. */ + __LA_DECL int archive_read_support_format_zip_seekable(struct archive *); + ++__LA_DECL int archive_read_support_format_stone(struct archive *); ++ + /* Functions to manually set the format and filters to be used. This is + * useful to bypass the bidding process when the format and filters to use + * is known in advance. +diff --git a/libarchive/archive_read_private.h b/libarchive/archive_read_private.h +index 0c374f48..3c4efafb 100644 +--- a/libarchive/archive_read_private.h ++++ b/libarchive/archive_read_private.h +@@ -205,7 +205,7 @@ struct archive_read { + int (*cleanup)(struct archive_read *); + int (*format_capabilties)(struct archive_read *); + int (*has_encrypted_entries)(struct archive_read *); +- } formats[16]; ++ } formats[17]; + struct archive_format_descriptor *format; /* Active format. */ + + /* +diff --git a/libarchive/archive_read_set_format.c b/libarchive/archive_read_set_format.c +index c74361b2..69fc3479 100644 +--- a/libarchive/archive_read_set_format.c ++++ b/libarchive/archive_read_set_format.c +@@ -93,6 +93,9 @@ archive_read_set_format(struct archive *_a, int code) + case ARCHIVE_FORMAT_ZIP: + strcpy(str, "zip"); + break; ++ case ARCHIVE_FORMAT_STONE: ++ strcpy(str, "stone"); ++ break; + default: + archive_set_error(&a->archive, ARCHIVE_ERRNO_PROGRAMMER, + "Invalid format code specified"); +diff --git a/libarchive/archive_read_support_format_all.c b/libarchive/archive_read_support_format_all.c +index 3b53c9ad..228ef43c 100644 +--- a/libarchive/archive_read_support_format_all.c ++++ b/libarchive/archive_read_support_format_all.c +@@ -77,6 +77,8 @@ archive_read_support_format_all(struct archive *a) + * logic to discard buffered data. */ + archive_read_support_format_zip(a); + ++ archive_read_support_format_stone(a); ++ + /* Note: We always return ARCHIVE_OK here, even if some of the + * above return ARCHIVE_WARN. The intent here is to enable + * "as much as possible." Clients who need specific +diff --git a/libarchive/archive_read_support_format_by_code.c b/libarchive/archive_read_support_format_by_code.c +index 7ed045f5..9d2f772b 100644 +--- a/libarchive/archive_read_support_format_by_code.c ++++ b/libarchive/archive_read_support_format_by_code.c +@@ -84,6 +84,9 @@ archive_read_support_format_by_code(struct archive *a, int format_code) + case ARCHIVE_FORMAT_ZIP: + return archive_read_support_format_zip(a); + break; ++ case ARCHIVE_FORMAT_STONE: ++ return archive_read_support_format_stone(a); ++ break; + } + archive_set_error(a, ARCHIVE_ERRNO_PROGRAMMER, + "Invalid format code specified"); +diff --git a/libarchive/archive_read_support_format_stone.c b/libarchive/archive_read_support_format_stone.c +new file mode 100644 +index 00000000..89c08a6c +--- /dev/null ++++ b/libarchive/archive_read_support_format_stone.c +@@ -0,0 +1,552 @@ ++/*- ++ * Copyright (c) 2011 Michihiro NAKAJIMA ++ * 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 "archive_platform.h" ++ ++#ifdef HAVE_ERRNO_H ++#include ++#endif ++#include ++#ifdef HAVE_STONE_H ++#include ++#endif ++ ++#include "archive.h" ++#include "archive_entry.h" ++#include "archive_entry_private.h" ++#include "archive_private.h" ++#include "archive_rb.h" ++#include "archive_read_private.h" ++ ++#if (!defined(HAVE_STONE_H) || !defined(HAVE_LIBSTONE)) ++ ++int archive_read_support_format_stone(struct archive *_a) { ++ struct archive_read *a = (struct archive_read *)_a; ++ archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW, ++ "archive_read_support_format_stone"); ++ ++ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC, ++ "stone format not supported on this platform"); ++ return (ARCHIVE_WARN); ++} ++ ++#else /* Support stone format */ ++ ++#define minimum(a, b) (a < b ? a : b) ++ ++static int archive_read_format_stone_bid(struct archive_read *, int); ++static int archive_read_format_stone_cleanup(struct archive_read *); ++static int archive_read_format_stone_read_header(struct archive_read *, ++ struct archive_entry *); ++static int archive_read_format_stone_read_data(struct archive_read *, ++ const void **, size_t *, ++ int64_t *); ++static int archive_read_format_stone_read_data_skip(struct archive_read *); ++static signed int cmp_index_nodes(const struct archive_rb_node *, ++ const struct archive_rb_node *); ++static signed int cmp_index_keys(const struct archive_rb_node *, const void *); ++static signed int cmp_file_nodes(const struct archive_rb_node *, ++ const struct archive_rb_node *); ++static char *stone_string_to_cstring(const StoneString *); ++ ++size_t read_shim(void *, char *, size_t); ++int64_t seek_shim(void *, int64_t, StoneSeekFrom); ++ ++struct _payload { ++ StonePayload *ptr; ++ StonePayloadHeader header; ++}; ++ ++struct _index { ++ struct archive_rb_node node; ++ StonePayloadIndexRecord record; ++ char *matched_path; ++}; ++ ++struct _layout { ++ StonePayloadLayoutRecord record; ++}; ++ ++struct _file { ++ struct archive_rb_node node; ++ const struct _layout *layout; ++ struct _index *index; ++ mode_t type; ++ char *path; ++ char *link; ++ char *hardlink; ++ size_t offset; ++}; ++ ++struct _stone { ++ StoneHeaderV1 header; ++ StoneReader *reader; ++ StonePayloadContentReader *content_reader; ++ struct _payload *payloads; ++ struct _index *indexes; ++ struct _layout *layouts; ++ struct _payload *content; ++ struct _file *files; ++ struct archive_rb_tree index_tree; ++ struct archive_rb_tree file_tree; ++ int nindex; ++ int nlayout; ++ // int nfiles; ++ struct _file *file; ++ char outbuf[2048]; ++}; ++ ++static signed int cmp_index_nodes(const struct archive_rb_node *n1, ++ const struct archive_rb_node *n2) { ++ const struct _index *e1 = (const struct _index *)n1; ++ const struct _index *e2 = (const struct _index *)n2; ++ ++ return memcmp(e2->record.digest, e1->record.digest, 16); ++} ++ ++static signed int cmp_index_keys(const struct archive_rb_node *n, ++ const void *_key) { ++ const struct _index *e = (const struct _index *)n; ++ const uint8_t *key = (const uint8_t *)_key; ++ ++ return memcmp(key, &e->record.digest, 16); ++} ++ ++static signed int cmp_file_nodes(const struct archive_rb_node *n1, ++ const struct archive_rb_node *n2) { ++ const struct _file *e1 = (const struct _file *)n1; ++ const struct _file *e2 = (const struct _file *)n2; ++ ++ if (e1->index == NULL && e2->index != NULL) { ++ return -1; ++ } else if (e1->index != NULL && e2->index == NULL) { ++ return 1; ++ } else if (e1->index == NULL && e2->index == NULL) { ++ return strcmp(e2->path, e1->path); ++ } else { ++ return (e2->index->record.start > e1->index->record.start) - ++ (e2->index->record.start < e1->index->record.start); ++ } ++} ++ ++// static signed int cmp_file_keys(const struct archive_rb_node *n, ++// const void *_key) { ++// const struct _file *e = (const struct _file *)n; ++// const uint64_t *key = (const uint64_t *)_key; ++ ++// return (*key > e->index->record.start) - (*key < e->index->record.start); ++// } ++ ++struct archive_rb_tree_ops rb_index_ops = {&cmp_index_nodes, &cmp_index_keys}; ++struct archive_rb_tree_ops rb_file_ops = {&cmp_file_nodes, ++ .rbto_compare_key = NULL}; ++ ++StoneReadVTable stone_read_vtable = { ++ .read = read_shim, ++ .seek = seek_shim, ++}; ++ ++int archive_read_support_format_stone(struct archive *_a) { ++ struct archive_read *a = (struct archive_read *)_a; ++ struct _stone *stone; ++ int r; ++ ++ archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW, ++ "archive_read_support_format_stone"); ++ ++ stone = calloc(1, sizeof(*stone)); ++ ++ if (stone == NULL) { ++ archive_set_error(&a->archive, ENOMEM, "Can't allocate stone data"); ++ return (ARCHIVE_FATAL); ++ } ++ ++ r = __archive_read_register_format( ++ a, stone, "stone", archive_read_format_stone_bid, NULL, ++ archive_read_format_stone_read_header, ++ archive_read_format_stone_read_data, ++ archive_read_format_stone_read_data_skip, NULL, ++ archive_read_format_stone_cleanup, NULL, NULL); ++ ++ if (r != ARCHIVE_OK) ++ free(stone); ++ ++ return (ARCHIVE_OK); ++} ++ ++static int archive_read_format_stone_bid(struct archive_read *a, int best_bid) { ++ struct _stone *stone; ++ StoneHeaderVersion version; ++ ++ (void)best_bid; /* UNUSED */ ++ ++ stone = (struct _stone *)(a->format->data); ++ ++ /* If there's already a better bid than we can ever ++ make, don't bother testing. */ ++ if (best_bid > STONE_HEADER_SIZE) { ++ return -1; ++ } ++ ++ if (stone_read(a, stone_read_vtable, &stone->reader, &version) < 0) { ++ return -1; ++ } ++ ++ if (version != STONE_HEADER_VERSION_V1) { ++ return -1; ++ } ++ ++ if (stone_reader_header_v1(stone->reader, &stone->header) < 0) { ++ return -1; ++ } ++ ++ if (stone->header.file_type != STONE_HEADER_V1_FILE_TYPE_BINARY) { ++ return -1; ++ } ++ ++ return STONE_HEADER_SIZE; ++} ++ ++static int archive_read_format_stone_read_header(struct archive_read *a, ++ struct archive_entry *entry) { ++ struct _stone *stone; ++ ++ (void)entry; /* UNUSED */ ++ ++ stone = (struct _stone *)(a->format->data); ++ ++ a->archive.archive_format = ARCHIVE_FORMAT_STONE; ++ a->archive.archive_format_name = "stone"; ++ ++ if (stone->payloads == 0) { ++ __archive_rb_tree_init(&stone->index_tree, &rb_index_ops); ++ __archive_rb_tree_init(&stone->file_tree, &rb_file_ops); ++ ++ if (a->filter->position != STONE_HEADER_SIZE) { ++ __archive_read_seek(a, STONE_HEADER_SIZE, 0); ++ } ++ ++ stone->payloads = ++ calloc(stone->header.num_payloads, sizeof(struct _payload)); ++ if (stone->payloads == NULL) { ++ archive_set_error(&a->archive, ENOMEM, ++ "Can't allocate memory for payloads"); ++ return (ARCHIVE_FATAL); ++ } ++ ++ for (int p = 0; p < stone->header.num_payloads; p++) { ++ struct _payload *payload = &stone->payloads[p]; ++ ++ stone_reader_next_payload(stone->reader, &payload->ptr); ++ stone_payload_header(payload->ptr, &payload->header); ++ ++ switch (payload->header.kind) { ++ case STONE_PAYLOAD_KIND_INDEX: { ++ struct _index *index; ++ ++ stone->indexes = realloc( ++ stone->indexes, sizeof(*stone->indexes) * ++ (stone->nindex + payload->header.num_records)); ++ if (stone->indexes == NULL) { ++ archive_set_error(&a->archive, ENOMEM, ++ "Can't allocate memory for index records"); ++ return (ARCHIVE_FATAL); ++ } ++ ++ for (int r = 0; r < (int)payload->header.num_records; r++) { ++ index = &stone->indexes[stone->nindex + r]; ++ memset(index, 0, sizeof(*index)); ++ stone_payload_next_index_record(payload->ptr, &index->record); ++ __archive_rb_tree_insert_node(&stone->index_tree, &index->node); ++ } ++ ++ stone->nindex += payload->header.num_records; ++ break; ++ } ++ case STONE_PAYLOAD_KIND_LAYOUT: { ++ struct _layout *layout; ++ ++ stone->layouts = realloc( ++ stone->layouts, sizeof(StonePayloadLayoutRecord) * ++ (stone->nlayout + payload->header.num_records)); ++ ++ if (stone->layouts == NULL) { ++ archive_set_error(&a->archive, ENOMEM, ++ "Can't allocate memory for layout records"); ++ return (ARCHIVE_FATAL); ++ } ++ ++ for (int r = 0; r < (int)payload->header.num_records; r++) { ++ layout = &stone->layouts[stone->nlayout + r]; ++ memset(layout, 0, sizeof(*layout)); ++ stone_payload_next_layout_record(payload->ptr, &layout->record); ++ } ++ ++ stone->nlayout += payload->header.num_records; ++ break; ++ } ++ case STONE_PAYLOAD_KIND_CONTENT: { ++ stone->content = payload; ++ } ++ default: { ++ break; ++ } ++ } ++ } ++ ++ if (stone->nlayout == 0 || stone->content == NULL) { ++ return (ARCHIVE_EOF); ++ } ++ ++ stone->files = calloc(stone->nlayout, sizeof(*stone->files)); ++ ++ for (int l = 0; l < stone->nlayout; l++) { ++ struct _file *file; ++ const struct _layout *layout = &stone->layouts[l]; ++ ++ file = &stone->files[l]; ++ file->layout = layout; ++ ++ switch (layout->record.file_type) { ++ case STONE_PAYLOAD_LAYOUT_FILE_TYPE_REGULAR: { ++ file->type = AE_IFREG; ++ file->path = stone_string_to_cstring( ++ &file->layout->record.file_payload.regular.name); ++ break; ++ } ++ case STONE_PAYLOAD_LAYOUT_FILE_TYPE_SYMLINK: { ++ file->type = AE_IFLNK; ++ file->path = stone_string_to_cstring( ++ &file->layout->record.file_payload.symlink.target); ++ file->link = stone_string_to_cstring( ++ &file->layout->record.file_payload.symlink.source); ++ ++ if (file->link == NULL) { ++ archive_set_error(&a->archive, ENOMEM, ++ "Can't allocate memory for link name"); ++ return (ARCHIVE_FATAL); ++ } ++ ++ break; ++ } ++ case STONE_PAYLOAD_LAYOUT_FILE_TYPE_DIRECTORY: { ++ file->type = AE_IFDIR; ++ file->path = stone_string_to_cstring( ++ &file->layout->record.file_payload.directory); ++ break; ++ } ++ case STONE_PAYLOAD_LAYOUT_FILE_TYPE_CHARACTER_DEVICE: { ++ file->type = AE_IFCHR; ++ file->path = stone_string_to_cstring( ++ &file->layout->record.file_payload.character_device); ++ break; ++ } ++ case STONE_PAYLOAD_LAYOUT_FILE_TYPE_BLOCK_DEVICE: { ++ file->type = AE_IFBLK; ++ file->path = stone_string_to_cstring( ++ &file->layout->record.file_payload.block_device); ++ break; ++ } ++ case STONE_PAYLOAD_LAYOUT_FILE_TYPE_FIFO: { ++ file->type = AE_IFIFO; ++ file->path = ++ stone_string_to_cstring(&file->layout->record.file_payload.fifo); ++ break; ++ } ++ case STONE_PAYLOAD_LAYOUT_FILE_TYPE_SOCKET: { ++ file->type = AE_IFSOCK; ++ file->path = ++ stone_string_to_cstring(&file->layout->record.file_payload.socket); ++ break; ++ } ++ default: { ++ break; ++ } ++ } ++ ++ if (file->path == NULL) { ++ archive_set_error(&a->archive, ENOMEM, ++ "Can't allocate memory for file name"); ++ return (ARCHIVE_FATAL); ++ } ++ ++ if (layout->record.file_type == STONE_PAYLOAD_LAYOUT_FILE_TYPE_REGULAR) { ++ struct _index *index = (struct _index *)__archive_rb_tree_find_node( ++ &stone->index_tree, &layout->record.file_payload.regular.hash); ++ ++ if (index->matched_path == NULL) { ++ index->matched_path = file->path; ++ file->index = index; ++ } else { ++ file->hardlink = index->matched_path; ++ } ++ } ++ ++ __archive_rb_tree_insert_node(&stone->file_tree, &file->node); ++ } ++ ++ stone->file = (struct _file *)ARCHIVE_RB_TREE_MIN(&stone->file_tree); ++ ++ stone_reader_read_content_payload(stone->reader, stone->content->ptr, ++ &stone->content_reader); ++ } else { ++ stone->file = (struct _file *)ARCHIVE_RB_TREE_NEXT( ++ &stone->file_tree, (struct archive_rb_node *)stone->file); ++ } ++ ++ if (stone->file != NULL) { ++ const struct _file *file = stone->file; ++ ++ archive_entry_set_pathname_utf8(entry, file->path); ++ archive_entry_set_filetype(entry, file->type); ++ ++ if (file->link != NULL) { ++ archive_entry_set_symlink_utf8(entry, file->link); ++ } else if (file->hardlink != NULL) { ++ archive_entry_set_hardlink_utf8(entry, file->hardlink); ++ } ++ ++ archive_entry_set_uid(entry, file->layout->record.uid); ++ archive_entry_set_gid(entry, file->layout->record.gid); ++ archive_entry_set_mode(entry, file->layout->record.mode); ++ ++ if (file->index) { ++ archive_entry_set_size(entry, file->index->record.end - ++ file->index->record.start); ++ } ++ ++ return (ARCHIVE_OK); ++ } else { ++ return (ARCHIVE_EOF); ++ } ++} ++ ++static int archive_read_format_stone_read_data(struct archive_read *a, ++ const void **buf, size_t *size, ++ int64_t *offset) { ++ struct _stone *stone; ++ struct _file *file; ++ ++ stone = (struct _stone *)(a->format->data); ++ *buf = &stone->outbuf; ++ file = stone->file; ++ ++ int fsize = file->index->record.end - file->index->record.start; ++ int frem = fsize - file->offset; ++ int avail = minimum(sizeof(stone->outbuf), (uint64_t)frem); ++ ++ if (frem == 0) { ++ return (ARCHIVE_EOF); ++ } ++ ++ *size = stone_payload_content_reader_read(stone->content_reader, ++ (void *)&stone->outbuf, avail); ++ ++ *offset = file->offset; ++ file->offset += *size; ++ ++ return (ARCHIVE_OK); ++} ++ ++static int archive_read_format_stone_read_data_skip(struct archive_read *a) { ++ struct _stone *stone; ++ const struct _file *file; ++ size_t read = 0; ++ int64_t offset = 0; ++ ++ stone = (struct _stone *)(a->format->data); ++ file = stone->file; ++ ++ if (file->index != NULL) { ++ while (archive_read_format_stone_read_data(a, NULL, &read, &offset) == ++ ARCHIVE_OK) { ++ } ++ } ++ ++ return (ARCHIVE_EOF); ++} ++ ++static int archive_read_format_stone_cleanup(struct archive_read *a) { ++ struct _stone *stone; ++ ++ stone = (struct _stone *)(a->format->data); ++ ++ for (int i = 0; i < stone->nlayout; i++) { ++ free(stone->files[i].path); ++ free(stone->files[i].link); ++ free(stone->files[i].hardlink); ++ } ++ free(stone->files); ++ free(stone->indexes); ++ free(stone->layouts); ++ stone_payload_content_reader_destroy(stone->content_reader); ++ for (int i = 0; i < stone->header.num_payloads; i++) { ++ stone_payload_destroy(stone->payloads[i].ptr); ++ } ++ free(stone->payloads); ++ stone_reader_destroy(stone->reader); ++ free(stone); ++ ++ (a->format->data) = NULL; ++ ++ return (ARCHIVE_OK); ++} ++ ++size_t read_shim(void *_a, char *buf, size_t size) { ++ struct archive_read *a = (struct archive_read *)_a; ++ ssize_t avail = 0; ++ size_t min; ++ const char *p; ++ ++ if ((p = __archive_read_ahead(a, 1, &avail)) == NULL) ++ return 0; ++ ++ min = minimum((size_t)avail, size); ++ ++ memcpy(buf, p, min); ++ ++ __archive_read_consume(a, min); ++ ++ return min; ++} ++ ++int64_t seek_shim(void *_a, int64_t offset, StoneSeekFrom from) { ++ struct archive_read *a = (struct archive_read *)_a; ++ ++ return __archive_read_seek(a, offset, from); ++} ++ ++static char *stone_string_to_cstring(const StoneString *stone) { ++ char *p; ++ ++ p = calloc(stone->size + 1, 1); ++ if (p == NULL) { ++ return (p); ++ } ++ memcpy(p, stone->buf, stone->size); ++ return (p); ++} ++ ++#endif /* Support stone format */ diff --git a/packages/l/libarchive/package.yml b/packages/l/libarchive/package.yml index ff0c371ba7ad..da6b85fdf7d5 100644 --- a/packages/l/libarchive/package.yml +++ b/packages/l/libarchive/package.yml @@ -2,7 +2,7 @@ name : libarchive version : 3.7.7 release : 56 source : - - https://github.com/tarkah/libarchive/archive/43dab5e7d608dc3e8b4e3a514dd74f6b86f7ecb7.tar.gz : 8f5768633fd3ddc5e86c51fce9c2e25e351081dd58f6e899299855830bc847c6 + - https://github.com/libarchive/libarchive/releases/download/v3.7.7/libarchive-3.7.7.tar.xz : 879acd83c3399c7caaee73fe5f7418e06087ab2aaf40af3e99b9e29beb29faee homepage : http://www.libarchive.org/ license : BSD-2-Clause component : @@ -34,12 +34,11 @@ patterns : clang : yes optimize : thin-lto setup : | + %patch -p1 -i $pkgfiles/0001-Add-stone-read-support.patch + ./build/autogen.sh - %configure \ - --disable-static \ - --with-lzo2 \ - --with-libstone + %configure --disable-static --with-lzo2 --with-libstone build : | %make install : | diff --git a/packages/l/libarchive/pspec_x86_64.xml b/packages/l/libarchive/pspec_x86_64.xml index 239ac9319049..fd5f7c255533 100644 --- a/packages/l/libarchive/pspec_x86_64.xml +++ b/packages/l/libarchive/pspec_x86_64.xml @@ -21,7 +21,7 @@ programming.library /usr/lib64/libarchive.so.13 - /usr/lib64/libarchive.so.13.8.0 + /usr/lib64/libarchive.so.13.7.7 @@ -35,7 +35,7 @@ /usr/lib32/libarchive.so.13 - /usr/lib32/libarchive.so.13.8.0 + /usr/lib32/libarchive.so.13.7.7 @@ -45,8 +45,8 @@ programming.devel - libarchive-devel libarchive-32bit + libarchive-devel /usr/lib32/libarchive.so @@ -132,7 +132,7 @@ - 2024-11-05 + 2024-11-07 3.7.7 Packaging update Cory Forsstrom