From patchwork Fri Mar 12 01:50:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Woodard X-Patchwork-Id: 42486 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 8BD133850414; Fri, 12 Mar 2021 01:51:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8BD133850414 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1615513892; bh=Q56rDu2zvjoQtr5dTwwrogyudvaLtg75Q+R4/JS1Bok=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Help: List-Subscribe:From:Reply-To:From; b=aSJmSktXw2iawTR1GUDJqB59awW7Q22U8R6EsARbwhV7o+2Wdvzc04pjQG4CbDxQV DC4YhF/zNc0DD058jhtrdYuUonpUPfc/ZuOPe7TGYHeb4Iz2kyGnAgJfzl2pviTtsZ 1/cRObBq1+F37gSTzjlIs+wbJZHDbxpaTbZJre6U= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id 2322E385802D for ; Fri, 12 Mar 2021 01:51:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2322E385802D Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-518-XvFB4FROMxm-xpHRkkAfjQ-1; Thu, 11 Mar 2021 20:51:21 -0500 X-MC-Unique: XvFB4FROMxm-xpHRkkAfjQ-1 Received: by mail-pf1-f198.google.com with SMTP id s18so13635769pfe.10 for ; Thu, 11 Mar 2021 17:51:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Q56rDu2zvjoQtr5dTwwrogyudvaLtg75Q+R4/JS1Bok=; b=bU/jLdGygFgSwprGJMxUdiBUWd+jY58MYg2Pmy8CZDNbu7TY6yKw48klFSGmrn+j1+ QDbKnRL2Gn6kX5JTSdXx7f19xP+h1TSAd6Vh6CN6/1LBQfl6MYB4q+Fzh3ncFK+LNIlr v4MHmgWPGcf6Hz0NO/jC9sAbwmJjCQxz0J4/s0mecddcHDfcBoQmjyeyRY3fvHZvrAKP AnzXnyAPwRZl3x0zXq6bK8ddrQgOseSEqabBwlZaW9yNONbFoVMRJE3Nr8Wqtn1puRGI m+1Gjb5C8xccXw1/HbiscsV8TjFbiQjpZxfqSqtH38HWq56KSWlt2urREg3aZQUlvXJB 264g== X-Gm-Message-State: AOAM5313uGWrsbspVxTnxDVgZ098jIAbTqEqfsIWybnxCA9dVg9ttAdr mMq5Bd3Bl+iE4keZAk+zqcVk2nxA1w2kXt3djmHxDSsmwWYX8E+gpykJiie0dByuf+07pwRRBAO Jmzd5X9quTqAv/KxlIsx/QiGL4hHwQkcsM+di1qHYcymyxmrxx57yeNijKeIpZiMeH//zOsE= X-Received: by 2002:a17:90a:ce03:: with SMTP id f3mr11643890pju.195.1615513878806; Thu, 11 Mar 2021 17:51:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJw5s/zqtIzC8DpVnKAtLDml3NgtVvvs/GOn5/pnUPvSIqmkp5coWfxd9sX7OZZH3rET36HoGQ== X-Received: by 2002:a17:90a:ce03:: with SMTP id f3mr11643821pju.195.1615513877676; Thu, 11 Mar 2021 17:51:17 -0800 (PST) Received: from alien.localdomain (47-208-193-143.trckcmtc01.res.dyn.suddenlink.net. [47.208.193.143]) by smtp.gmail.com with ESMTPSA id y7sm313538pja.25.2021.03.11.17.51.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Mar 2021 17:51:16 -0800 (PST) To: libabigail@sourceware.org Subject: [PATCH] Bug 27512 Remove broken zip-archive support Date: Thu, 11 Mar 2021 17:50:44 -0800 Message-Id: <20210312015044.81428-1-woodard@redhat.com> X-Mailer: git-send-email 2.30.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libabigail@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list of the Libabigail project List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Ben Woodard via Libabigail From: Ben Woodard Reply-To: Ben Woodard Errors-To: libabigail-bounces@sourceware.org Sender: "Libabigail" The optional zip archive feature was broken when with the commit b2e5366d3 when the environment code was introduced back in 2015. Since it wouldn't even compile and nobody even seemed to notice, we are fairly sure nobody was using that feature. Therefore, we decided to remove it rather than fix it. * configure.ac: remove --enable-zip-archive option and logic associated with it. * remove include/abg-libzip-utils.h * remove src/abg-libzip-utils.cc * include/Makefile.am: remove reference to include/abg-libzip-utils.h that no longer exists. * src/Makefile.am: remove reference to src/abg-libzip-utils.cc that no longer exists. * relicensing-scripts/file-licenses.orig.txt: remove references to files that no longer exist. * relicensing-scripts/files-with-lgplv3.txt: remove references to files that no longer exist. * remove tests/test-dot.cc because it tests code that no longer exists. * remove tests/test-write-read-archive.cc because it tests code that no longer exists. * tests/Makefile.am: remove reference to tests that no longer exist. * include/abg-reader.h: remove conditionally compiled code for zip archives. * include/abg-tools-utils.h: remove conditionally compiled code for zip archives. * src/abg-corpus.cc: remove conditionally compiled code for zip archives. * src/abg-reader.cc: remove conditionally compiled code for zip archives. * src/abg-tools-utils.cc: remove conditionally compiled code for zip archives. * src/abg-writer.cc: remove conditionally compiled code for zip archives. * tools/abidiff.cc: remove conditionally compiled code for zip archives. * tools/abilint.cc: remove conditionally compiled code for zip archives. * remove abiar: this tool only applied to zip archives. * tools/Makefile.am: remove references to abiar a utility that no longer has a reason for existing. Signed-off-by: Ben Woodard --- configure.ac | 54 +--- include/Makefile.am | 1 - include/abg-libzip-utils.h | 61 ---- include/abg-reader.h | 12 - include/abg-tools-utils.h | 3 - relicensing-scripts/file-licenses.orig.txt | 2 - relicensing-scripts/files-with-lgplv3.txt | 2 - src/Makefile.am | 1 - src/abg-corpus.cc | 11 - src/abg-libzip-utils.cc | 68 ----- src/abg-reader.cc | 154 ---------- src/abg-tools-utils.cc | 9 - src/abg-writer.cc | 202 ------------- tests/Makefile.am | 14 +- tests/test-dot.cc | 58 ---- tests/test-write-read-archive.cc | 178 ------------ tools/Makefile.am | 12 +- tools/abiar.cc | 319 --------------------- tools/abidiff.cc | 14 - tools/abilint.cc | 18 +- 20 files changed, 5 insertions(+), 1188 deletions(-) delete mode 100644 include/abg-libzip-utils.h delete mode 100644 src/abg-libzip-utils.cc delete mode 100644 tests/test-dot.cc delete mode 100644 tests/test-write-read-archive.cc delete mode 100644 tools/abiar.cc diff --git a/configure.ac b/configure.ac index b9f59c86..495460bf 100644 --- a/configure.ac +++ b/configure.ac @@ -78,13 +78,6 @@ AC_ARG_ENABLE(tar, ENABLE_TAR=$enableval, ENABLE_TAR=auto) -AC_ARG_ENABLE(zip-archive, - AS_HELP_STRING([--enable-zip-archive=yes|no|auto], - [enable bundling of TUs in zip archives (default is no)]), - ENABLE_ZIP_ARCHIVE=$enableval, - ENABLE_ZIP_ARCHIVE=no) - - AC_ARG_ENABLE(apidoc, AS_HELP_STRING([--enable-apidoc=yes|no|auto], [enable generation of the apidoc in html]), @@ -542,49 +535,7 @@ AM_CONDITIONAL(ENABLE_RUNNING_TESTS_WITH_PY3, test x$RUN_TESTS_WITH_PY3 = xyes) AM_CONDITIONAL(ENABLE_PYTHON3_INTERPRETER, test x$PYTHON3_INTERPRETER != xno) AC_SUBST(PYTHON) -dnl Check for dependency: libzip -LIBZIP_VERSION=0.10.1 - -HAS_LIBZIP=no -# The below doesn't seem to work on my box for a reason. Let's write -# the damn thing by hand: -# PKG_CHECK_EXISTS([libzip >= $LIBZIP_VERSION], [HAS_LIBZIP=yes], [HAS_LIBZIP=no]) - -if $PKG_CONFIG --exists --print-errors "libzip >= $LIBZIP_VERSION"; then - AC_MSG_NOTICE(found libzip version $LIBZIP_VERSION) - HAS_LIBZIP=yes -else - AC_MSG_NOTICE(no libzip >= $LIBZIP_VERSION has been found) - HAS_LIBZIP=no -fi - -if test x$ENABLE_ZIP_ARCHIVE = xauto; then - if test x$HAS_LIBZIP = xyes; then - ENABLE_ZIP_ARCHIVE=yes; - else - ENABLE_ZIP_ARCHIVE=no - fi -fi - -if test x$ENABLE_ZIP_ARCHIVE = xyes; then - AC_MSG_NOTICE(the zip-archive feature is enabled) -else - AC_MSG_NOTICE(the zip-archive feature is disabled) -fi - -FOUND_LIBZIP=no -if test x$ENABLE_ZIP_ARCHIVE = xyes; then - PKG_CHECK_MODULES(LIBZIP, libzip >= $LIBZIP_VERSION) - FOUND_LIBZIP=yes - AC_SUBST(LIBZIP_VERSION) - AC_SUBST(LIBZIP_LIBS) - AC_SUBST(LIBZIP_CFLAGS) - AC_DEFINE([WITH_ZIP_ARCHIVE], 1, [compile the zip archive support]) - AC_DEFINE([HAVE_LIBZIP], 1, [Defined to 1 if the libzip library is available]) -fi - -AM_CONDITIONAL(ENABLE_ZIP_ARCHIVE, test x$ENABLE_ZIP_ARCHIVE = xyes) -DEPS_CPPFLAGS="$XML_CFLAGS $LIBZIP_CFLAGS" +DEPS_CPPFLAGS="$XML_CFLAGS" AC_SUBST(DEPS_CPPFLAGS) dnl Check for the presence of doxygen program @@ -626,7 +577,7 @@ AX_VALGRIND_CHECK dnl Set the list of libraries libabigail depends on -DEPS_LIBS="$XML_LIBS $LIBZIP_LIBS $ELF_LIBS $DW_LIBS" +DEPS_LIBS="$XML_LIBS $ELF_LIBS $DW_LIBS" AC_SUBST(DEPS_LIBS) if test x$ABIGAIL_DEVEL != x; then @@ -959,7 +910,6 @@ AC_MSG_NOTICE([ Python : ${PYTHON} OPTIONAL FEATURES: - Enable zip archives : ${ENABLE_ZIP_ARCHIVE} C++ standard level : ${CXX_STANDARD} libdw has the dwarf_getalt function : ${FOUND_DWARF_GETALT_IN_LIBDW} Enable rpm support in abipkgdiff : ${ENABLE_RPM} diff --git a/include/Makefile.am b/include/Makefile.am index 1a4b64c9..0f3b0936 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -13,7 +13,6 @@ abg-suppression.h \ abg-comp-filter.h \ abg-diff-utils.h \ abg-libxml-utils.h \ -abg-libzip-utils.h \ abg-fwd.h \ abg-hash.h \ abg-tools-utils.h \ diff --git a/include/abg-libzip-utils.h b/include/abg-libzip-utils.h deleted file mode 100644 index dc431d18..00000000 --- a/include/abg-libzip-utils.h +++ /dev/null @@ -1,61 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -*- mode: C++ -*- -// -// Copyright (C) 2013-2020 Red Hat, Inc. - -/// @file - -#ifndef __ABG_LIBZIP_UTILS_H__ -#define __ABG_LIBZIP_UTILS_H__ - -#include -#include - -namespace abigail -{ - -namespace zip_utils -{ - -using std::shared_ptr; -using std::string; - -/// @brief Functor passed to shared_ptr constructor during -/// instantiation with zip* -/// -/// Its aim is to delete zip* managed by shared_ptr. -struct archive_deleter -{ - void - operator()(zip* archive) - { - /// ??? Maybe check the return code of close and throw if the - /// close fails? But then callers must be prepared to handle - /// this. - zip_close(archive); - } -};//end archive_deleter - -/// @brief Functor passed to shared_ptr's constructor. -/// -/// Its aim is to close (actually delete) the zip_file* managed by the -/// shared_ptr. -struct zip_file_deleter -{ - void - operator()(zip_file*f) - { - zip_fclose(f); - } -}; - -typedef shared_ptr zip_sptr; -zip_sptr open_archive(const string& path, int flags, int *errorp); - -typedef shared_ptr zip_file_sptr; -zip_file_sptr open_file_in_archive(zip_sptr archive, - int file_index); - -}// end namespace zip -}// end namespace abigail -#endif //__ABG_LIBZIP_UTILS_H__ diff --git a/include/abg-reader.h b/include/abg-reader.h index f1408912..b86afcf8 100644 --- a/include/abg-reader.h +++ b/include/abg-reader.h @@ -52,18 +52,6 @@ create_native_xml_read_context(std::istream* in, environment* env); const string& read_context_get_path(const read_context&); -#ifdef WITH_ZIP_ARCHIVE -corpus_sptr -read_corpus_from_file(const string& path); - -int -read_corpus_from_file(corpus_sptr& corp, - const string& path); - -int -read_corpus_from_file(corpus_sptr& corp); -#endif //WITH_ZIP_ARCHIVE - corpus_sptr read_corpus_from_native_xml(std::istream* in, environment* env); diff --git a/include/abg-tools-utils.h b/include/abg-tools-utils.h index 053f8795..712aa34b 100644 --- a/include/abg-tools-utils.h +++ b/include/abg-tools-utils.h @@ -180,9 +180,6 @@ enum file_type // A native abixml file format representing a corpus group of one or // several corpora. FILE_TYPE_XML_CORPUS_GROUP, - // A zip file, possibly containing a corpus of one of several - // translation units. - FILE_TYPE_ZIP_CORPUS, /// An RPM (.rpm) binary file FILE_TYPE_RPM, /// An SRPM (.src.rpm) file diff --git a/relicensing-scripts/file-licenses.orig.txt b/relicensing-scripts/file-licenses.orig.txt index ab4c8a98..9d9e17d8 100644 --- a/relicensing-scripts/file-licenses.orig.txt +++ b/relicensing-scripts/file-licenses.orig.txt @@ -26,7 +26,6 @@ ./include/abg-interned-str.h:1:// SPDX-License-Identifier: LGPL-3.0-or-later ./include/abg-ir.h:1:// SPDX-License-Identifier: LGPL-3.0-or-later ./include/abg-libxml-utils.h:1:// SPDX-License-Identifier: LGPL-3.0-or-later -./include/abg-libzip-utils.h:1:// SPDX-License-Identifier: LGPL-3.0-or-later ./include/abg-regex.h:1:// SPDX-License-Identifier: LGPL-3.0-or-later ./include/abg-reporter.h:1:// SPDX-License-Identifier: LGPL-3.0-or-later ./include/abg-sptr-utils.h:1:// SPDX-License-Identifier: LGPL-3.0-or-later @@ -57,7 +56,6 @@ ./src/abg-internal.h:1:// SPDX-License-Identifier: LGPL-3.0-or-later ./src/abg-ir-priv.h:1:// SPDX-License-Identifier: LGPL-3.0-or-later ./src/abg-leaf-reporter.cc:1:// SPDX-License-Identifier: LGPL-3.0-or-later -./src/abg-libzip-utils.cc:1:// SPDX-License-Identifier: LGPL-3.0-or-later ./src/abg-reporter-priv.cc:1:// SPDX-License-Identifier: LGPL-3.0-or-later ./src/abg-suppression-priv.h:1:// SPDX-License-Identifier: LGPL-3.0-or-later ./src/abg-viz-svg.cc:1:// SPDX-License-Identifier: LGPL-3.0-or-later diff --git a/relicensing-scripts/files-with-lgplv3.txt b/relicensing-scripts/files-with-lgplv3.txt index 323d5b17..4ab8364b 100644 --- a/relicensing-scripts/files-with-lgplv3.txt +++ b/relicensing-scripts/files-with-lgplv3.txt @@ -25,7 +25,6 @@ ./include/abg-interned-str.h ./include/abg-ir.h ./include/abg-libxml-utils.h -./include/abg-libzip-utils.h ./include/abg-regex.h ./include/abg-reporter.h ./include/abg-sptr-utils.h @@ -56,7 +55,6 @@ ./src/abg-internal.h ./src/abg-ir-priv.h ./src/abg-leaf-reporter.cc -./src/abg-libzip-utils.cc ./src/abg-reporter-priv.cc ./src/abg-suppression-priv.h ./src/abg-viz-svg.cc diff --git a/src/Makefile.am b/src/Makefile.am index 86877635..430ce98d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -28,7 +28,6 @@ abg-comp-filter.cc \ abg-reader.cc \ abg-dwarf-reader.cc \ abg-libxml-utils.cc \ -abg-libzip-utils.cc \ abg-hash.cc \ abg-writer.cc \ abg-config.cc \ diff --git a/src/abg-corpus.cc b/src/abg-corpus.cc index 4e445e88..9c344287 100644 --- a/src/abg-corpus.cc +++ b/src/abg-corpus.cc @@ -26,10 +26,6 @@ ABG_BEGIN_EXPORT_DECLARATIONS #include "abg-tools-utils.h" #include "abg-writer.h" -#if WITH_ZIP_ARCHIVE -#include "abg-libzip-utils.h" -#endif - ABG_END_EXPORT_DECLARATIONS // @@ -47,13 +43,6 @@ using std::unordered_map; using std::list; using std::vector; -#if WITH_ZIP_ARCHIVE -using zip_utils::zip_sptr; -using zip_utils::zip_file_sptr; -using zip_utils::open_archive; -using zip_utils::open_file_in_archive; -#endif // WITH_ZIP_ARCHIVE - using regex::regex_t_sptr; /// Constructor of @ref corpus::exported_decls_builder. diff --git a/src/abg-libzip-utils.cc b/src/abg-libzip-utils.cc deleted file mode 100644 index c56754a1..00000000 --- a/src/abg-libzip-utils.cc +++ /dev/null @@ -1,68 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -*- mode: C++ -*- -// -// Copyright (C) 2013-2020 Red Hat, Inc. - -/// @file - -#include "abg-internal.h" -#ifdef WITH_ZIP_ARCHIVE -// -ABG_BEGIN_EXPORT_DECLARATIONS - -#include "abg-libzip-utils.h" - -ABG_END_EXPORT_DECLARATIONS -// - -#include -namespace abigail -{ - -namespace zip_utils -{ - -/// This is a wrapper of the zip_open function, from libzip. Its -/// purpose is to return a zip pointer wrapped in an appropriate -/// shared_ptr and thus to free the caller from having to deal with -/// calling zip_close on it. -/// -/// The arguments this wrapper have the same meaning as in zip_open. -/// -/// @param path the path to the zip archive to open. -/// -/// @return a non-null zip pointer if the function succeeds. -zip_sptr -open_archive(const string& path, int flags, int *errorp) -{ - zip* z = zip_open(path.c_str(), flags, errorp); - if (!z) - return zip_sptr(); - return zip_sptr(z, archive_deleter()); -} - -/// @brief Open a file from a zip archive. -/// -/// Open the file that is at a given \a index in the \a archive. -/// -/// @param archive the zip archive to consider -/// -/// @param file_index the index of the file to open from the zip -/// \a archive. -/// -/// @return a non-null zip_file* upon successful completion, a null -/// pointer otherwise. -zip_file_sptr -open_file_in_archive(zip_sptr archive, - int file_index) -{ - zip_file * f = zip_fopen_index(archive.get(), file_index, 0); - if (!f) - return zip_file_sptr(); - return zip_file_sptr(f, zip_file_deleter()); -} - -}// end namespace zip -}// end namespace abigail - -#endif //WITH_ZIP_ARCHIVE diff --git a/src/abg-reader.cc b/src/abg-reader.cc index 3e552864..9d229e62 100644 --- a/src/abg-reader.cc +++ b/src/abg-reader.cc @@ -34,10 +34,6 @@ ABG_BEGIN_EXPORT_DECLARATIONS #include "abg-reader.h" #include "abg-corpus.h" -#ifdef WITH_ZIP_ARCHIVE -#include "abg-libzip-utils.h" -#endif - ABG_END_EXPORT_DECLARATIONS // @@ -56,12 +52,6 @@ using std::unordered_map; using std::dynamic_pointer_cast; using std::vector; using std::istream; -#ifdef WITH_ZIP_ARCHIVE -using zip_utils::zip_sptr; -using zip_utils::zip_file_sptr; -using zip_utils::open_archive; -using zip_utils::open_file_in_archive; -#endif //WITH_ZIP_ARCHIVE static bool read_is_declaration_only(xmlNodePtr, bool&); static bool read_is_artificial(xmlNodePtr, bool&); @@ -5832,150 +5822,6 @@ struct array_deleter } };//end array_deleter -#ifdef WITH_ZIP_ARCHIVE -/// Deserialize an ABI Instrumentation XML file at a given index in a -/// zip archive, and populate a given @ref translation_unit object -/// with the result of that de-serialization. -/// -/// @param the @ref translation_unit to populate with the result of -/// the de-serialization. -/// -/// @param ar the zip archive to read from. -/// -/// @param file_index the index of the ABI Instrumentation XML file to -/// read from the zip archive. -/// -/// @return true upon successful completion, false otherwise. -static translation_unit_sptr -read_to_translation_unit(zip_sptr ar, - int file_index) -{ - translation_unit_sptr nil; - if (!ar) - return nil; - - zip_file_sptr f = open_file_in_archive(ar, file_index); - if (!f) - return nil; - - string input; - { - // Allocate a 64K byte buffer to read the archive. - int buf_size = 64 * 1024; - shared_ptr buf(new char[buf_size + 1], array_deleter()); - memset(buf.get(), 0, buf_size + 1); - input.reserve(buf_size); - - while (zip_fread(f.get(), buf.get(), buf_size)) - { - input.append(buf.get()); - memset(buf.get(), 0, buf_size + 1); - } - } - - return read_translation_unit_from_buffer(input); -} - -/// Read an ABI corpus from an archive file which is a ZIP archive of -/// several ABI Instrumentation XML files. -/// -/// @param ar an object representing the archive file. -/// -/// @param corp the ABI Corpus object to populate with the content of -/// the archive @ref ar. -/// -/// @return the number of ABI Instrumentation file read from the -/// archive. -static int -read_corpus_from_archive(zip_sptr ar, - corpus_sptr& corp) -{ - if (!ar) - return -1; - - int nb_of_tu_read = 0; - int nb_entries = zip_get_num_entries(ar.get(), 0); - if (nb_entries < 0) - return -1; - - // TODO: ensure abi-info descriptor is present in the archive. Read - // it and ensure that version numbers match. - for (int i = 0; i < nb_entries; ++i) - { - shared_ptr - tu(new translation_unit(zip_get_name(ar.get(), i, 0))); - if (read_to_translation_unit(*tu, ar, i)) - { - if (!corp) - corp.reset(new corpus("")); - corp->add(tu); - ++nb_of_tu_read; - } - } - if (nb_of_tu_read) - corp->set_origin(corpus::NATIVE_XML_ORIGIN); - return nb_of_tu_read; -} - -/// Read an ABI corpus from an archive file which is a ZIP archive of -/// several ABI Instrumentation XML files. -/// -/// @param corp the corpus to populate with the result of reading the -/// archive. -/// -/// @param path the path to the archive file. -/// -/// @return the number of ABI Instrument XML file read from the -/// archive, or -1 if the file could not read. -int -read_corpus_from_file(corpus_sptr& corp, - const string& path) -{ - if (path.empty()) - return -1; - - int error_code = 0; - zip_sptr archive = open_archive(path, ZIP_CREATE|ZIP_CHECKCONS, &error_code); - if (error_code) - return -1; - - ABG_ASSERT(archive); - return read_corpus_from_archive(archive, corp); -} - -/// Read an ABI corpus from an archive file which is a ZIP archive of -/// several ABI Instrumentation XML files. -/// -/// @param corp the corpus to populate with the result of reading the -/// archive. The archive file to consider is corp.get_path(). -/// -/// @return the number of ABI Instrument XML file read from the -/// archive. -int -read_corpus_from_file(corpus_sptr& corp) -{return read_corpus_from_file(corp, corp->get_path());} - -/// Read an ABI corpus from an archive file which is a ZIP archive of -/// several ABI Instrumentation XML files. -/// -/// @param path the path to the archive file. -/// -/// @return the resulting corpus object, or NULL if the file could not -/// be read. -corpus_sptr -read_corpus_from_file(const string& path) -{ - if (path.empty()) - return corpus_sptr(); - - corpus_sptr corp(new corpus(path)); - if (read_corpus_from_file(corp, path) < 0) - return corpus_sptr(); - - return corp; -} - -#endif //WITH_ZIP_ARCHIVE /// Create an xml_reader::read_context to read a native XML ABI file. /// diff --git a/src/abg-tools-utils.cc b/src/abg-tools-utils.cc index 4d019132..d6cc8ef4 100644 --- a/src/abg-tools-utils.cc +++ b/src/abg-tools-utils.cc @@ -1333,9 +1333,6 @@ operator<<(ostream& output, case FILE_TYPE_XML_CORPUS_GROUP: repr = "native XML corpus group file type"; break; - case FILE_TYPE_ZIP_CORPUS: - repr = "native ZIP corpus file type"; - break; case FILE_TYPE_RPM: repr = "RPM file type"; break; @@ -1445,12 +1442,6 @@ guess_file_type(istream& in) && buf[11] == ' ') return FILE_TYPE_XML_CORPUS; - if (buf[0] == 'P' - && buf[1] == 'K' - && buf[2] == 0x03 - && buf[3] == 0x04) - return FILE_TYPE_ZIP_CORPUS; - if ((unsigned char) buf[0] == 0xed && (unsigned char) buf[1] == 0xab && (unsigned char) buf[2] == 0xee diff --git a/src/abg-writer.cc b/src/abg-writer.cc index a8959314..1db74a79 100644 --- a/src/abg-writer.cc +++ b/src/abg-writer.cc @@ -34,10 +34,6 @@ ABG_BEGIN_EXPORT_DECLARATIONS #include "abg-hash.h" #include "abg-sptr-utils.h" -#if WITH_ZIP_ARCHIVE -#include "abg-libzip-utils.h" -#endif - #include "abg-writer.h" #include "abg-libxml-utils.h" @@ -59,13 +55,6 @@ using std::stack; using std::unordered_map; using abigail::sptr_utils::noop_deleter; -#if WITH_ZIP_ARCHIVE -using zip_utils::zip_sptr; -using zip_utils::zip_file_sptr; -using zip_utils::open_archive; -using zip_utils::open_file_in_archive; -#endif // WITH_ZIP_ARCHIVE - /// The namespace for the native XML file format writer. /// /// It contains utilities to serialize ABI artifacts from the @ref ir @@ -4284,197 +4273,6 @@ write_class_tdecl(const shared_ptr decl, return true; } -#ifdef WITH_ZIP_ARCHIVE - -/// A context used by functions that write a corpus out to disk in a -/// ZIP archive of ABI Instrumentation XML files. -/// -/// The aim of this context file is to hold the buffers of data that -/// are to be written into a given zip object, until the zip object is -/// closed. It's at that point that the buffers data is really -/// flushed into the zip archive. -/// -/// When an instance of this context type is created for a given zip -/// object, is created, its life time should be longer than the @ref -/// zip_sptr object it holds. -/// -/// The definition of this type is private and should remain hidden -/// from client code. -struct archive_write_ctxt -{ - list serialized_tus; - zip_sptr archive; - - archive_write_ctxt(zip_sptr ar) - : archive(ar) - {} -}; -typedef shared_ptr archive_write_ctxt_sptr; - -/// Create a write context to a given archive. The result of this -/// function is to be passed to the functions that are to write a -/// corpus to an archive, e.g, write_corpus_to_archive(). -/// -/// @param archive_path the path to the archive to create this write -/// context for. -/// -/// @return the resulting write context to pass to the functions that -/// are to write a corpus to @ref archive_path. -static archive_write_ctxt_sptr -create_archive_write_context(const string& archive_path) -{ - if (archive_path.empty()) - return archive_write_ctxt_sptr(); - - int error_code = 0; - zip_sptr archive = open_archive(archive_path, - ZIP_CREATE|ZIP_TRUNCATE|ZIP_CHECKCONS, - &error_code); - if (error_code) - return archive_write_ctxt_sptr(); - - archive_write_ctxt_sptr r(new archive_write_ctxt(archive)); - return r; -} - -/// Write a translation unit to an on-disk archive. The archive is a -/// zip archive of ABI Instrumentation files in XML format. -/// -/// @param tu the translation unit to serialize. -/// -/// @param ctxt the context of the serialization. Contains -/// information about where the archive is on disk, the zip archive, -/// and the buffers holding the temporary data to be flushed into the archive. -/// -/// @param annotate whether ABIXML output should be annotated. -/// -/// @return true upon succesful serialization occured, false -/// otherwise. -static bool -write_translation_unit_to_archive(const translation_unit& tu, - archive_write_ctxt& ctxt, - const bool annotate) -{ - if (!ctxt.archive) - return false; - - ostringstream os; - if (!write_translation_unit(tu, /*indent=*/0, os, annotate)) - return false; - ctxt.serialized_tus.push_back(os.str()); - - zip_source *source; - if ((source = zip_source_buffer(ctxt.archive.get(), - ctxt.serialized_tus.back().c_str(), - ctxt.serialized_tus.back().size(), - false)) == 0) - return false; - - if (zip_file_add(ctxt.archive.get(), tu.get_path().c_str(), source, - ZIP_FL_OVERWRITE|ZIP_FL_ENC_GUESS) < 0) - { - zip_source_free(source); - return false; - } - - return true; -} - - /// Serialize a given corpus to disk in a file at a given path. - /// - /// @param tu the translation unit to serialize. - /// - /// @param ctxt the context of the serialization. Contains - /// information about where the archive is on disk, the zip archive - /// object, and the buffers holding the temporary data to be flushed - /// into the archive. - /// - /// @param annotate whether ABIXML output should be annotated. - /// - /// @return true upon successful completion, false otherwise. -static bool -write_corpus_to_archive(const corpus& corp, - archive_write_ctxt& ctxt, - const bool annotate) -{ - for (translation_units::const_iterator i = - corp.get_translation_units().begin(); - i != corp.get_translation_units().end(); - ++i) - { - if (! write_translation_unit_to_archive(**i, ctxt, annotate)) - return false; - } - - // TODO: ensure abi-info descriptor is added to the archive. - return true; -} - -/// Serialize a given corpus to disk in an archive file at a given -/// path. -/// -/// @param corp the ABI corpus to serialize. -/// - /// @param ctxt the context of the serialization. Contains - /// information about where the archive is on disk, the zip archive - /// object, and the buffers holding the temporary data to be flushed - /// into the archive. - /// - /// @param annotate whether ABIXML output should be annotated. - /// - /// @return upon successful completion, false otherwise. -static bool -write_corpus_to_archive(const corpus& corp, - archive_write_ctxt_sptr ctxt, - const bool annotate) -{return write_corpus_to_archive(corp, *ctxt, annotate);} - - /// Serialize the current corpus to disk in a file at a given path. - /// - /// @param tu the translation unit to serialize. - /// - /// @param path the path of the file to serialize the - /// translation_unit to. - /// - /// @param annotate whether ABIXML output should be annotated. - /// - /// @return true upon successful completion, false otherwise. -bool -write_corpus_to_archive(const corpus& corp, - const string& path, - const bool annotate) -{ - archive_write_ctxt_sptr ctxt = create_archive_write_context(path); - ABG_ASSERT(ctxt); - return write_corpus_to_archive(corp, ctxt, annotate); -} - - /// Serialize the current corpus to disk in a file. The file path is - /// given by translation_unit::get_path(). - /// - /// @param tu the translation unit to serialize. - /// - /// @param annotate whether ABIXML output should be annotated. - /// - /// @return true upon successful completion, false otherwise. -bool -write_corpus_to_archive(const corpus& corp, const bool annotate) -{return write_corpus_to_archive(corp, corp.get_path(), annotate);} - - /// Serialize the current corpus to disk in a file. The file path is - /// given by translation_unit::get_path(). - /// - /// @param tu the translation unit to serialize. - /// - /// @param annotate whether ABIXML output should be annotated. - /// - /// @return true upon successful completion, false otherwise. -bool -write_corpus_to_archive(const corpus_sptr corp, const bool annotate) -{return write_corpus_to_archive(*corp, annotate);} - -#endif //WITH_ZIP_ARCHIVE - /// Serialize the current version number of the ABIXML format. /// /// @param ctxt the writing context to use. diff --git a/tests/Makefile.am b/tests/Makefile.am index 533cc236..e3855aea 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,11 +1,6 @@ ## SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception SUBDIRS = data -ZIP_ARCHIVE_TESTS = -if ENABLE_ZIP_ARCHIVE -ZIP_ARCHIVE_TESTS += runtestwritereadarchive runtestdot -endif - AM_CXXFLAGS = $(VISIBILITY_FLAGS) FEDABIPKGDIFF_TEST = @@ -49,8 +44,7 @@ runtestsymtab \ runtestsymtabreader \ runtesttoolsutils \ runtestsvg \ -$(FEDABIPKGDIFF_TEST) \ -$(ZIP_ARCHIVE_TESTS) +$(FEDABIPKGDIFF_TEST) if ENABLE_RUNNING_TESTS_WITH_PY3 @@ -93,9 +87,6 @@ libcatch_la_SOURCES = lib/catch.cc lib/catch.hpp runtestreadwrite_SOURCES=test-read-write.cc runtestreadwrite_LDADD=libtestutils.la $(top_builddir)/src/libabigail.la -runtestwritereadarchive_SOURCES=test-write-read-archive.cc -runtestwritereadarchive_LDADD= libtestutils.la $(top_builddir)/src/libabigail.la - runtestreaddwarf_SOURCES=test-read-dwarf.cc runtestreaddwarf_LDADD=libtestutils.la $(top_builddir)/src/libabigail.la runtestreaddwarf_LDFLAGS=-pthread @@ -163,9 +154,6 @@ runtestsymtabreader_LDADD = libcatch.la $(top_builddir)/src/libabigail.la runtestsvg_SOURCES=test-svg.cc runtestsvg_LDADD=$(top_builddir)/src/libabigail.la -runtestdot_SOURCES = test-dot.cc -runtestdot_LDADD = $(top_builddir)/src/libabigail.la - testirwalker_SOURCES=test-ir-walker.cc testirwalker_LDADD=$(top_builddir)/src/libabigail.la diff --git a/tests/test-dot.cc b/tests/test-dot.cc deleted file mode 100644 index 0906c1d3..00000000 --- a/tests/test-dot.cc +++ /dev/null @@ -1,58 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -*- mode: C++ -*- -// -// Copyright (C) 2013-2019 Red Hat, Inc. - -#include "abg-viz-dot.h" - -int main() -{ - using namespace abigail; - - // sa-base - { - dot obj("sa-base"); - parent_node p("base"); - obj.start(); - obj.add_parent(p); - obj.finish(); - } - - - // sa-A - { - dot obj("sa-A"); - parent_node p("base"); - child_node c1("A"); - obj.start(); - obj.add_parent(p); - obj.add_child_to_node(c1, p); - obj.finish(); - } - - // sa-B - { - dot obj("sa-B"); - parent_node p("base"); - child_node c1("B"); - obj.start(); - obj.add_parent(p); - obj.add_child_to_node(c1, p); - obj.finish(); - } - - // sa-D1 - { - dot obj("sa-D1"); - parent_node p("base"); - child_node c1("A"); - child_node c2("D1"); - obj.start(); - obj.add_parent(p); - obj.add_child_to_node(c1, p); - obj.add_child_to_node(c2, c1); - obj.finish(); - } - - return 0; -} diff --git a/tests/test-write-read-archive.cc b/tests/test-write-read-archive.cc deleted file mode 100644 index dd16586f..00000000 --- a/tests/test-write-read-archive.cc +++ /dev/null @@ -1,178 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -*- Mode: C++ -*- -// -// Copyright (C) 2013-2020 Red Hat, Inc. - -#include -#include -#include -#include -#include "test-utils.h" -#include "abg-ir.h" -#include "abg-corpus.h" -#include "abg-tools-utils.h" -#include "abg-reader.h" -#include "abg-writer.h" - -struct InOutSpec -{ - const char* in_path; - const char* out_path; -};// end struct InOutSpec - -/// This is an aggregate that specifies where the test gets the -/// elements that it reads to build an archive. It also specifies -/// where to write the output result of the element that is written -/// back to disk, for diffing purposes. -InOutSpec archive_elements[] = -{ - { - "data/test-write-read-archive/test0.xml", - "output/test-write-read-archive/test0.xml", - }, - { - "data/test-write-read-archive/test1.xml", - "output/test-write-read-archive/test2.xml", - }, - { - "data/test-write-read-archive/test2.xml", - "output/test-write-read-archive/test2.xml", - }, - { - "data/test-write-read-archive/test3.xml", - "output/test-write-read-archive/test3.xml", - }, - { - "data/test-write-read-archive/test4.xml", - "output/test-write-read-archive/test4.xml", - }, - // This should be the last entry. - {NULL, NULL} -}; - -#define NUM_ARCHIVES_ELEMENTS \ - ((sizeof(archive_elements) / sizeof(InOutSpec)) -1) - -/// Where to write the archive, and where to read it from to get the -/// base for the diffing. -const InOutSpec archive_spec = -{ - "data/test-write-read-archive/archive.abi", - "output/test-write-read-archive/archive.abi" -}; - -using std::string; -using std::cerr; -using std::ofstream; -using std::shared_ptr; -using abigail::corpus; -using abigail::corpus_sptr; -using abigail::translation_unit; -using abigail::xml_reader::read_corpus_from_file; -using abigail::xml_writer::write_corpus_to_archive; - -int -main() -{ - // Read the elements into abigail::translation_unit and stick them - // into an abigail::corpus. - string in_path, out_path; - bool is_ok = true; - - out_path = - abigail::tests::get_build_dir() + "/tests/" + archive_spec.out_path; - - if (!abigail::tools_utils::ensure_parent_dir_created(out_path)) - { - cerr << "Could not create parent director for " << out_path; - return 1; - } - - corpus_sptr abi_corpus(new corpus(out_path)); - - for (InOutSpec *s = archive_elements; s->in_path; ++s) - { - in_path = abigail::tests::get_src_dir() + "/tests/" + s->in_path; - abigail::translation_unit_sptr tu = - abigail::xml_reader::read_translation_unit_from_file(in_path); - if (!tu || tu->is_empty()) - { - cerr << "failed to read " << in_path << "\n"; - is_ok = false; - continue; - } - - string file_name; - abigail::tools_utils::base_name(tu->get_path(), file_name); - tu->set_path(file_name); - abi_corpus->add(tu); - } - - if (!write_corpus_to_archive(abi_corpus)) - { - cerr << "failed to write archive file: " << abi_corpus->get_path(); - return 1; - } - - // Diff the archive members. - // - // Basically, re-read the corpus from disk, walk the loaded - // translation units, write them back and diff them against their - // reference. - - abi_corpus->drop_translation_units(); - if (abi_corpus->get_translation_units().size()) - { - cerr << "In-memory object of abi corpus at '" - << abi_corpus->get_path() - << "' still has translation units after call to " - "corpus::drop_translation_units!"; - return false; - } - - if (read_corpus_from_file(abi_corpus) != NUM_ARCHIVES_ELEMENTS) - { - cerr << "Failed to load the abi corpus from path '" - << abi_corpus->get_path() - << "'"; - return 1; - } - - if (abi_corpus->get_translation_units().size() != NUM_ARCHIVES_ELEMENTS) - { - cerr << "Read " << abi_corpus->get_translation_units().size() - << " elements from the abi corpus at " - << abi_corpus->get_path() - << " instead of " - << NUM_ARCHIVES_ELEMENTS - << "\n"; - return 1; - } - - for (unsigned i = 0; i < NUM_ARCHIVES_ELEMENTS; ++i) - { - InOutSpec& spec = archive_elements[i]; - out_path = - abigail::tests::get_build_dir() + "/tests/" + spec.out_path; - using abigail::xml_writer::write_translation_unit; - bool wrote = - write_translation_unit(*abi_corpus->get_translation_units()[i], - /*indent=*/0, out_path); - if (!wrote) - { - cerr << "Failed to serialize translation_unit to '" - << out_path - << "'\n"; - is_ok = false; - } - - string ref = - abigail::tests::get_src_dir() + "/tests/" + spec.in_path; - string cmd = "diff -u " + ref + " " + out_path; - - if (system(cmd.c_str())) - is_ok = false; - } - - return !is_ok; -} diff --git a/tools/Makefile.am b/tools/Makefile.am index e168bd6f..648a71b5 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -1,11 +1,7 @@ ## SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception h=$(abs_srcdir) -if ENABLE_ZIP_ARCHIVE - bin_PROGRAMS = abiar abidiff abilint abidw abicompat abipkgdiff kmidiff -else - bin_PROGRAMS = abidiff abilint abidw abicompat abipkgdiff kmidiff -endif +bin_PROGRAMS = abidiff abilint abidw abicompat abipkgdiff kmidiff if ENABLE_FEDABIPKGDIFF dist_bin_SCRIPTS = fedabipkgdiff @@ -15,12 +11,6 @@ endif noinst_PROGRAMS = abisym abinilint -if ENABLE_ZIP_ARCHIVE -abiar_SOURCES = abiar.cc -abiardir = $(bindir) -abiar_LDADD = ../src/libabigail.la -endif - abidiff_SOURCES = abidiff.cc abidiffdir = $(bindir) abidiff_LDADD = ../src/libabigail.la diff --git a/tools/abiar.cc b/tools/abiar.cc deleted file mode 100644 index 4889c74f..00000000 --- a/tools/abiar.cc +++ /dev/null @@ -1,319 +0,0 @@ -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -*- Mode: C++ -*- -// -// Copyright (C) 2013-2020 Red Hat, Inc. - -#include -#include // The two above is for 'stat' -#include // for 'strcmp' -#include // for 'system' -#include -#include -#include -#include "abg-corpus.h" -#include "abg-reader.h" -#include "abg-writer.h" -#include "abg-tools-utils.h" - -using std::cerr; -using std::cout; -using std::ostream; -using std::string; -using std::list; - -struct options -{ - bool list_content; - string extract_dest; - string archive; - list in_files; - string out_dir; - - options() - : list_content(false) - { - } - -};//end options - -/// Display a message explaining the usage of the program on stdout. -static void -display_usage(const string &prog_name, ostream& out) -{ - out << "usage: " << prog_name << " [options] [archive-file-path]\n" - << " where options are: \n" - << "--help|-h display this usage message\n" - << "--list|l list the archive content\n" - << "--add|-a add files to an archive\n" - << "--extract|x [dest-dir] extract archive content\n" - ; -} - -/// Parse the command line arguments and populate an instance of \a -/// options as a result. -/// -/// @param argc the number of words on the command line, including the -/// program name. -/// -/// @param argv an array of words representing the command line. This -/// is the thing that is parsed. -/// -/// @param opts the options that are set as a result of parsing the -/// command line. This output parameter is set iff the function -/// returs true. -/// -/// @return true if the function could make sense of the command line -/// and parsed it correctly. Otherwise, return false. If this -/// function returns false, the caller would be well inspired to call -/// display_usage() to remind the user how to properly invoke this -/// program so that its command line makes sense. -static bool -parse_args(int argc, char* argv[], options& opts) -{ - if (argc < 2) - return false; - - for (int i = 1; i < argc; ++i) - { - char* arg = argv[i]; - - if (! strcmp(arg, "--help") - ||! strcmp(arg, "-h")) - return false; - - if (arg[0] != '-') - opts.archive = arg; - else if (! strcmp(arg, "--list") - ||! strcmp(arg, "-l")) - opts.list_content = true; - else if (! strcmp(arg, "--add") - || ! strcmp(arg,"-a")) - { - int arg_index0, arg_index1; - char *f = 0; - for (arg_index0 = i + 1; arg_index0 < argc; ++arg_index0) - { - // --add must be followed by at N words that don't start - // by '-' (N > 1). The first N-1 words are the - // arguments of --add (the files to add to the archive) - // and the last one is the name of the archive to add - // the files to. - - f = argv[arg_index0]; - if (f[0] == '-') - break; - - arg_index1 = arg_index0 + 1; - if (arg_index1 >= argc - || argv[arg_index1][0] == '-') - break; - - opts.in_files.push_back(f); - } - if (opts.in_files.empty()) - return false; - } - else if (! strcmp(arg, "--extract") - || ! strcmp(arg, "-x")) - { - int arg_index = i + 1, arch_index = arg_index + 1; - if (arg_index < argc - && argv[arg_index][0] != '-' - && arch_index < argc - && argv[arch_index][0] != '-') - opts.extract_dest = argv[arg_index]; - else if (arg_index < argc - && argv[arg_index][0] != '-') - // No destination directory argument was given for the - // --extract option, so consider it to be the current - // directory - opts.extract_dest = "."; - else - return false; - } - } - - return true; -} - -using abigail::corpus; -using abigail::corpus_sptr; -using abigail::translation_unit; -using abigail::translation_unit_sptr; -using abigail::translation_units; -using abigail::xml_reader::read_corpus_from_file; -using abigail::xml_writer::write_corpus_to_archive; - -/// List the content of a given archive. The names of the files of -/// the archive are then displayed on stdout. -/// -/// @param archive_path a path to the file containing the archive file -/// to list the content of. -/// -/// @return true upon successful completion, false otherwise. -static bool -list_content(const string& archive_path) -{ - if (archive_path.empty()) - { - cerr << "Empty archive path\n"; - return false; - } - - corpus_sptr archive = read_corpus_from_file(archive_path); - if (!archive) - { - cerr << "Could not read archive at '" << archive_path << "'\n"; - return false; - } - - for (translation_units::const_iterator i = - archive->get_translation_units().begin(); - i != archive->get_translation_units().end(); - ++i) - cout << (*i)->get_path() << "\n"; - - return true; -} - -/// Add a translation unit to an archive -- or create one for that -/// matter. -/// -/// @param tu_paths a list of paths to add to the archive. -/// -/// @param archive_path the path of the archive to either open or -/// create. The specified in \tu_paths are then added to this -/// archive. Note that this function creates the entire directory -/// tree needed up to \a archive_path, if needed. -/// -/// @return true upon successful completion, false otherwise. -static bool -add_tus_to_archive(const list& tu_paths, - const string& archive_path) -{ - translation_units tus; - corpus corp(archive_path); - - bool added_some_tus = false; - for (list::const_iterator i = tu_paths.begin(); - i != tu_paths.end(); - ++i) - { - translation_unit_sptr tu = - abigail::xml_reader::read_translation_unit_from_file(*i); - if (!tu) - { - cerr << "could not read binary instrumentation file '" - << *i - << "'\n"; - continue; - } - corp.add(tu); - added_some_tus = true; - } - - if (added_some_tus) - { - if (!write_corpus_to_archive(corp)) - { - cerr << "could not write archive file '" - << corp.get_path() - << "'\n"; - return false; - } - } - - return true; -} - -/// Extract translation units from a given archive. -/// -/// @param dest_path the path of the destination directory which the -/// elements of the archive are to be extracted under. -/// -/// @param archive_path the path to the archive to extract. The -/// archive must exist and be accessible with read privileges. -/// -/// @return true upon successful completion, false otherwise. -static bool -extract_tus_from_archive(const string& dest_path, - const string& archive_path) -{ - if (dest_path.empty()) - { - cerr << "empty file directory\n"; - return false; - } - - corpus_sptr archive(new corpus(archive_path)); - - if (read_corpus_from_file(archive) < 1) - { - cerr << "could not read archive at '" - << archive_path - << "'\n;"; - return false; - } - - string cmd = "mkdir -p " + dest_path; - if (system(cmd.c_str())) - { - cerr << "could not create file directory '" - << dest_path - << "'\n"; - return false; - } - - for (translation_units::const_iterator i = - archive->get_translation_units().begin(); - i != archive->get_translation_units().end(); - ++i) - { - string dest = dest_path + "/" + (*i)->get_path(); - if (!abigail::tools_utils::ensure_parent_dir_created(dest)) - { - cerr << "could not create parent director for '" << dest << "'\n"; - return false; - } - - if (!abigail::xml_writer::write_translation_unit(**i, /*indent=*/0, dest)) - { - cerr << "could not write binary instrumentation file to '" - << dest - << "'\n"; - return false; - } - } - - return true; -} - -/// Parse the command line and perform the archive-related operations -/// asked by the user, if the command line makes sense; otherwise, -/// display a usage help message and bail out. -int -main(int argc, char* argv[]) -{ - options opts; - - if (!parse_args(argc, argv, opts) - || opts.archive.empty()) - { - display_usage(argv[0], cout); - return -1; - } - - if (opts.list_content) - return !list_content(opts.archive); - else if (!opts.in_files.empty()) - return !add_tus_to_archive(opts.in_files, opts.archive); - else if (!opts.extract_dest.empty()) - return !extract_tus_from_archive(opts.extract_dest, opts.archive); - else - { - display_usage(argv[0], cout); - return -1; - } - - return 0; -} diff --git a/tools/abidiff.cc b/tools/abidiff.cc index f0820de2..518d7562 100644 --- a/tools/abidiff.cc +++ b/tools/abidiff.cc @@ -1178,13 +1178,6 @@ main(int argc, char* argv[]) argv[0], opts); } break; - case abigail::tools_utils::FILE_TYPE_ZIP_CORPUS: -#ifdef WITH_ZIP_ARCHIVE - c1 = abigail::xml_reader::read_corpus_from_file(opts.file1); - if (!c1) - return handle_error(c1_status, /*ctxt=*/0, argv[0], opts); -#endif //WITH_ZIP_ARCHIVE - break; case abigail::tools_utils::FILE_TYPE_RPM: case abigail::tools_utils::FILE_TYPE_SRPM: case abigail::tools_utils::FILE_TYPE_DEB: @@ -1253,13 +1246,6 @@ main(int argc, char* argv[]) return handle_error(c2_status, /*ctxt=*/0, argv[0], opts); } break; - case abigail::tools_utils::FILE_TYPE_ZIP_CORPUS: -#ifdef WITH_ZIP_ARCHIVE - c2 = abigail::xml_reader::read_corpus_from_file(opts.file2); - if (!c2) - return handle_error(c2_status, /*ctxt=*/0, argv[0], opts); -#endif //WITH_ZIP_ARCHIVE - break; case abigail::tools_utils::FILE_TYPE_RPM: case abigail::tools_utils::FILE_TYPE_SRPM: case abigail::tools_utils::FILE_TYPE_DEB: diff --git a/tools/abilint.cc b/tools/abilint.cc index fb7b0781..28ef25ff 100644 --- a/tools/abilint.cc +++ b/tools/abilint.cc @@ -57,9 +57,6 @@ using abigail::xml_writer::write_context_sptr; using abigail::xml_writer::create_write_context; using abigail::xml_writer::write_corpus; using abigail::xml_writer::write_corpus_to_archive; -#ifdef WITH_ZIP_ARCHIVE -using abigail::xml_reader::read_corpus_from_file; -#endif struct options { @@ -370,11 +367,6 @@ main(int argc, char* argv[]) group = read_corpus_group_from_input(*ctxt); } break; - case abigail::tools_utils::FILE_TYPE_ZIP_CORPUS: -#if WITH_ZIP_ARCHIVE - corp = read_corpus_from_file(opts.file_path); -#endif - break; case abigail::tools_utils::FILE_TYPE_RPM: break; case abigail::tools_utils::FILE_TYPE_SRPM: @@ -454,13 +446,6 @@ main(int argc, char* argv[]) if (!opts.noout) is_ok = write_corpus(*ctxt, corp, 0); } - else if (type == abigail::tools_utils::FILE_TYPE_ZIP_CORPUS) - { -#ifdef WITH_ZIP_ARCHIVE - if (!opts.noout) - is_ok = write_corpus_to_archive(*corp, tmp_file->get_path()); -#endif //WITH_ZIP_ARCHIVE - } } if (!is_ok) @@ -478,8 +463,7 @@ main(int argc, char* argv[]) && opts.diff && ((type == abigail::tools_utils::FILE_TYPE_XML_CORPUS) ||type == abigail::tools_utils::FILE_TYPE_XML_CORPUS_GROUP - || type == abigail::tools_utils::FILE_TYPE_NATIVE_BI - || type == abigail::tools_utils::FILE_TYPE_ZIP_CORPUS)) + || type == abigail::tools_utils::FILE_TYPE_NATIVE_BI)) { string cmd = "diff -u " + opts.file_path + " " + tmp_file->get_path(); if (system(cmd.c_str()))