[pacman-dev] [RFC] libalpm: replace deprecated libarchive calls
Dave Reisner
d at falconindy.com
Mon Jan 28 14:08:59 EST 2013
On Mon, Jan 28, 2013 at 01:57:53PM -0500, Dave Reisner wrote:
> This raises our minimum libarchive version to 3.0.0, which is reflected
> by autoconf.
>
> Signed-off-by: Dave Reisner <dreisner at archlinux.org>
> ---
Bleh. This patch is wrong, but the RFC still stands.
> There's a soname bump with libarchive 3.1 (which no one in Arch Linux land has
> been brave enough to touch yet). Maybe this will help us get started. The test
> suite still passes, though there is a CPIO based failure in libarchive 3.1.1
> which should be dealt with separately.
>
> I mark this as an RFC since it's a library requirement bump. As an alternative,
> I propose that we could create a header, perhaps lib/libalpm/libarchive.h which
> has wrapper methods and preprocessor logic to Do The Right Thing™. Personally, I'd
> rather not get into this business.
>
> configure.ac | 4 ++--
> lib/libalpm/add.c | 6 +++---
> lib/libalpm/be_local.c | 6 +++---
> lib/libalpm/be_package.c | 10 +++++-----
> lib/libalpm/be_sync.c | 4 ++--
> lib/libalpm/util.c | 6 +++---
> 6 files changed, 18 insertions(+), 18 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index a7364ba..08af5a3 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -190,8 +190,8 @@ AC_CHECK_LIB([m], [fabs], ,
> AC_MSG_ERROR([libm is needed to compile pacman!]))
>
> # Check for libarchive
> -PKG_CHECK_MODULES(LIBARCHIVE, [libarchive >= 2.8.0], ,
> - AC_MSG_ERROR([*** libarchive >= 2.8.0 is needed to compile pacman!]))
> +PKG_CHECK_MODULES(LIBARCHIVE, [libarchive >= 3.0.0], ,
> + AC_MSG_ERROR([*** libarchive >= 3.0.0 is needed to compile pacman!]))
>
> # Check for OpenSSL
> have_openssl=no
> diff --git a/lib/libalpm/add.c b/lib/libalpm/add.c
> index 9b67813..7bdb032 100644
> --- a/lib/libalpm/add.c
> +++ b/lib/libalpm/add.c
> @@ -555,7 +555,7 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
> if(chdir(handle->root) != 0) {
> _alpm_log(handle, ALPM_LOG_ERROR, _("could not change directory to %s (%s)\n"),
> handle->root, strerror(errno));
> - archive_read_finish(archive);
> + archive_read_close(archive);
> CLOSE(fd);
> ret = -1;
> goto cleanup;
> @@ -577,7 +577,7 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
> /* Using compressed size for calculations here, as newpkg->isize is not
> * exact when it comes to comparing to the ACTUAL uncompressed size
> * (missing metadata sizes) */
> - int64_t pos = archive_position_compressed(archive);
> + int64_t pos = archive_filter_bytes(archive, -1);
> percent = (pos * 100) / newpkg->size;
> if(percent >= 100) {
> percent = 100;
> @@ -597,7 +597,7 @@ static int commit_single_pkg(alpm_handle_t *handle, alpm_pkg_t *newpkg,
> /* extract the next file from the archive */
> errors += extract_single_file(handle, archive, entry, newpkg, oldpkg);
> }
> - archive_read_finish(archive);
> + archive_read_close(archive);
> CLOSE(fd);
>
> /* restore the old cwd if we have it */
> diff --git a/lib/libalpm/be_local.c b/lib/libalpm/be_local.c
> index 0f60b6d..6c58920 100644
> --- a/lib/libalpm/be_local.c
> +++ b/lib/libalpm/be_local.c
> @@ -241,11 +241,11 @@ static struct archive *_cache_mtree_open(alpm_pkg_t *pkg)
> archive_read_support_filter_gzip(mtree);
> archive_read_support_format_mtree(mtree);
>
> - if((r = archive_read_open_file(mtree, mtfile, ALPM_BUFFER_SIZE))) {
> + if((r = archive_read_open_filename(mtree, mtfile, ALPM_BUFFER_SIZE))) {
> _alpm_log(pkg->handle, ALPM_LOG_ERROR, _("error while reading file %s: %s\n"),
> mtfile, archive_error_string(mtree));
> pkg->handle->pm_errno = ALPM_ERR_LIBARCHIVE;
> - archive_read_finish(mtree);
> + archive_read_close(mtree);
> goto error;
> }
>
> @@ -279,7 +279,7 @@ static int _cache_mtree_next(const alpm_pkg_t UNUSED *pkg,
> static int _cache_mtree_close(const alpm_pkg_t UNUSED *pkg,
> struct archive *mtree)
> {
> - return archive_read_finish(mtree);
> + return archive_read_close(mtree);
> }
>
> static int _cache_force_load(alpm_pkg_t *pkg)
> diff --git a/lib/libalpm/be_package.c b/lib/libalpm/be_package.c
> index 18fc14a..d920a76 100644
> --- a/lib/libalpm/be_package.c
> +++ b/lib/libalpm/be_package.c
> @@ -74,7 +74,7 @@ static void *_package_changelog_open(alpm_pkg_t *pkg)
> changelog = malloc(sizeof(struct package_changelog));
> if(!changelog) {
> pkg->handle->pm_errno = ALPM_ERR_MEMORY;
> - archive_read_finish(archive);
> + archive_read_close(archive);
> CLOSE(fd);
> return NULL;
> }
> @@ -84,7 +84,7 @@ static void *_package_changelog_open(alpm_pkg_t *pkg)
> }
> }
> /* we didn't find a changelog */
> - archive_read_finish(archive);
> + archive_read_close(archive);
> CLOSE(fd);
> errno = ENOENT;
>
> @@ -124,7 +124,7 @@ static int _package_changelog_close(const alpm_pkg_t UNUSED *pkg, void *fp)
> {
> int ret;
> struct package_changelog *changelog = fp;
> - ret = archive_read_finish(changelog->archive);
> + ret = archive_read_close(changelog->archive);
> CLOSE(changelog->fd);
> free(changelog);
> return ret;
> @@ -471,7 +471,7 @@ alpm_pkg_t *_alpm_pkg_load_internal(alpm_handle_t *handle,
> goto pkg_invalid;
> }
>
> - archive_read_finish(archive);
> + archive_read_close(archive);
> CLOSE(fd);
>
> /* internal fields for package struct */
> @@ -503,7 +503,7 @@ pkg_invalid:
> handle->pm_errno = ALPM_ERR_PKG_INVALID;
> error:
> _alpm_pkg_free(newpkg);
> - archive_read_finish(archive);
> + archive_read_close(archive);
> if(fd >= 0) {
> CLOSE(fd);
> }
> diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c
> index a5a2c10..77bfc1e 100644
> --- a/lib/libalpm/be_sync.c
> +++ b/lib/libalpm/be_sync.c
> @@ -383,7 +383,7 @@ static size_t estimate_package_count(struct stat *st, struct archive *archive)
> {
> int per_package;
>
> - switch(archive_compression(archive)) {
> + switch(archive_filter_code(archive, 0)) {
> case ARCHIVE_COMPRESSION_NONE:
> per_package = 3015;
> break;
> @@ -471,7 +471,7 @@ static int sync_db_populate(alpm_db_t *db)
> count, db->treename);
>
> cleanup:
> - archive_read_finish(archive);
> + archive_read_close(archive);
> if(fd >= 0) {
> CLOSE(fd);
> }
> diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
> index 5960be6..f2258d6 100644
> --- a/lib/libalpm/util.c
> +++ b/lib/libalpm/util.c
> @@ -240,7 +240,7 @@ int _alpm_open_archive(alpm_handle_t *handle, const char *path,
> RET_ERR(handle, ALPM_ERR_LIBARCHIVE, -1);
> }
>
> - archive_read_support_compression_all(*archive);
> + archive_read_support_filter_all(*archive);
> archive_read_support_format_all(*archive);
>
> _alpm_log(handle, ALPM_LOG_DEBUG, "opening archive %s\n", path);
> @@ -271,7 +271,7 @@ int _alpm_open_archive(alpm_handle_t *handle, const char *path,
> return fd;
>
> error:
> - archive_read_finish(*archive);
> + archive_read_close(*archive);
> *archive = NULL;
> if(fd >= 0) {
> CLOSE(fd);
> @@ -392,7 +392,7 @@ int _alpm_unpack(alpm_handle_t *handle, const char *path, const char *prefix,
>
> cleanup:
> umask(oldmask);
> - archive_read_finish(archive);
> + archive_read_close(archive);
> CLOSE(fd);
> if(cwdfd >= 0) {
> if(fchdir(cwdfd) != 0) {
> --
> 1.8.1.1
>
More information about the pacman-dev
mailing list