libarchive 3.1.2-246-ga5a5d28b (reduced)

Extract upstream libarchive using the following shell code.

url=git://github.com/libarchive/libarchive.git &&
v=3.1.2-246-ga5a5d28b &&
r=a5a5d28b &&
paths="
  CMakeLists.txt
  COPYING
  CTestConfig.cmake
  build/cmake
  build/pkgconfig
  build/utils
  build/version
  libarchive/*.*
" &&
mkdir libarchive-$v-g$r-reduced &&
git clone $url libarchive-git &&
date=$(cd libarchive-git && git log -n 1 --format='%cd' $r) &&
(cd libarchive-git && git archive --format=tar $r -- $paths) |
(cd libarchive-$v-g$r-reduced && tar xv) &&
fromdos libarchive-$v-g$r-reduced/build/cmake/Find*.cmake &&
echo "g$r date: $date"
This commit is contained in:
LibArchive Upstream 2014-04-14 19:19:05 -07:00 committed by Brad King
parent 64713ae3ff
commit 37f225b72c
9 changed files with 195 additions and 139 deletions

View File

@ -55,6 +55,7 @@ STRING(REGEX REPLACE "[0]*([^0]*[0-9])$" "\\1" _trimmed_revision ${_revision})
SET(VERSION "${_major}.${_trimmed_minor}.${_trimmed_revision}${_quality}")
SET(BSDCPIO_VERSION_STRING "${VERSION}")
SET(BSDTAR_VERSION_STRING "${VERSION}")
SET(BSDCAT_VERSION_STRING "${VERSION}")
SET(LIBARCHIVE_VERSION_NUMBER "${_version_number}")
SET(LIBARCHIVE_VERSION_STRING "${VERSION}")
@ -168,6 +169,8 @@ OPTION(ENABLE_TAR "Enable tar building" ON)
OPTION(ENABLE_TAR_SHARED "Enable dynamic build of tar" FALSE)
OPTION(ENABLE_CPIO "Enable cpio building" ON)
OPTION(ENABLE_CPIO_SHARED "Enable dynamic build of cpio" FALSE)
OPTION(ENABLE_CAT "Enable cat building" ON)
OPTION(ENABLE_CAT_SHARED "Enable dynamic build of cat" FALSE)
OPTION(ENABLE_XATTR "Enable extended attribute support" ON)
OPTION(ENABLE_ACL "Enable ACL support" ON)
OPTION(ENABLE_ICONV "Enable iconv support" ON)
@ -1535,6 +1538,12 @@ ADD_DEFINITIONS(-DHAVE_CONFIG_H)
# Handle generation of the libarchive.pc file for pkg-config
INCLUDE(CreatePkgConfigFile)
#
# Expose ADDITIONAL_LIBS for projects using libarchive as a subdirectory
# and linking against archive_static.
#
set(LIBARCHIVE_ADDITIONAL_LIBS ${ADDITIONAL_LIBS} CACHE INTERNAL "libarchive dependencies")
#
# Register installation of PDF documents.
#
@ -1565,5 +1574,6 @@ IF(ENABLE_TEST)
ENDIF(ENABLE_TEST)
add_subdirectory(libarchive)
add_subdirectory(cat)
add_subdirectory(tar)
add_subdirectory(cpio)

View File

@ -289,6 +289,9 @@ typedef uint64_t uintmax_t;
/* Version number of bsdtar */
#cmakedefine BSDTAR_VERSION_STRING "${BSDTAR_VERSION_STRING}"
/* Version number of bsdcat */
#cmakedefine BSDCAT_VERSION_STRING "${BSDCAT_VERSION_STRING}"
/* Define to 1 if you have the `acl_create_entry' function. */
#cmakedefine HAVE_ACL_CREATE_ENTRY 1

View File

@ -54,6 +54,7 @@ SET(libarchive_SOURCES
archive_read_disk_private.h
archive_read_disk_set_standard_lookup.c
archive_read_extract.c
archive_read_extract2.c
archive_read_open_fd.c
archive_read_open_file.c
archive_read_open_filename.c

View File

@ -26,146 +26,40 @@
#include "archive_platform.h"
__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_extract.c,v 1.61 2008/05/26 17:00:22 kientzle Exp $");
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#include "archive.h"
#include "archive_entry.h"
#include "archive_private.h"
#include "archive_read_private.h"
#include "archive_write_disk_private.h"
struct extract {
struct archive *ad; /* archive_write_disk object */
/* Progress function invoked during extract. */
void (*extract_progress)(void *);
void *extract_progress_user_data;
};
static int archive_read_extract_cleanup(struct archive_read *);
static int copy_data(struct archive *ar, struct archive *aw);
static struct extract *get_extract(struct archive_read *);
static struct extract *
get_extract(struct archive_read *a)
{
/* If we haven't initialized, do it now. */
/* This also sets up a lot of global state. */
if (a->extract == NULL) {
a->extract = (struct extract *)malloc(sizeof(*a->extract));
if (a->extract == NULL) {
archive_set_error(&a->archive, ENOMEM, "Can't extract");
return (NULL);
}
memset(a->extract, 0, sizeof(*a->extract));
a->extract->ad = archive_write_disk_new();
if (a->extract->ad == NULL) {
archive_set_error(&a->archive, ENOMEM, "Can't extract");
return (NULL);
}
archive_write_disk_set_standard_lookup(a->extract->ad);
a->cleanup_archive_extract = archive_read_extract_cleanup;
}
return (a->extract);
}
int
archive_read_extract(struct archive *_a, struct archive_entry *entry, int flags)
{
struct extract *extract;
struct archive_read_extract *extract;
struct archive_read * a = (struct archive_read *)_a;
extract = get_extract((struct archive_read *)_a);
extract = __archive_read_get_extract(a);
if (extract == NULL)
return (ARCHIVE_FATAL);
archive_write_disk_set_options(extract->ad, flags);
return (archive_read_extract2(_a, entry, extract->ad));
}
int
archive_read_extract2(struct archive *_a, struct archive_entry *entry,
struct archive *ad)
{
struct archive_read *a = (struct archive_read *)_a;
int r, r2;
/* Set up for this particular entry. */
if (a->skip_file_set)
archive_write_disk_set_skip_file(ad,
a->skip_file_dev, a->skip_file_ino);
r = archive_write_header(ad, entry);
if (r < ARCHIVE_WARN)
r = ARCHIVE_WARN;
if (r != ARCHIVE_OK)
/* If _write_header failed, copy the error. */
archive_copy_error(&a->archive, ad);
else if (!archive_entry_size_is_set(entry) || archive_entry_size(entry) > 0)
/* Otherwise, pour data into the entry. */
r = copy_data(_a, ad);
r2 = archive_write_finish_entry(ad);
if (r2 < ARCHIVE_WARN)
r2 = ARCHIVE_WARN;
/* Use the first message. */
if (r2 != ARCHIVE_OK && r == ARCHIVE_OK)
archive_copy_error(&a->archive, ad);
/* Use the worst error return. */
if (r2 < r)
r = r2;
return (r);
}
void
archive_read_extract_set_progress_callback(struct archive *_a,
void (*progress_func)(void *), void *user_data)
{
struct archive_read *a = (struct archive_read *)_a;
struct extract *extract = get_extract(a);
if (extract != NULL) {
extract->extract_progress = progress_func;
extract->extract_progress_user_data = user_data;
}
}
static int
copy_data(struct archive *ar, struct archive *aw)
{
int64_t offset;
const void *buff;
struct extract *extract;
size_t size;
int r;
extract = get_extract((struct archive_read *)ar);
if (extract == NULL)
return (ARCHIVE_FATAL);
for (;;) {
r = archive_read_data_block(ar, &buff, &size, &offset);
if (r == ARCHIVE_EOF)
return (ARCHIVE_OK);
if (r != ARCHIVE_OK)
return (r);
r = (int)archive_write_data_block(aw, buff, size, offset);
if (r < ARCHIVE_WARN)
r = ARCHIVE_WARN;
if (r != ARCHIVE_OK) {
archive_set_error(ar, archive_errno(aw),
"%s", archive_error_string(aw));
return (r);
/* If we haven't initialized the archive_write_disk object, do it now. */
if (extract->ad == NULL) {
extract->ad = archive_write_disk_new();
if (extract->ad == NULL) {
archive_set_error(&a->archive, ENOMEM, "Can't extract");
return (ARCHIVE_FATAL);
}
if (extract->extract_progress)
(extract->extract_progress)
(extract->extract_progress_user_data);
archive_write_disk_set_standard_lookup(extract->ad);
a->cleanup_archive_extract = archive_read_extract_cleanup;
}
archive_write_disk_set_options(extract->ad, flags);
return (archive_read_extract2(&a->archive, entry, extract->ad));
}
/*

View File

@ -0,0 +1,137 @@
/*-
* Copyright (c) 2003-2007 Tim Kientzle
* 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"
__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_extract.c,v 1.61 2008/05/26 17:00:22 kientzle Exp $");
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#include "archive.h"
#include "archive_entry.h"
#include "archive_private.h"
#include "archive_read_private.h"
static int copy_data(struct archive *ar, struct archive *aw);
/* Retrieve an extract object without initialising the associated
* archive_write_disk object.
*/
struct archive_read_extract *
__archive_read_get_extract(struct archive_read *a)
{
if (a->extract == NULL) {
a->extract = (struct archive_read_extract *)malloc(sizeof(*a->extract));
if (a->extract == NULL) {
archive_set_error(&a->archive, ENOMEM, "Can't extract");
return (NULL);
}
memset(a->extract, 0, sizeof(*a->extract));
}
return (a->extract);
}
int
archive_read_extract2(struct archive *_a, struct archive_entry *entry,
struct archive *ad)
{
struct archive_read *a = (struct archive_read *)_a;
int r, r2;
/* Set up for this particular entry. */
if (a->skip_file_set)
archive_write_disk_set_skip_file(ad,
a->skip_file_dev, a->skip_file_ino);
r = archive_write_header(ad, entry);
if (r < ARCHIVE_WARN)
r = ARCHIVE_WARN;
if (r != ARCHIVE_OK)
/* If _write_header failed, copy the error. */
archive_copy_error(&a->archive, ad);
else if (!archive_entry_size_is_set(entry) || archive_entry_size(entry) > 0)
/* Otherwise, pour data into the entry. */
r = copy_data(_a, ad);
r2 = archive_write_finish_entry(ad);
if (r2 < ARCHIVE_WARN)
r2 = ARCHIVE_WARN;
/* Use the first message. */
if (r2 != ARCHIVE_OK && r == ARCHIVE_OK)
archive_copy_error(&a->archive, ad);
/* Use the worst error return. */
if (r2 < r)
r = r2;
return (r);
}
void
archive_read_extract_set_progress_callback(struct archive *_a,
void (*progress_func)(void *), void *user_data)
{
struct archive_read *a = (struct archive_read *)_a;
struct archive_read_extract *extract = __archive_read_get_extract(a);
if (extract != NULL) {
extract->extract_progress = progress_func;
extract->extract_progress_user_data = user_data;
}
}
static int
copy_data(struct archive *ar, struct archive *aw)
{
int64_t offset;
const void *buff;
struct archive_read_extract *extract;
size_t size;
int r;
extract = __archive_read_get_extract((struct archive_read *)ar);
if (extract == NULL)
return (ARCHIVE_FATAL);
for (;;) {
r = archive_read_data_block(ar, &buff, &size, &offset);
if (r == ARCHIVE_EOF)
return (ARCHIVE_OK);
if (r != ARCHIVE_OK)
return (r);
r = (int)archive_write_data_block(aw, buff, size, offset);
if (r < ARCHIVE_WARN)
r = ARCHIVE_WARN;
if (r != ARCHIVE_OK) {
archive_set_error(ar, archive_errno(aw),
"%s", archive_error_string(aw));
return (r);
}
if (extract->extract_progress)
(extract->extract_progress)
(extract->extract_progress_user_data);
}
}

View File

@ -142,6 +142,14 @@ struct archive_read_client {
struct archive_read_data_node *dataset;
};
struct archive_read_extract {
struct archive *ad; /* archive_write_disk object */
/* Progress function invoked during extract. */
void (*extract_progress)(void *);
void *extract_progress_user_data;
};
struct archive_read {
struct archive archive;
@ -215,7 +223,7 @@ struct archive_read {
/*
* Various information needed by archive_extract.
*/
struct extract *extract;
struct archive_read_extract *extract;
int (*cleanup_archive_extract)(struct archive_read *);
};
@ -245,4 +253,5 @@ int64_t __archive_read_filter_consume(struct archive_read_filter *, int64_t);
int __archive_read_program(struct archive_read_filter *, const char *);
void __archive_read_free_filters(struct archive_read *);
int __archive_read_close_filters(struct archive_read *);
struct archive_read_extract *__archive_read_get_extract(struct archive_read *);
#endif

View File

@ -204,10 +204,11 @@ compression_name(const int compression)
{
static const int num_compression_methods = sizeof(compression_methods)/sizeof(compression_methods[0]);
int i=0;
while(compression >= 0 && i++ < num_compression_methods) {
while(compression >= 0 && i < num_compression_methods) {
if (compression_methods[i].id == compression) {
return compression_methods[i].name;
}
i++;
}
return "??";
}
@ -743,7 +744,7 @@ zip_read_local_file_header(struct archive_read *a, struct archive_entry *entry,
zip->end_of_entry = 1;
/* Set up a more descriptive format name. */
sprintf(zip->format_name, "ZIP %d.%d (%s)",
snprintf(zip->format_name, sizeof(zip->format_name), "ZIP %d.%d (%s)",
version / 10, version % 10,
compression_name(zip->entry->compression));
a->archive.archive_format_name = zip->format_name;

View File

@ -2215,7 +2215,8 @@ _archive_write_disk_free(struct archive *_a)
free(a->resource_fork);
free(a->compressed_buffer);
free(a->uncompressed_buffer);
#ifdef HAVE_ZLIB_H
#if defined(__APPLE__) && defined(UF_COMPRESSED) && defined(HAVE_SYS_XATTR_H)\
&& defined(HAVE_ZLIB_H)
if (a->stream_valid) {
switch (deflateEnd(&a->stream)) {
case Z_OK:

View File

@ -405,8 +405,8 @@ archive_write_zip_header(struct archive_write *a, struct archive_entry *entry)
unsigned char *e;
unsigned char *cd_extra;
size_t filename_length;
const char *symlink = NULL;
size_t symlink_size = 0;
const char *slink = NULL;
size_t slink_size = 0;
struct archive_string_conv *sconv = get_sconv(a, zip);
int ret, ret2 = ARCHIVE_OK;
int64_t size;
@ -528,16 +528,16 @@ archive_write_zip_header(struct archive_write *a, struct archive_entry *entry)
/* Determine appropriate compression and size for this entry. */
if (type == AE_IFLNK) {
symlink = archive_entry_symlink(zip->entry);
if (symlink != NULL)
symlink_size = strlen(symlink);
slink = archive_entry_symlink(zip->entry);
if (slink != NULL)
slink_size = strlen(slink);
else
symlink_size = 0;
zip->entry_uncompressed_limit = symlink_size;
zip->entry_compressed_size = symlink_size;
zip->entry_uncompressed_size = symlink_size;
slink_size = 0;
zip->entry_uncompressed_limit = slink_size;
zip->entry_compressed_size = slink_size;
zip->entry_uncompressed_size = slink_size;
zip->entry_crc32 = zip->crc32func(zip->entry_crc32,
(const unsigned char *)symlink, symlink_size);
(const unsigned char *)slink, slink_size);
zip->entry_compression = COMPRESSION_STORE;
version_needed = 20;
} else if (type != AE_IFREG) {
@ -742,13 +742,13 @@ archive_write_zip_header(struct archive_write *a, struct archive_entry *entry)
zip->written_bytes += e - local_extra;
/* For symlinks, write the body now. */
if (symlink != NULL) {
ret = __archive_write_output(a, symlink, (size_t)symlink_size);
if (slink != NULL) {
ret = __archive_write_output(a, slink, slink_size);
if (ret != ARCHIVE_OK)
return (ARCHIVE_FATAL);
zip->entry_compressed_written += symlink_size;
zip->entry_uncompressed_written += symlink_size;
zip->written_bytes += symlink_size;
zip->entry_compressed_written += slink_size;
zip->entry_uncompressed_written += slink_size;
zip->written_bytes += slink_size;
}
#ifdef HAVE_ZLIB_H