From: DongHun Kwak Date: Fri, 27 Nov 2020 06:47:19 +0000 (+0900) Subject: Imported Upstream version 17.22.0 X-Git-Tag: upstream/17.22.0^0 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fupstream%2Flibzypp.git;a=commitdiff_plain;h=d58a5d90878551ca9fde5de55c8a026453ac32ca Imported Upstream version 17.22.0 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 29c17b8..96e16b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,7 @@ OPTION (ENABLE_BUILD_DOCS "Build documentation by default?" OFF) OPTION (ENABLE_BUILD_TRANS "Build translation files by default?" OFF) OPTION (ENABLE_BUILD_TESTS "Build and run test suite by default?" OFF) OPTION (ENABLE_USE_THREADS "Enable using threads (NOT being used by threads!)?" OFF) +OPTION (ENABLE_ZCHUNK_COMPRESSION "Build with zchunk compression support?" OFF) OPTION (DISABLE_LIBPROXY "Build without libproxy support even if package is installed?" OFF) OPTION (DISABLE_AUTODOCS "Do not require doxygen being installed (required to build autodocs)?" OFF) @@ -41,6 +42,7 @@ if(COMMAND cmake_policy) endif(COMMAND cmake_policy) INCLUDE(ZyppCommon) +find_package(FindPkgConfig) INCLUDE( ${LIBZYPP_SOURCE_DIR}/VERSION.cmake ) MATH( EXPR LIBZYPP_NUMVERSION "${LIBZYPP_MAJOR} * 10000 + ${LIBZYPP_MINOR} * 100 + ${LIBZYPP_PATCH}" ) @@ -239,6 +241,14 @@ ELSE ( NOT DOXYGEN ) MESSAGE( STATUS "doxygen found: ${DOXYGEN}" ) ENDIF ( NOT DOXYGEN ) +IF (ENABLE_ZCHUNK_COMPRESSION) + MESSAGE("Building with zchunk support enabled.") + PKG_CHECK_MODULES (ZCHUNK zck REQUIRED) + SET( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ZCHUNK_CFLAGS}" ) + SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ZCHUNK_CFLAGS}" ) + ADD_DEFINITIONS (-DENABLE_ZCHUNK_COMPRESSION=1) +ENDIF(ENABLE_ZCHUNK_COMPRESSION) + MESSAGE(STATUS "soname: ${LIBZYPP_VERSION_INFO}") MESSAGE(STATUS "version: ${VERSION}") diff --git a/VERSION.cmake b/VERSION.cmake index eef901d..c4c5706 100644 --- a/VERSION.cmake +++ b/VERSION.cmake @@ -59,10 +59,10 @@ # See './mkChangelog -h' for help. # SET(LIBZYPP_MAJOR "17") -SET(LIBZYPP_COMPATMINOR "20") -SET(LIBZYPP_MINOR "21") +SET(LIBZYPP_COMPATMINOR "22") +SET(LIBZYPP_MINOR "22") SET(LIBZYPP_PATCH "0") # -# LAST RELEASED: 17.21.0 (20) +# LAST RELEASED: 17.22.0 (22) # (The number in parenthesis is LIBZYPP_COMPATMINOR) #======= diff --git a/libzypp.spec.cmake b/libzypp.spec.cmake index 3b81e75..c5029e8 100644 --- a/libzypp.spec.cmake +++ b/libzypp.spec.cmake @@ -15,6 +15,11 @@ # Please submit bugfixes or comments via http://bugs.opensuse.org/ # +%if 0%{?is_opensuse} && (0%{?sle_version} >= 150000 || 0%{?suse_version} >= 1500) +%bcond_without zchunk +%else +%bcond_with zchunk +%endif Name: @PACKAGE@ Version: @VERSION@ @@ -71,7 +76,7 @@ BuildRequires: pkgconfig BuildRequires: pkg-config %endif -BuildRequires: libsolv-devel >= 0.7.10 +BuildRequires: libsolv-devel >= 0.7.11 %if 0%{?suse_version} >= 1100 BuildRequires: libsolv-tools %requires_eq libsolv-tools @@ -129,6 +134,10 @@ BuildRequires: asciidoc BuildRequires: libxslt-tools %endif +%if %{with zchunk} +BuildRequires: libzck-devel +%endif + %description libzypp is the package management library that powers applications like YaST, zypper and the openSUSE/SLE implementation of PackageKit. @@ -220,6 +229,7 @@ cmake -DCMAKE_INSTALL_PREFIX=%{_prefix} \ -DLIB=%{_lib} \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_SKIP_RPATH=1 \ + %{?with_zchunk:-DENABLE_ZCHUNK_COMPRESSION=1} \ ${EXTRA_CMAKE_OPTIONS} \ .. make %{?_smp_mflags} VERBOSE=1 diff --git a/package/libzypp.changes b/package/libzypp.changes index f7ddd22..cce0999 100644 --- a/package/libzypp.changes +++ b/package/libzypp.changes @@ -1,9 +1,17 @@ ------------------------------------------------------------------- +Thu Jan 23 16:30:19 CET 2020 - ma@suse.de + +- yum::Downloader: Prefer zchunk compressed metadata if libvsolv + supports it. +- BuildRequires: libsolv-devel >= 0.7.11. +- version 17.22.0 (22) + +------------------------------------------------------------------- Mon Jan 20 12:53:12 CET 2020 - ma@suse.de - Selectable: Fix highestAvailableVersionObj if only retracted packages are available. Avoid using retracted items as candidate - (jira#SLE-8905) + (jsc#SLE-8770) - version 17.21.0 (20) ------------------------------------------------------------------- diff --git a/tests/parser/yum/CMakeLists.txt b/tests/parser/yum/CMakeLists.txt index 44d1901..2d697c9 100644 --- a/tests/parser/yum/CMakeLists.txt +++ b/tests/parser/yum/CMakeLists.txt @@ -1 +1 @@ -ADD_TESTS(RepomdFileReader PatchesFileReader) +ADD_TESTS(RepomdFileReader) diff --git a/tests/parser/yum/PatchesFileReader_test.cc b/tests/parser/yum/PatchesFileReader_test.cc deleted file mode 100644 index 7c57a2e..0000000 --- a/tests/parser/yum/PatchesFileReader_test.cc +++ /dev/null @@ -1,81 +0,0 @@ -#include -#include -#include -#include -#include -#include - -#include "zypp/OnMediaLocation.h" -#include "zypp/parser/yum/PatchesFileReader.h" -#include "zypp/Url.h" -#include "zypp/PathInfo.h" - -using namespace std; -using namespace zypp; -using namespace boost::unit_test; - -using namespace zypp::parser::yum; - -#define DATADIR (Pathname(TESTS_SRC_DIR) + "/parser/yum/data") - -class Collector -{ -public: - Collector() - {} - - bool callback( const OnMediaLocation &loc, const string &id ) - { - items.push_back( make_pair( id, loc ) ); - //items.push_back(loc); - //cout << items.size() << endl; - return true; - } - - vector > items; - //vector items; -}; - -BOOST_AUTO_TEST_CASE(patches_read_test) -{ - list entries; - if ( filesystem::readdir( entries, DATADIR, false ) != 0 ) - ZYPP_THROW(Exception("failed to read directory")); - - for ( list::const_iterator it = entries.begin(); it != entries.end(); ++it ) - { - Pathname file = *it; - //cout << file.basename().substr(0, 7) << " " << file.extension() << endl; - if ( ( file.basename().substr(0, 7) == "patches" ) && (file.extension() == ".xml" ) ) - { - //cout << *it << endl; - - Collector collect; - PatchesFileReader( file, bind( &Collector::callback, &collect, _1, _2 )); - - std::ifstream ifs( file.extend(".solution").asString().c_str() ); - cout << "Comparing to " << file.extend(".solution") << endl; - unsigned int count = 0; - while ( ifs && ! ifs.eof() && count < collect.items.size() ) - { - string id; - string checksum_type; - string checksum; - string loc; - - getline(ifs, id); - BOOST_CHECK_EQUAL( collect.items[count].first, id); - getline(ifs, checksum_type); - getline(ifs, checksum); - BOOST_CHECK_EQUAL( collect.items[count].second.checksum(), CheckSum(checksum_type, checksum) ); - getline(ifs, loc); - BOOST_CHECK_EQUAL( collect.items[count].second.filename(), Pathname(loc) ); - - count++; - } - BOOST_CHECK_EQUAL( collect.items.size(), count ); - } - } -} - -// vim: set ts=2 sts=2 sw=2 ai et: diff --git a/tests/parser/yum/RepomdFileReader_test.cc b/tests/parser/yum/RepomdFileReader_test.cc index 0d46005..1faff43 100644 --- a/tests/parser/yum/RepomdFileReader_test.cc +++ b/tests/parser/yum/RepomdFileReader_test.cc @@ -14,7 +14,6 @@ using namespace zypp; using namespace boost::unit_test; using namespace zypp::parser::yum; -using repo::yum::ResourceType; #define DATADIR (Pathname(TESTS_SRC_DIR) + "parser/yum/data") @@ -23,17 +22,14 @@ class Collector public: Collector() {} - - bool callback( const OnMediaLocation &loc, const ResourceType &t ) + + bool operator()( OnMediaLocation &&loc, const std::string &t ) { - items.push_back( make_pair( t, loc ) ); - //items.push_back(loc); - //cout << items.size() << endl; + items.push_back( make_pair( t, std::move(loc) ) ); return true; } - vector > items; - //vector items; + vector > items; }; BOOST_AUTO_TEST_CASE(repomd_read) @@ -48,28 +44,32 @@ BOOST_AUTO_TEST_CASE(repomd_read) if ( ( file.basename().substr(0, 6) == "repomd" ) && (file.extension() == ".xml" ) ) { cout << *it << endl; - + Collector collect; - RepomdFileReader( file, RepomdFileReader::ProcessResource(bind( &Collector::callback, &collect, _1, _2 )) ); - + RepomdFileReader( file, std::ref(collect) ); + std::ifstream ifs( file.extend(".solution").asString().c_str() ); - + unsigned int count = 0; - while ( ifs && ! ifs.eof() && count < collect.items.size() ) + while ( ifs && !ifs.eof() ) { string dtype; + getline(ifs, dtype); + if ( dtype.empty() ) + break; + BOOST_REQUIRE( count < collect.items.size() ); + BOOST_CHECK_EQUAL( collect.items[count].first, dtype ); + string checksum_type; string checksum; - string loc; - - getline(ifs, dtype); - BOOST_CHECK_EQUAL( collect.items[count].first, ResourceType(dtype)); getline(ifs, checksum_type); getline(ifs, checksum); BOOST_CHECK_EQUAL( collect.items[count].second.checksum(), CheckSum(checksum_type, checksum) ); + + string loc; getline(ifs, loc); BOOST_CHECK_EQUAL( collect.items[count].second.filename(), Pathname(loc) ); - + count++; } BOOST_CHECK_EQUAL( collect.items.size(), count ); diff --git a/tests/parser/yum/data/README b/tests/parser/yum/data/README deleted file mode 100644 index 348bf4c..0000000 --- a/tests/parser/yum/data/README +++ /dev/null @@ -1,4 +0,0 @@ -to generate a solution, take the -patches.xml, remove the namespace and do: - -xsltproc patches.xsl patches2.xml | html2tex diff --git a/tests/parser/yum/data/patch-fetchmsttfonts.sh-4347.xml b/tests/parser/yum/data/patch-fetchmsttfonts.sh-4347.xml deleted file mode 100644 index 86ec18c..0000000 --- a/tests/parser/yum/data/patch-fetchmsttfonts.sh-4347.xml +++ /dev/null @@ -1,296 +0,0 @@ - - - - fetchmsttfonts.sh - Download Microsoft(r) TrueType Core Fonts - Download Microsoft(r) TrueType Core Fonts - For legal reasons we can't include the Microsoft(r) -TrueType Core Fonts in our product. This patch downloads -these fonts and installs them on your system. Please note -that about 4 MByte data are downloaded therefore. License -for the fonts will be installed as -/usr/share/doc/corefonts/EULA.html. - - Aus rechtlichen Gründen können wir leider die TrueType Core -Fonts von Microsoft(r) auf unserem Produkt nicht -mitliefern. Dieser Patch lädt diese Fonts herunter und -installiert diese auf Ihrem System. Beachten Sie bitte, -dass dazu in etwa 4 MByte an Daten heruntergeladen werden. -Die Lizenz für die Fonts wird unter -/usr/share/doc/corefonts/EULA.html abgelegt. - - - - - - - optional - -END-USER LICENSE AGREEMENT FOR -MICROSOFT SOFTWARE - -IMPORTANT-READ CAREFULLY: This Microsoft End-User License Agreement ("EULA") is -a legal agreement between you (either an individual or a single entity) and -Microsoft Corporation for the Microsoft software accompanying this EULA, which -includes computer software and may include associated media, printed materials, -and "on-line" or electronic documentation ("SOFTWARE PRODUCT" or "SOFTWARE"). -By exercising your rights to make and use copies of the SOFTWARE PRODUCT, you -agree to be bound by the terms of this EULA. If you do not agree to the terms -of this EULA, you may not use the SOFTWARE PRODUCT. - - -SOFTWARE PRODUCT LICENSE -The SOFTWARE PRODUCT is protected by copyright laws and international copyright -treaties, as well as other intellectual property laws and treaties. The -SOFTWARE PRODUCT is licensed, not sold. - - -1. GRANT OF LICENSE. This EULA grants you the following rights: - - * Installation and Use. You may install and use an unlimited number of copies - of the SOFTWARE PRODUCT. - * Reproduction and Distribution. You may reproduce and distribute an - unlimited number of copies of the SOFTWARE PRODUCT; provided that each copy - shall be a true and complete copy, including all copyright and trademark - notices, and shall be accompanied by a copy of this EULA. Copies of the - SOFTWARE PRODUCT may not be distributed for profit either on a standalone - basis or included as part of your own product. - - -2. DESCRIPTION OF OTHER RIGHTS AND LIMITATIONS. - - * Limitations on Reverse Engineering, Decompilation, and Disassembly. You may - not reverse engineer, decompile, or disassemble the SOFTWARE PRODUCT, - except and only to the extent that such activity is expressly permitted by - applicable law notwithstanding this limitation. - * Restrictions on Alteration. You may not rename, edit or create any - derivative works from the SOFTWARE PRODUCT, other than subsetting when - embedding them in documents. - * Software Transfer. You may permanently transfer all of your rights under - this EULA, provided the recipient agrees to the terms of this EULA. - * Termination. Without prejudice to any other rights, Microsoft may terminate - this EULA if you fail to comply with the terms and conditions of this EULA. - In such event, you must destroy all copies of the SOFTWARE PRODUCT and all - of its component parts. - - -3. COPYRIGHT. All title and copyrights in and to the SOFTWARE PRODUCT -(including but not limited to any images, text, and "applets" incorporated into -the SOFTWARE PRODUCT), the accompanying printed materials, and any copies of -the SOFTWARE PRODUCT are owned by Microsoft or its suppliers. The SOFTWARE -PRODUCT is protected by copyright laws and international treaty provisions. -Therefore, you must treat the SOFTWARE PRODUCT like any other copyrighted -material. - - -4. U.S. GOVERNMENT RESTRICTED RIGHTS. The SOFTWARE PRODUCT and documentation -are provided with RESTRICTED RIGHTS. Use, duplication, or disclosure by the -Government is subject to restrictions as set forth in subparagraph (c)(1)(ii) -of the Rights in Technical Data and Computer Software clause at DFARS -252.227-7013 or subparagraphs (c)(1) and (2) of the Commercial Computer -Software - Restricted Rights at 48 CFR 52.227-19, as applicable. Manufacturer -is Microsoft Corporation/One Microsoft Way/Redmond, WA 98052-6399. - - -LIMITED WARRANTY - -NO WARRANTIES. Microsoft expressly disclaims any warranty for the SOFTWARE -PRODUCT. The SOFTWARE PRODUCT and any related documentation is provided "as is" -without warranty of any kind, either express or implied, including, without -limitation, the implied warranties or merchantability, fitness for a particular -purpose, or noninfringement. The entire risk arising out of use or performance -of the SOFTWARE PRODUCT remains with you. - -NO LIABILITY FOR CONSEQUENTIAL DAMAGES. In no event shall Microsoft or its -suppliers be liable for any damages whatsoever (including, without limitation, -damages for loss of business profits, business interruption, loss of business -information, or any other pecuniary loss) arising out of the use of or -inability to use this Microsoft product, even if Microsoft has been advised of -the possibility of such damages. Because some states/jurisdictions do not allow -the exclusion or limitation of liability for consequential or incidental -damages, the above limitation may not apply to you. - - -MISCELLANEOUS - -If you acquired this product in the United States, this EULA is governed by the -laws of the State of Washington. - -If this product was acquired outside the United States, then local laws may -apply. - -Should you have any questions concerning this EULA, or if you desire to contact -Microsoft for any reason, please contact the Microsoft subsidiary serving your -country, or write: Microsoft Sales Information Center/One Microsoft Way/ -Redmond, WA 98052-6399. - - - - - diff --git a/tests/parser/yum/data/patches-1.xml b/tests/parser/yum/data/patches-1.xml deleted file mode 100644 index 42de48f..0000000 --- a/tests/parser/yum/data/patches-1.xml +++ /dev/null @@ -1,763 +0,0 @@ - - - - 6b72b4f3617d0d51af28399c0f5e0af401440245 - - - - b02ba598d8ed5f8a31859d3b34e72e1ddecbe894 - - - - 321ee41de68be4e83dfb74559c14300a59b85ccf - - - - ec9e8a3f3ce2588cecd84ab95ec910d41db5d74b - - - - d803372cd5d844ee01ab6fb3d1b4332391fa1206 - - - - c2de5dd35ec2dcccc118d9d7f539e768dfd5ec50 - - - - 7fb791963114836621873280c7edd58887b91784 - - - - 28f0c33aa4a34830a4b7b8a795db609bfd3d7531 - - - - 98c2d98fe33439563047eef97c6db065c8361bbe - - - - f449fabf0a7bedfc9f561ea5d04e160c521a5186 - - - - e1dd5a93ce9bb796348557d7d8e16ef54fb8d90d - - - - a73445a3630084c867d63868d9d064625a84ea6d - - - - 792bad7440845613b608c771c2d948607e02759d - - - - de603b359e148a7666b5b695b76602c4689ff193 - - - - 6dff2c1367613b7eae36db090233bfbf31a92920 - - - - 3266d24fa2fb7aeb4ba303ccd77fbe8b27f75ad0 - - - - 394bec89d3f5f976a9f7ae074a0e4c0d5582139a - - - - 6630055daac876bcb0a6ebf36f63d28341b1ff6e - - - - d3de77e29165bdbce88310a6ce9f97f3a5368377 - - - - 905a98399c20efb91592d2767ec187823c7b154d - - - - 5314e6c2d4e21a38dd2ea05ee0495d7dd27f0931 - - - - 329b6083dfe59ddb7d50cb9e92686eb7ecc48d6d - - - - b5ec61bcf901f4270fc3ba6a18926c20102c94c9 - - - - c38d7746f8aca8d40347879bfba5d977ca8fc03f - - - - c1dca99b03a2b012c141a64c8fcc494d957baed2 - - - - f239f615760d15515bd4f0316cc99e40d25a6117 - - - - f30517b5083e9bc007adf9cc974a36fc7bba3f0b - - - - 24769a5bbd9e57cd59806b186088d5f0dffa5e30 - - - - 6c2aa38c513f7eeda2b38555182b8200c08f6468 - - - - c0b54062cb5b16cbb18d383beb721c60b2a36f72 - - - - 640a5b7ca790a3becc9c26d8434adfac560a14c5 - - - - 94c690e13540511db05ee397e9ab5fc9905b086b - - - - fb1786ca30124e82b24e57b694a58da9f920e6b3 - - - - bb6aea44ad2e2ddb0f50842b15f791b7c0a0b346 - - - - d9ba43f21238b71a7b8cfb6d9256e404cffb7cc0 - - - - 42e904686825e904752238b85085771ee51965c7 - - - - cd88e95ae02706069fe6f3031178bf26e9e06d3a - - - - ab7741ef2411c11a7ec941fc8736feebfca73398 - - - - 2f8c1cd5d147c89b06c0898d4392f1196098236f - - - - a26f9f36ed0a0f6a45cb5369234ff44d6c535310 - - - - 61a24339218f1fd480085fe0e3f754baa8820cb3 - - - - c37bf9a8ff3810e2c9a674bd9aadfed24f8c2ab2 - - - - 2cdfac93ac338ccf87abe8049f13bb415428a279 - - - - 9adf70721a91e7666c40c45c1c2270bd673d2ac4 - - - - d0a21646dc9d1c244e7e35888a0fb52aaeb1b5e2 - - - - 8daf1728afb47779fd28e0021ea6ff55f18f1149 - - - - a515c1a96ac1b55f50852cfda93a49004ce4c79a - - - - a3f5b8927b7f1f47f347e7ee3ab821995dca00b7 - - - - 4fdf8c67eaa488edbe668ead3d995caa38a1936b - - - - 5209e7b0a7f89ec7c225de065d4cbc4fbefcbddb - - - - 669837ce13f07df59ac79ce6201c176342ed27c4 - - - - a41806bf5d57c36825ad832be3d0f13d1695d70a - - - - bdbbba1841bebd9822458f3a3fb1c88141e78281 - - - - 1b84ea4aa922b21a7039330c0fdbf2775dd13444 - - - - c7266496955cee3242ae100ffd731ce4323d6b89 - - - - 883f737c6ecedd05670bad4784a37e2c67a8c5da - - - - 538c771158fa860793ed285990641b1ed04330b5 - - - - 32ae23cb16bff2f8e6ec4ba168e6a75d541efc8c - - - - cea742686fabc65af02a9dd7bea89b39cbdb62c1 - - - - 8f021c3fec51df6155c44276b87260bbf074c0a2 - - - - 73e3b82edf6537e759d3c7fe103654baad9155cf - - - - 9b83d8d408138a521c7926be0c569047eb5d866a - - - - 837cb40fa331f256281577e8ca81fe73b9c27e2a - - - - 050a31137f1ff1ca986c27addaf894deaa10b6ad - - - - cd51f150dda049a82acca2ef4b0524465947ddc2 - - - - ec3095ea0c8b996b49061d79f7afb780ab4ea84b - - - - c53aeb36ef68f4f1b6e6ac0f38df63c22f22359d - - - - 31c74fc5d4ba42bf3301fa95b806caa978659127 - - - - 7cbcd6c1064568aeb0e523d2587336e742e44fcb - - - - 4f331f6ea3e5c5a90f66a871162114ca94f92f76 - - - - b5a4c65f2356613b4de6ad1bc2dd0582e77b0ee6 - - - - 18e4e361c7688a57f7b7963c359fee4f58d29b08 - - - - f812f28e10039b5bfd249e3902b905e92a7eb769 - - - - 90c4516d8073322a05f4235dbe1f7c4770c6e4e0 - - - - 7d9f7a7fdd96843f5d962aef984cc0c5c2534f30 - - - - fffd63b332907c46b926499e27b6ec0ad9025ddb - - - - b0bbd764da5ec2651bf030e7051d045341ddbdd7 - - - - 5e2c95f36ceb9c7d94c4a2df8ec60aaf36dde810 - - - - 11a15f477e35a5e4879a8883074c13e6ab321141 - - - - c71c5d298bf5b11fcc0c0865b1302a7ba9970c0c - - - - fb916bb899aa6d2b1ae8d211ee84ceb0a66f1fd8 - - - - 558c89fe1d04efa2d7c5988be9344376f2eacace - - - - 18473edb5c4b6853aea94db3883bcfe496b5b6ee - - - - 4c3d0446ffd36ce86b40da43135913a18349ef44 - - - - 188b82cfb54dd61f0fe0e5beea054d5a9591e0a5 - - - - 85a08c9bc4eebac24854a9eb7da257a3fe8f5b6d - - - - e711370f446cf3538fbaf64c9faaf0eadaedb580 - - - - 16921f0179c7c3dcb504b9ffb82abd32e84086ac - - - - 147a7b5f084395bd427c273ba8f25f312cc87193 - - - - afd07ae38e0585e615022a7df3cd469c2c99fdbb - - - - 5b9d9747bffc3368ea2f7c8c7b3ff8e0cc4605f7 - - - - 1b1c1fdb9ad132cd6504c8b437cfe519bc9c0dfa - - - - 2af5b888f4f4c9b9be8b9bc2aaae02efd436b924 - - - - 664ef6d8c867824f20b15a9af4d2957fd79897bd - - - - ad29afc8f5dd7ca1f4faa4a2aaed644c80d844b6 - - - - 8cc33adb78b9fccccc7f2fc03d5df13f8a79eae5 - - - - ccece044c2ba608c8233d70a4aa68c466c1862f1 - - - - 339f1a841955652ccaccd9c9e936c21abe85a2f2 - - - - 3ef0e4f08055c2f458c0efa5dfdd4d7aee384122 - - - - 67602c57de3f98ffd2c7434b6952f79481feceb8 - - - - 4da7e1958d56142f48d99b9ab1b16425aeb0cd96 - - - - 940c331de3e40be9f570e012b8ca9bbab6d594d2 - - - - da26f814db1c2f04cd8fc27495aecdbd66f73daf - - - - 299f0dff3447555cea60a63fdf97e81e1bd56096 - - - - a7a501a1465dfcb3e125d14c1a67efd2638be166 - - - - 10b87459f9209a43097bebd31f9ec8cff4354c11 - - - - 8d0d0b963c5fa85c92d5a9b5c86c88063b2faf8e - - - - 5f43e01206494f0d0cbab846bfbb157285e22efc - - - - 5e86626239c4798708e7d2432708cf98d6a001d2 - - - - 5af58df93d8f36428726d0cf55fc5bb6a18a8bfd - - - - 924e7f989e3d6f159e717e2d76b21de572ce7ec2 - - - - 93a54883e5b9170839fc81a72c534f76e7987c19 - - - - 64a57f29d835e46f7f00e939d4b505cb546d0654 - - - - 88ee8256ac3875e2b087ab9723bb13f071f9de73 - - - - 115f31bcb61f37f264daa4b0ef8220816be05de7 - - - - c5a5fd01f5266d3f30fe33b5fc1679b35af3d4d4 - - - - b6654a37408c21d66e60cf7a78a1cddb991b797a - - - - fd76c123487f884cf10b161c87afe5b7bc9f05f8 - - - - d3533c47354977c9f821eb4e579c43ea919d4488 - - - - 06f48c215e805213e339fa581670fb35e2151786 - - - - b5217b10a1a3e513085665d994dded954a72e884 - - - - e2d31e95095a1c7dd242c577f3a394a39d7e75be - - - - b6f7e30d0d8f3e699e8593a178b5fd63c865ad0e - - - - 7ebc8745836d63bdfee712bca5c71ba328877047 - - - - 4eb206f1dba689554bc3e113fd87ad2a4fcdbf78 - - - - 505cc81dc924efb58154806700b1d261cc33fbb9 - - - - 3d960c76d7dd38393c631c63212f0a8c4f08ad98 - - - - b31ced09fece6d2f9fad37653acfda9eb9e7ba2b - - - - 26a5b6e1a3c77afa7fd77171bcbef2d78f7df11f - - - - 420d992e8b4436cc7ebc0609183ba040db340dc5 - - - - bf0b411e4eb5494a27ebef8d5b9cd923da4fe2c8 - - - - 19126ca4e55852b98ffa69c6c3fcff12743af49c - - - - 0bbcdeab9294272a677f9b4a7b57e13701244010 - - - - df03ccdfcb0f188ac3072c5086ab86b425a66f8e - - - - 8ffefa033ac19a70938a7af71854184d6b902e45 - - - - df121b6b7cc82715a4544f491a0104b50a28eb20 - - - - f34eb5a2f4399578c78e6dca5dd165077787c806 - - - - da442e32fe4401897261051bf817e1a029e804c3 - - - - ff002a87486fbd2c68b445e58b6ac0d307e8dbad - - - - fd8198e09f073515c67cf90a879ff57bfde0cfa9 - - - - 2453275e874a7d65c9f21cc50885f50202d617bf - - - - fad24b42e3d7d8c35e410017ca85dd375f2b7f1d - - - - e74c7b27498161c9ba056869ba1813658f4ef4e0 - - - - 36f9b9e6ff739fe7d82a58b59fcb74be6581a752 - - - - c1e569e948b46ddcd33369c9479e6ad92fb8c7ec - - - - 3dd423deeb41c58b11f54184d59367d152d78f24 - - - - 678cae267889c434cbdd81654066244270a341b6 - - - - 9539aa93b99854e21cc69248bd82249f75a6f6e0 - - - - fedf719a3be03d6c93fc04f78b50ce7be1465606 - - - - b95d82b3c1e22c1ce2ec2ea96ffb9ba94e1a2adb - - - - be5018a378fbce22ad2f1f94266f251dfb0fecc2 - - - - 93496c003d8a1565e88fa37bc28b62b685b86223 - - - - 40b9fd23e3eb4141d8b28794c40aeebdee7dcc1d - - - - 7d6301a829eda6ff7ab006302c38943693defd44 - - - - c338bfb439e94dc27774a76d860285577b9ade19 - - - - eb0c412124838a4ff2ff884642a88fac1578da8f - - - - 95ce884347ae5fb4f8b030f9e302f75dec58cefd - - - - 91dba1fffdd033eb289fec17dd2a288658dbb586 - - - - 069398c5d7b94dc32c6102243b478584a76b84bb - - - - 2c534ad1e2a36b668f7d22f37b5e0457f5892359 - - - - bce7d390d3db0bdedf63304a9b739645e7c10eb8 - - - - 5d0fa6b2d1a729ed86d6bdc54bb3eeabb1bfea38 - - - - c1e7abcd4dc9ffda6f97dc8c98e68d36f0fa51e5 - - - - ff9e274c83ef488d9eed486c7eae9f2952d4c29e - - - - 2dd405d9651c0f9b87412b07488d4b03796390e9 - - - - f4b8a55a8b737a513c4531487888ff231126cce9 - - - - 5413228a54cf99ce20ad08e6917605f7a9ceeabe - - - - a17b3f3406caf33fb9160d2464b0945bc2b0a8ad - - - - 2ec2f7e3abf84e60ce2a2e3935e3373242f97d27 - - - - b83c95c8f2337d42ea1b8b1e606ca83c8acc17b8 - - - - 89d9e49eb0c49803ab2bd5d51570f8e688f93196 - - - - 9501fa94de1e6e9a896cc2e29d66424e17d429e4 - - - - 882e3dad4edfc0e2e923d4fc49c78341acea368d - - - - 03671597239a76a8716da20528d4a71d24e44825 - - - - f6a3e069f70f9250d7ae0c5f7497999714552ddc - - - - a7a9803370986ec4de2913c416db11a0c207d8a1 - - - - 4b3f9bbb0f413a4b70392219f501ad782e5c647a - - - - 7f65de9106151c59e1b91eab1c195e5765445894 - - - - 1c801d3a719e843a50f43faceff0bd2bf77f3e82 - - - - 06cd8e287e5cc94bf936726e9a8540283ad42af5 - - - - 555d3279e2485cae5feb3a7c57b0ee0f16ae8ba6 - - - - cd767b5b8690e08ec5b1f231641cd6a4a7d1dec4 - - - - 24e57eaa5bc4c6080577f7555b9b28ba30c298e6 - - - - 262095e2c3ad96a3c892c0e06baad6c995ac52b9 - - - - beba36db67a885e7a43a2b8d0f5b6a1e394fad39 - - - - 079e72f31dcd4e20a786501b6670d581480cb249 - - - - b7bf854b78d3ba9488e4a9c46bf48d6e7501ead5 - - - - 8dd539e1cb8196a3bde56ec0e5d9717bf74d3696 - - - - f96cebcb74f4e9067976240f8da5dff3dbc954e3 - - - - 5d11f1e0772a8eae3d0276c2fc0c36fd024ff969 - - - diff --git a/tests/parser/yum/data/patches-1.xml.solution b/tests/parser/yum/data/patches-1.xml.solution deleted file mode 100644 index 6df7288..0000000 --- a/tests/parser/yum/data/patches-1.xml.solution +++ /dev/null @@ -1,760 +0,0 @@ -fetchmsttfonts.sh-2333 -sha -6b72b4f3617d0d51af28399c0f5e0af401440245 -repodata/patch-fetchmsttfonts.sh-2333.xml -glabels-2348 -sha -b02ba598d8ed5f8a31859d3b34e72e1ddecbe894 -repodata/patch-glabels-2348.xml -openssl-2349 -sha -321ee41de68be4e83dfb74559c14300a59b85ccf -repodata/patch-openssl-2349.xml -gv-2350 -sha -ec9e8a3f3ce2588cecd84ab95ec910d41db5d74b -repodata/patch-gv-2350.xml -tar-2351 -sha -d803372cd5d844ee01ab6fb3d1b4332391fa1206 -repodata/patch-tar-2351.xml -flash-player-2359 -sha -c2de5dd35ec2dcccc118d9d7f539e768dfd5ec50 -repodata/patch-flash-player-2359.xml -lineak_kde-2361 -sha -7fb791963114836621873280c7edd58887b91784 -repodata/patch-lineak_kde-2361.xml -evince-2362 -sha -28f0c33aa4a34830a4b7b8a795db609bfd3d7531 -repodata/patch-evince-2362.xml -capi4hylafax-2366 -sha -98c2d98fe33439563047eef97c6db065c8361bbe -repodata/patch-capi4hylafax-2366.xml -resmgr-2371 -sha -f449fabf0a7bedfc9f561ea5d04e160c521a5186 -repodata/patch-resmgr-2371.xml -release-notes-2374 -sha -e1dd5a93ce9bb796348557d7d8e16ef54fb8d90d -repodata/patch-release-notes-2374.xml -privoxy-2375 -sha -a73445a3630084c867d63868d9d064625a84ea6d -repodata/patch-privoxy-2375.xml -kdeaddons3-konqueror-2383 -sha -792bad7440845613b608c771c2d948607e02759d -repodata/patch-kdeaddons3-konqueror-2383.xml -krusader-2386 -sha -de603b359e148a7666b5b695b76602c4689ff193 -repodata/patch-krusader-2386.xml -gdm-2387 -sha -6dff2c1367613b7eae36db090233bfbf31a92920 -repodata/patch-gdm-2387.xml -gpg-2388 -sha -3266d24fa2fb7aeb4ba303ccd77fbe8b27f75ad0 -repodata/patch-gpg-2388.xml -clamav-2391 -sha -394bec89d3f5f976a9f7ae074a0e4c0d5582139a -repodata/patch-clamav-2391.xml -mono-core-2392 -sha -6630055daac876bcb0a6ebf36f63d28341b1ff6e -repodata/patch-mono-core-2392.xml -sysstat-2401 -sha -d3de77e29165bdbce88310a6ce9f97f3a5368377 -repodata/patch-sysstat-2401.xml -xorg-x11-server-2403 -sha -905a98399c20efb91592d2767ec187823c7b154d -repodata/patch-xorg-x11-server-2403.xml -dazuko-2404 -sha -5314e6c2d4e21a38dd2ea05ee0495d7dd27f0931 -repodata/patch-dazuko-2404.xml -cups-2406 -sha -329b6083dfe59ddb7d50cb9e92686eb7ecc48d6d -repodata/patch-cups-2406.xml -squirrelmail-2409 -sha -b5ec61bcf901f4270fc3ba6a18926c20102c94c9 -repodata/patch-squirrelmail-2409.xml -wxGTK-2411 -sha -c38d7746f8aca8d40347879bfba5d977ca8fc03f -repodata/patch-wxGTK-2411.xml -ImageMagick-2413 -sha -c1dca99b03a2b012c141a64c8fcc494d957baed2 -repodata/patch-ImageMagick-2413.xml -squirrelmail-2417 -sha -f239f615760d15515bd4f0316cc99e40d25a6117 -repodata/patch-squirrelmail-2417.xml -MozillaFirefox-2418 -sha -f30517b5083e9bc007adf9cc974a36fc7bba3f0b -repodata/patch-MozillaFirefox-2418.xml -liboil-2419 -sha -24769a5bbd9e57cd59806b186088d5f0dffa5e30 -repodata/patch-liboil-2419.xml -MozillaThunderbird-2421 -sha -6c2aa38c513f7eeda2b38555182b8200c08f6468 -repodata/patch-MozillaThunderbird-2421.xml -pm-utils-2422 -sha -c0b54062cb5b16cbb18d383beb721c60b2a36f72 -repodata/patch-pm-utils-2422.xml -sysvinit-2424 -sha -640a5b7ca790a3becc9c26d8434adfac560a14c5 -repodata/patch-sysvinit-2424.xml -java-1_4_2-sun-2425 -sha -94c690e13540511db05ee397e9ab5fc9905b086b -repodata/patch-java-1_4_2-sun-2425.xml -java-1_5_0-sun-2427 -sha -fb1786ca30124e82b24e57b694a58da9f920e6b3 -repodata/patch-java-1_5_0-sun-2427.xml -cups-2430 -sha -bb6aea44ad2e2ddb0f50842b15f791b7c0a0b346 -repodata/patch-cups-2430.xml -w3m-2433 -sha -d9ba43f21238b71a7b8cfb6d9256e404cffb7cc0 -repodata/patch-w3m-2433.xml -unison-2436 -sha -42e904686825e904752238b85085771ee51965c7 -repodata/patch-unison-2436.xml -lvm2-2438 -sha -cd88e95ae02706069fe6f3031178bf26e9e06d3a -repodata/patch-lvm2-2438.xml -yast2-sudo-2441 -sha -ab7741ef2411c11a7ec941fc8736feebfca73398 -repodata/patch-yast2-sudo-2441.xml -krb5-2442 -sha -2f8c1cd5d147c89b06c0898d4392f1196098236f -repodata/patch-krb5-2442.xml -xorg-x11-server-2444 -sha -a26f9f36ed0a0f6a45cb5369234ff44d6c535310 -repodata/patch-xorg-x11-server-2444.xml -sax2-2445 -sha -61a24339218f1fd480085fe0e3f754baa8820cb3 -repodata/patch-sax2-2445.xml -python-2446 -sha -c37bf9a8ff3810e2c9a674bd9aadfed24f8c2ab2 -repodata/patch-python-2446.xml -cacti-2447 -sha -2cdfac93ac338ccf87abe8049f13bb415428a279 -repodata/patch-cacti-2447.xml -kdelibs3-2448 -sha -9adf70721a91e7666c40c45c1c2270bd673d2ac4 -repodata/patch-kdelibs3-2448.xml -kdeutils3-extra-2450 -sha -d0a21646dc9d1c244e7e35888a0fb52aaeb1b5e2 -repodata/patch-kdeutils3-extra-2450.xml -jarnal-2451 -sha -8daf1728afb47779fd28e0021ea6ff55f18f1149 -repodata/patch-jarnal-2451.xml -kdelibs3-2452 -sha -a515c1a96ac1b55f50852cfda93a49004ce4c79a -repodata/patch-kdelibs3-2452.xml -xorg-x11-server-2453 -sha -a3f5b8927b7f1f47f347e7ee3ab821995dca00b7 -repodata/patch-xorg-x11-server-2453.xml -cyrus-imapd-2454 -sha -4fdf8c67eaa488edbe668ead3d995caa38a1936b -repodata/patch-cyrus-imapd-2454.xml -opera-2456 -sha -5209e7b0a7f89ec7c225de065d4cbc4fbefcbddb -repodata/patch-opera-2456.xml -mediawiki-2457 -sha -669837ce13f07df59ac79ce6201c176342ed27c4 -repodata/patch-mediawiki-2457.xml -compiz-2458 -sha -a41806bf5d57c36825ad832be3d0f13d1695d70a -repodata/patch-compiz-2458.xml -libzypp-2460 -sha -bdbbba1841bebd9822458f3a3fb1c88141e78281 -repodata/patch-libzypp-2460.xml -bzip2-2465 -sha -1b84ea4aa922b21a7039330c0fdbf2775dd13444 -repodata/patch-bzip2-2465.xml -autoyast2-2466 -sha -c7266496955cee3242ae100ffd731ce4323d6b89 -repodata/patch-autoyast2-2466.xml -squid-2467 -sha -883f737c6ecedd05670bad4784a37e2c67a8c5da -repodata/patch-squid-2467.xml -totem-2468 -sha -538c771158fa860793ed285990641b1ed04330b5 -repodata/patch-totem-2468.xml -java-1_4_2-sun-demo-2469 -sha -32ae23cb16bff2f8e6ec4ba168e6a75d541efc8c -repodata/patch-java-1_4_2-sun-demo-2469.xml -ulogd-2470 -sha -cea742686fabc65af02a9dd7bea89b39cbdb62c1 -repodata/patch-ulogd-2470.xml -xpdf-tools-2472 -sha -8f021c3fec51df6155c44276b87260bbf074c0a2 -repodata/patch-xpdf-tools-2472.xml -xpdf-2473 -sha -73e3b82edf6537e759d3c7fe103654baad9155cf -repodata/patch-xpdf-2473.xml -neon-2476 -sha -9b83d8d408138a521c7926be0c569047eb5d866a -repodata/patch-neon-2476.xml -libzypp-2477 -sha -837cb40fa331f256281577e8ca81fe73b9c27e2a -repodata/patch-libzypp-2477.xml -gtk2-2479 -sha -050a31137f1ff1ca986c27addaf894deaa10b6ad -repodata/patch-gtk2-2479.xml -nss_ldap-2480 -sha -cd51f150dda049a82acca2ef4b0524465947ddc2 -repodata/patch-nss_ldap-2480.xml -cups-2481 -sha -ec3095ea0c8b996b49061d79f7afb780ab4ea84b -repodata/patch-cups-2481.xml -bluez-utils-2482 -sha -c53aeb36ef68f4f1b6e6ac0f38df63c22f22359d -repodata/patch-bluez-utils-2482.xml -xine-lib-2487 -sha -31c74fc5d4ba42bf3301fa95b806caa978659127 -repodata/patch-xine-lib-2487.xml -kdegraphics3-2489 -sha -7cbcd6c1064568aeb0e523d2587336e742e44fcb -repodata/patch-kdegraphics3-2489.xml -xorg-x11-Xvnc-2491 -sha -4f331f6ea3e5c5a90f66a871162114ca94f92f76 -repodata/patch-xorg-x11-Xvnc-2491.xml -bluez-utils-2492 -sha -b5a4c65f2356613b4de6ad1bc2dd0582e77b0ee6 -repodata/patch-bluez-utils-2492.xml -koffice-2495 -sha -18e4e361c7688a57f7b7963c359fee4f58d29b08 -repodata/patch-koffice-2495.xml -gtk2-2499 -sha -f812f28e10039b5bfd249e3902b905e92a7eb769 -repodata/patch-gtk2-2499.xml -hal-2500 -sha -90c4516d8073322a05f4235dbe1f7c4770c6e4e0 -repodata/patch-hal-2500.xml -libsoup-2503 -sha -7d9f7a7fdd96843f5d962aef984cc0c5c2534f30 -repodata/patch-libsoup-2503.xml -squid-2504 -sha -fffd63b332907c46b926499e27b6ec0ad9025ddb -repodata/patch-squid-2504.xml -acroread-2506 -sha -b0bbd764da5ec2651bf030e7051d045341ddbdd7 -repodata/patch-acroread-2506.xml -flash-player-2509 -sha -5e2c95f36ceb9c7d94c4a2df8ec60aaf36dde810 -repodata/patch-flash-player-2509.xml -compat-g77-2510 -sha -11a15f477e35a5e4879a8883074c13e6ab321141 -repodata/patch-compat-g77-2510.xml -libgtop-2512 -sha -c71c5d298bf5b11fcc0c0865b1302a7ba9970c0c -repodata/patch-libgtop-2512.xml -zypper-2513 -sha -fb916bb899aa6d2b1ae8d211ee84ceb0a66f1fd8 -repodata/patch-zypper-2513.xml -smb4k-2514 -sha -558c89fe1d04efa2d7c5988be9344376f2eacace -repodata/patch-smb4k-2514.xml -amarok-2516 -sha -18473edb5c4b6853aea94db3883bcfe496b5b6ee -repodata/patch-amarok-2516.xml -yast2-trans-de-2518 -sha -4c3d0446ffd36ce86b40da43135913a18349ef44 -repodata/patch-yast2-trans-de-2518.xml -compiz-2519 -sha -188b82cfb54dd61f0fe0e5beea054d5a9591e0a5 -repodata/patch-compiz-2519.xml -fetchmail-2520 -sha -85a08c9bc4eebac24854a9eb7da257a3fe8f5b6d -repodata/patch-fetchmail-2520.xml -spamassassin-2523 -sha -e711370f446cf3538fbaf64c9faaf0eadaedb580 -repodata/patch-spamassassin-2523.xml -libzypp-2524 -sha -16921f0179c7c3dcb504b9ffb82abd32e84086ac -repodata/patch-libzypp-2524.xml -yast2-printer-2525 -sha -147a7b5f084395bd427c273ba8f25f312cc87193 -repodata/patch-yast2-printer-2525.xml -powersave-2526 -sha -afd07ae38e0585e615022a7df3cd469c2c99fdbb -repodata/patch-powersave-2526.xml -cups-2527 -sha -5b9d9747bffc3368ea2f7c8c7b3ff8e0cc4605f7 -repodata/patch-cups-2527.xml -bind-2529 -sha -1b1c1fdb9ad132cd6504c8b437cfe519bc9c0dfa -repodata/patch-bind-2529.xml -libzypp-2533 -sha -2af5b888f4f4c9b9be8b9bc2aaae02efd436b924 -repodata/patch-libzypp-2533.xml -chmlib-2536 -sha -664ef6d8c867824f20b15a9af4d2957fd79897bd -repodata/patch-chmlib-2536.xml -kchmviewer-2539 -sha -ad29afc8f5dd7ca1f4faa4a2aaed644c80d844b6 -repodata/patch-kchmviewer-2539.xml -rrdtool-2540 -sha -8cc33adb78b9fccccc7f2fc03d5df13f8a79eae5 -repodata/patch-rrdtool-2540.xml -yast2-sound-2541 -sha -ccece044c2ba608c8233d70a4aa68c466c1862f1 -repodata/patch-yast2-sound-2541.xml -fetchmail-2542 -sha -339f1a841955652ccaccd9c9e936c21abe85a2f2 -repodata/patch-fetchmail-2542.xml -kdenetwork3-InstantMessenger-2547 -sha -3ef0e4f08055c2f458c0efa5dfdd4d7aee384122 -repodata/patch-kdenetwork3-InstantMessenger-2547.xml -openssl-2548 -sha -67602c57de3f98ffd2c7434b6952f79481feceb8 -repodata/patch-openssl-2548.xml -autofs-2549 -sha -4da7e1958d56142f48d99b9ab1b16425aeb0cd96 -repodata/patch-autofs-2549.xml -qemu-2550 -sha -940c331de3e40be9f570e012b8ca9bbab6d594d2 -repodata/patch-qemu-2550.xml -cross-avr-binutils-2551 -sha -da26f814db1c2f04cd8fc27495aecdbd66f73daf -repodata/patch-cross-avr-binutils-2551.xml -digikam-2552 -sha -299f0dff3447555cea60a63fdf97e81e1bd56096 -repodata/patch-digikam-2552.xml -samba-2555 -sha -a7a501a1465dfcb3e125d14c1a67efd2638be166 -repodata/patch-samba-2555.xml -fetchmail-2563 -sha -10b87459f9209a43097bebd31f9ec8cff4354c11 -repodata/patch-fetchmail-2563.xml -kdegraphics3-pdf-2565 -sha -8d0d0b963c5fa85c92d5a9b5c86c88063b2faf8e -repodata/patch-kdegraphics3-pdf-2565.xml -koffice-wordprocessing-2577 -sha -5f43e01206494f0d0cbab846bfbb157285e22efc -repodata/patch-koffice-wordprocessing-2577.xml -samba-2584 -sha -5e86626239c4798708e7d2432708cf98d6a001d2 -repodata/patch-samba-2584.xml -ImageMagick-2585 -sha -5af58df93d8f36428726d0cf55fc5bb6a18a8bfd -repodata/patch-ImageMagick-2585.xml -poppler-2590 -sha -924e7f989e3d6f159e717e2d76b21de572ce7ec2 -repodata/patch-poppler-2590.xml -NetworkManager-kde-2591 -sha -93a54883e5b9170839fc81a72c534f76e7987c19 -repodata/patch-NetworkManager-kde-2591.xml -GraphicsMagick-2593 -sha -64a57f29d835e46f7f00e939d4b505cb546d0654 -repodata/patch-GraphicsMagick-2593.xml -chmlib-2595 -sha -88ee8256ac3875e2b087ab9723bb13f071f9de73 -repodata/patch-chmlib-2595.xml -gpdf-2596 -sha -115f31bcb61f37f264daa4b0ef8220816be05de7 -repodata/patch-gpdf-2596.xml -kdenetwork3-InstantMessenger-2599 -sha -c5a5fd01f5266d3f30fe33b5fc1679b35af3d4d4 -repodata/patch-kdenetwork3-InstantMessenger-2599.xml -kdebase3-2600 -sha -b6654a37408c21d66e60cf7a78a1cddb991b797a -repodata/patch-kdebase3-2600.xml -pam-2601 -sha -fd76c123487f884cf10b161c87afe5b7bc9f05f8 -repodata/patch-pam-2601.xml -fetchmail-2602 -sha -d3533c47354977c9f821eb4e579c43ea919d4488 -repodata/patch-fetchmail-2602.xml -novfs-kmp-bigsmp-2630 -sha -06f48c215e805213e339fa581670fb35e2151786 -repodata/patch-novfs-kmp-bigsmp-2630.xml -clamav-2632 -sha -b5217b10a1a3e513085665d994dded954a72e884 -repodata/patch-clamav-2632.xml -timezone-2634 -sha -e2d31e95095a1c7dd242c577f3a394a39d7e75be -repodata/patch-timezone-2634.xml -gwenview-2637 -sha -b6f7e30d0d8f3e699e8593a178b5fd63c865ad0e -repodata/patch-gwenview-2637.xml -wireshark-2638 -sha -7ebc8745836d63bdfee712bca5c71ba328877047 -repodata/patch-wireshark-2638.xml -hal-resmgr-2639 -sha -4eb206f1dba689554bc3e113fd87ad2a4fcdbf78 -repodata/patch-hal-resmgr-2639.xml -klamav-2640 -sha -505cc81dc924efb58154806700b1d261cc33fbb9 -repodata/patch-klamav-2640.xml -ekiga-2641 -sha -3d960c76d7dd38393c631c63212f0a8c4f08ad98 -repodata/patch-ekiga-2641.xml -libwpd-2642 -sha -b31ced09fece6d2f9fad37653acfda9eb9e7ba2b -repodata/patch-libwpd-2642.xml -rubygems-2644 -sha -26a5b6e1a3c77afa7fd77171bcbef2d78f7df11f -repodata/patch-rubygems-2644.xml -MozillaFirefox-2647 -sha -420d992e8b4436cc7ebc0609183ba040db340dc5 -repodata/patch-MozillaFirefox-2647.xml -koffice-wordprocessing-2648 -sha -bf0b411e4eb5494a27ebef8d5b9cd923da4fe2c8 -repodata/patch-koffice-wordprocessing-2648.xml -agfa-fonts-2650 -sha -19126ca4e55852b98ffa69c6c3fcff12743af49c -repodata/patch-agfa-fonts-2650.xml -OpenOffice_org-2652 -sha -0bbcdeab9294272a677f9b4a7b57e13701244010 -repodata/patch-OpenOffice_org-2652.xml -gdm-2653 -sha -df03ccdfcb0f188ac3072c5086ab86b425a66f8e -repodata/patch-gdm-2653.xml -ruby-2655 -sha -8ffefa033ac19a70938a7af71854184d6b902e45 -repodata/patch-ruby-2655.xml -sylpheed-claws-2685 -sha -df121b6b7cc82715a4544f491a0104b50a28eb20 -repodata/patch-sylpheed-claws-2685.xml -php5-2687 -sha -f34eb5a2f4399578c78e6dca5dd165077787c806 -repodata/patch-php5-2687.xml -klamav-2688 -sha -da442e32fe4401897261051bf817e1a029e804c3 -repodata/patch-klamav-2688.xml -clamav-2690 -sha -ff002a87486fbd2c68b445e58b6ac0d307e8dbad -repodata/patch-clamav-2690.xml -seamonkey-2691 -sha -fd8198e09f073515c67cf90a879ff57bfde0cfa9 -repodata/patch-seamonkey-2691.xml -gnokii-2689 -sha -2453275e874a7d65c9f21cc50885f50202d617bf -repodata/patch-gnokii-2689.xml -doxygen-2694 -sha -fad24b42e3d7d8c35e410017ca85dd375f2b7f1d -repodata/patch-doxygen-2694.xml -enlightenment-2695 -sha -e74c7b27498161c9ba056869ba1813658f4ef4e0 -repodata/patch-enlightenment-2695.xml -gnome-terminal-2696 -sha -36f9b9e6ff739fe7d82a58b59fcb74be6581a752 -repodata/patch-gnome-terminal-2696.xml -kpowersave-2698 -sha -c1e569e948b46ddcd33369c9479e6ad92fb8c7ec -repodata/patch-kpowersave-2698.xml -clamav-2700 -sha -3dd423deeb41c58b11f54184d59367d152d78f24 -repodata/patch-clamav-2700.xml -autofs-2703 -sha -678cae267889c434cbdd81654066244270a341b6 -repodata/patch-autofs-2703.xml -ivtv-kmp-bigsmp-2704 -sha -9539aa93b99854e21cc69248bd82249f75a6f6e0 -repodata/patch-ivtv-kmp-bigsmp-2704.xml -kernel-2705 -sha -fedf719a3be03d6c93fc04f78b50ce7be1465606 -repodata/patch-kernel-2705.xml -yast2-printer-2706 -sha -b95d82b3c1e22c1ce2ec2ea96ffb9ba94e1a2adb -repodata/patch-yast2-printer-2706.xml -MozillaThunderbird-2734 -sha -be5018a378fbce22ad2f1f94266f251dfb0fecc2 -repodata/patch-MozillaThunderbird-2734.xml -gstreamer010-plugins-base-2737 -sha -93496c003d8a1565e88fa37bc28b62b685b86223 -repodata/patch-gstreamer010-plugins-base-2737.xml -gstreamer010-plugins-base-2805 -sha -40b9fd23e3eb4141d8b28794c40aeebdee7dcc1d -repodata/patch-gstreamer010-plugins-base-2805.xml -evolution-2824 -sha -7d6301a829eda6ff7ab006302c38943693defd44 -repodata/patch-evolution-2824.xml -avahi-2982 -sha -c338bfb439e94dc27774a76d860285577b9ade19 -repodata/patch-avahi-2982.xml -syslog-ng-2984 -sha -eb0c412124838a4ff2ff884642a88fac1578da8f -repodata/patch-syslog-ng-2984.xml -tomcat5-2985 -sha -95ce884347ae5fb4f8b030f9e302f75dec58cefd -repodata/patch-tomcat5-2985.xml -xine-lib-2989 -sha -91dba1fffdd033eb289fec17dd2a288658dbb586 -repodata/patch-xine-lib-2989.xml -xorg-x11-libs-3070 -sha -069398c5d7b94dc32c6102243b478584a76b84bb -repodata/patch-xorg-x11-libs-3070.xml -rekall-2991 -sha -2c534ad1e2a36b668f7d22f37b5e0457f5892359 -repodata/patch-rekall-2991.xml -gpg-2995 -sha -bce7d390d3db0bdedf63304a9b739645e7c10eb8 -repodata/patch-gpg-2995.xml -gstreamer010-plugins-base-2992 -sha -5d0fa6b2d1a729ed86d6bdc54bb3eeabb1bfea38 -repodata/patch-gstreamer010-plugins-base-2992.xml -unrar-2996 -sha -c1e7abcd4dc9ffda6f97dc8c98e68d36f0fa51e5 -repodata/patch-unrar-2996.xml -ktorrent-2998 -sha -ff9e274c83ef488d9eed486c7eae9f2952d4c29e -repodata/patch-ktorrent-2998.xml -ekiga-3023 -sha -2dd405d9651c0f9b87412b07488d4b03796390e9 -repodata/patch-ekiga-3023.xml -krb5-apps-servers-3021 -sha -f4b8a55a8b737a513c4531487888ff231126cce9 -repodata/patch-krb5-apps-servers-3021.xml -pam_ssh-3024 -sha -5413228a54cf99ce20ad08e6917605f7a9ceeabe -repodata/patch-pam_ssh-3024.xml -TeXmacs-3030 -sha -a17b3f3406caf33fb9160d2464b0945bc2b0a8ad -repodata/patch-TeXmacs-3030.xml -perl-Bootloader-3029 -sha -2ec2f7e3abf84e60ce2a2e3935e3373242f97d27 -repodata/patch-perl-Bootloader-3029.xml -kernel-3032 -sha -b83c95c8f2337d42ea1b8b1e606ca83c8acc17b8 -repodata/patch-kernel-3032.xml -NetworkManager-3031 -sha -89d9e49eb0c49803ab2bd5d51570f8e688f93196 -repodata/patch-NetworkManager-3031.xml -file-3033 -sha -9501fa94de1e6e9a896cc2e29d66424e17d429e4 -repodata/patch-file-3033.xml -squid-3036 -sha -882e3dad4edfc0e2e923d4fc49c78341acea368d -repodata/patch-squid-3036.xml -libwpd-3038 -sha -03671597239a76a8716da20528d4a71d24e44825 -repodata/patch-libwpd-3038.xml -opensuse-updater-3037 -sha -f6a3e069f70f9250d7ae0c5f7497999714552ddc -repodata/patch-opensuse-updater-3037.xml -krb5-3045 -sha -a7a9803370986ec4de2913c416db11a0c207d8a1 -repodata/patch-krb5-3045.xml -qt3-3048 -sha -4b3f9bbb0f413a4b70392219f501ad782e5c647a -repodata/patch-qt3-3048.xml -gwenview-3055 -sha -7f65de9106151c59e1b91eab1c195e5765445894 -repodata/patch-gwenview-3055.xml -libqt4-3056 -sha -1c801d3a719e843a50f43faceff0bd2bf77f3e82 -repodata/patch-libqt4-3056.xml -ktorrent-3057 -sha -06cd8e287e5cc94bf936726e9a8540283ad42af5 -repodata/patch-ktorrent-3057.xml -kdelibs3-3058 -sha -555d3279e2485cae5feb3a7c57b0ee0f16ae8ba6 -repodata/patch-kdelibs3-3058.xml -inkscape-3062 -sha -cd767b5b8690e08ec5b1f231641cd6a4a7d1dec4 -repodata/patch-inkscape-3062.xml -perl-Bootloader-3059 -sha -24e57eaa5bc4c6080577f7555b9b28ba30c298e6 -repodata/patch-perl-Bootloader-3059.xml -scpm-3064 -sha -262095e2c3ad96a3c892c0e06baad6c995ac52b9 -repodata/patch-scpm-3064.xml -mediawiki-3065 -sha -beba36db67a885e7a43a2b8d0f5b6a1e394fad39 -repodata/patch-mediawiki-3065.xml -freetype2-3066 -sha -079e72f31dcd4e20a786501b6670d581480cb249 -repodata/patch-freetype2-3066.xml -xorg-x11-libX11-3069 -sha -b7bf854b78d3ba9488e4a9c46bf48d6e7501ead5 -repodata/patch-xorg-x11-libX11-3069.xml -xorg-x11-server-3071 -sha -8dd539e1cb8196a3bde56ec0e5d9717bf74d3696 -repodata/patch-xorg-x11-server-3071.xml -xmms-3073 -sha -f96cebcb74f4e9067976240f8da5dff3dbc954e3 -repodata/patch-xmms-3073.xml -spamassassin-3077 -sha -5d11f1e0772a8eae3d0276c2fc0c36fd024ff969 -repodata/patch-spamassassin-3077.xml diff --git a/tests/parser/yum/data/patches.xsl b/tests/parser/yum/data/patches.xsl deleted file mode 100644 index 10b4cc2..0000000 --- a/tests/parser/yum/data/patches.xsl +++ /dev/null @@ -1,13 +0,0 @@ - - - - - -
-
-
-
-
-
-
diff --git a/tests/repo/yum/YUMDownloader_test.cc b/tests/repo/yum/YUMDownloader_test.cc index 32a4f0c..fa60894 100644 --- a/tests/repo/yum/YUMDownloader_test.cc +++ b/tests/repo/yum/YUMDownloader_test.cc @@ -4,21 +4,19 @@ #include #include #include +#include #include "zypp/base/Logger.h" #include "zypp/Url.h" #include "zypp/PathInfo.h" #include "zypp/TmpPath.h" #include "zypp/repo/yum/Downloader.h" +#include "tests/zypp/KeyRingTestReceiver.h" using std::cout; using std::endl; -using std::string; using namespace zypp; using namespace boost::unit_test; -using namespace zypp::repo; - -#include "tests/zypp/KeyRingTestReceiver.h" #define DATADIR (Pathname(TESTS_SRC_DIR) + "/repo/yum/data") @@ -27,42 +25,42 @@ BOOST_AUTO_TEST_CASE(yum_download) KeyRingTestReceiver keyring_callbacks; keyring_callbacks.answerAcceptKey(KeyRingReport::KEY_TRUST_TEMPORARILY); - Pathname p = DATADIR + "/10.2-updates-subset"; + Pathname p = DATADIR + "/ZCHUNK"; Url url(p.asDirUrl()); MediaSetAccess media(url); RepoInfo repoinfo; repoinfo.setAlias("testrepo"); repoinfo.setPath("/"); - yum::Downloader yum(repoinfo); + repo::yum::Downloader yum(repoinfo); filesystem::TmpDir tmp; Pathname localdir(tmp.path()); yum.download(media, localdir); - const char* files[] = - { -// "filelists.xml.gz", -// "other.xml.gz", - "patches.xml", - "patch-fetchmsttfonts.sh-2333.xml", - "patch-flash-player-2359.xml", - "patch-glabels-2348.xml", - "patch-gv-2350.xml", - "patch-openssl-2349.xml", - "patch-tar-2351.xml", - "primary.xml.gz", - "repomd.xml", - "repomd.xml.asc", - "repomd.xml.key", - NULL +#ifdef LIBSOLVEXT_FEATURE_ZSTD_COMPRESSION + const bool zchunk = true; +#else + const bool zchunk = false; +#endif + std::map files { + { "filelists.xml.gz", false&&!zchunk }, + { "filelists.xml.zck", false&&zchunk }, + { "other.xml.gz", false&&!zchunk }, + { "other.xml.zck", false&&zchunk }, + { "patterns.xml.gz", true }, + { "primary.xml.gz", !zchunk }, + { "primary.xml.zck", zchunk }, + { "repomd.xml", true }, + { "repomd.xml.asc", true }, + { "repomd.xml.key", true }, }; - int i=0; - while ( files[i] != NULL ) + for ( const auto & el : files ) { - BOOST_CHECK_MESSAGE( PathInfo(localdir + "/repodata/" + files[i] ).isExist(), (string("/repodata/") + files[i]).c_str() ); - i++; + Pathname stem { "/repodata/"+el.first }; + bool downloaded { PathInfo(localdir/stem).isExist() }; + BOOST_CHECK_MESSAGE( downloaded == el.second, std::string(el.second?"missing ":"unexpected ")+stem ); } } diff --git a/tests/repo/yum/data/ZCHUNK/repodata/filelists.xml.gz b/tests/repo/yum/data/ZCHUNK/repodata/filelists.xml.gz new file mode 100644 index 0000000..e69de29 diff --git a/tests/repo/yum/data/ZCHUNK/repodata/filelists.xml.zck b/tests/repo/yum/data/ZCHUNK/repodata/filelists.xml.zck new file mode 100644 index 0000000..e69de29 diff --git a/tests/repo/yum/data/ZCHUNK/repodata/other.xml.gz b/tests/repo/yum/data/ZCHUNK/repodata/other.xml.gz new file mode 100644 index 0000000..e69de29 diff --git a/tests/repo/yum/data/ZCHUNK/repodata/other.xml.zck b/tests/repo/yum/data/ZCHUNK/repodata/other.xml.zck new file mode 100644 index 0000000..e69de29 diff --git a/tests/repo/yum/data/ZCHUNK/repodata/patterns.xml.gz b/tests/repo/yum/data/ZCHUNK/repodata/patterns.xml.gz new file mode 100644 index 0000000..e69de29 diff --git a/tests/repo/yum/data/ZCHUNK/repodata/primary.xml.gz b/tests/repo/yum/data/ZCHUNK/repodata/primary.xml.gz new file mode 100644 index 0000000..e69de29 diff --git a/tests/repo/yum/data/ZCHUNK/repodata/primary.xml.zck b/tests/repo/yum/data/ZCHUNK/repodata/primary.xml.zck new file mode 100644 index 0000000..e69de29 diff --git a/tests/repo/yum/data/ZCHUNK/repodata/repomd.xml b/tests/repo/yum/data/ZCHUNK/repodata/repomd.xml new file mode 100644 index 0000000..deeabc4 --- /dev/null +++ b/tests/repo/yum/data/ZCHUNK/repodata/repomd.xml @@ -0,0 +1,70 @@ + + + 1579611877 + + obsrepository://build.opensuse.org/OBS:Server:Unstable/openSUSE_15.1 + obsbuildid:1547846024 + + + e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 + 0e6e755baf18198ef58bb2f4630911b0628f1439ddbc14f486842a3238dbb99b + + 1579611877 + 1 + 599948 + + + e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 + 35ebf812be754b3b5380fd662ec35d3b00302e2f112d0a339710547c19794505 + + 1579611877 + 1 + 5344403 + + + e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 + 914babd921de65377d9a746df744865dbe6b45e185db011644b955b6e24b5aeb + + 1579611877 + 1 + 1772089 + + + e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 + 0e6e755baf18198ef58bb2f4630911b0628f1439ddbc14f486842a3238dbb99b + dc6c50934d7847077e559d740d5363d2d5885e40a811bfb1c6ec71007a7dc73f + + 1579611877 + 1 + 599948 + 3265 + + + e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 + 35ebf812be754b3b5380fd662ec35d3b00302e2f112d0a339710547c19794505 + 9d33f302afe9a38630b1c6519a8e0c820902c2247447636d89c50f98a6344e38 + + 1579611877 + 1 + 5344403 + 3260 + + + e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 + 914babd921de65377d9a746df744865dbe6b45e185db011644b955b6e24b5aeb + 7ca38348f174e5b9cba5df862b48da22029d10c7288125b59871590706aca580 + + 1579611877 + 1 + 1772089 + 3262 + + + e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 + cc15cbebe9bd8360d90384cb4ce2aefd9fdf69940090dd719b2d3908dba79d53 + + 1579611877 + 1 + 1014 + + diff --git a/tests/repo/yum/data/ZCHUNK/repodata/repomd.xml.asc b/tests/repo/yum/data/ZCHUNK/repodata/repomd.xml.asc new file mode 100644 index 0000000..d4560eb Binary files /dev/null and b/tests/repo/yum/data/ZCHUNK/repodata/repomd.xml.asc differ diff --git a/tests/repo/yum/data/ZCHUNK/repodata/repomd.xml.key b/tests/repo/yum/data/ZCHUNK/repodata/repomd.xml.key new file mode 100644 index 0000000..70f9b57 --- /dev/null +++ b/tests/repo/yum/data/ZCHUNK/repodata/repomd.xml.key @@ -0,0 +1,30 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- + +mQENBF4oEngBCADqWMfMbd6s4rSQl6/uOpsiFIMKsoEtUAQQdodXTov/kxNKi43D +C9SQPB6jicPpG3sGJFQVLb1lRA8Hsqu9wi0HYc5af0Jm4smFJJl6lhYKhDm7JbO6 +OGxGvN/Bj//afW+KDWz2YfeY4PNojPGME3d6k1rnwazC6pB0sELHeWbAwSGx5W6P +DVgMddSQIY6OsfXf81NGfg6mgmWDq5t+bvmltKGUfRsiPODaaMOOnpLfowTL0VoF +B8r1CscV8Y4M6OyO4PmycQU26GTIcVzFNBcMHg5+211bmZJb4zTV45wjsEbYr27x +7pOd7FE10AtNW/tRkt+mW0QmoLEgbmd9/APBABEBAAG0Hnp5cHB0ZXN0c3VpdGUg +PHp5cHBAdGVzdHN1aXRlPokBVAQTAQgAPhYhBNp/RmE26oYTpNXGWYajNLYPDprl +BQJeKBJ4AhsDBQkDwmcABQsJCAcCBhUKCQgLAgQWAgMBAh4BAheAAAoJEIajNLYP +DprlQ5gIANbKTou2WsZYfV204oungoJcsh2DRQEcMbY0mdiZ5BOWTTME3TbdA6jc +iPFOYzX/Sw9ZVB6mEqWeeEHJzhzE2NZgkQA0ONC+0gn2r5sxr9Rl4zG3/sJN1lrs +YyboRhgyB32EGO7g9nxEHBAKLavsWifRKJDeX8loVjOCzcrTNARpnun4TDc6ErHL +bvKqUiz3jH7r3bAlmQL2XJsL1fiX9lQWKl9nEqTHkT4KNyi1RcJlpTl3C5nhLc4z +w9y5k3WOFgy8S8kgWC9uidarUZfi8uL7e6IM/2WgBqrtyTqWHvqtUsQlzcKEio+w +sauvwYkufFaOApnB69HEv3SCWnmDCEi5AQ0EXigSeAEIAN4ATwBho89Tqo9WzotB +czDubcWD8FA4UFxPDlrY9YrUtHuDrUUsnT+jUzOI41VRrw4EC1RKHKZRndAoD+66 +gwPdGJJXPJhl+ZIUXNJ7gwot6ffOMnr+Htft8a7ZRErUCDcD/gd9fKSycWcFdGjn +nYQ17f91dPIpj3//OwoiYpxpcqMjKh2IYqGkDyem4DfCNi+3aHMldwHwlgr3Z4Ne +FjmCpBhEb7mTginZhq5bXnS3G2pteIifLo8pC+N+rG/Vw+F0DYPGKuDqQQXwoqVw +WVSnhpfUauls7ROM3zndoW9eZ+qkTCA0WqYxlIVwVgsZwwhg1dGnqFwl8AJfCa1O +/nEAEQEAAYkBPAQYAQgAJhYhBNp/RmE26oYTpNXGWYajNLYPDprlBQJeKBJ4AhsM +BQkDwmcAAAoJEIajNLYPDprlsAIIAMejrcg+WRiFKAt6JvkKlc8DrnV8H6Da7KFU +SfoqFkIRxR3b7/oUsrvy1AWkeDhXIe3ba36+4tXTjXJGTfmWVq68V6Pcp0LdQ5qM +omalDGlbmb7jlbm+MuzN6pTOGKzb70CtaoqSasLFBqzJ/ytC1dPZZHjukKE56WJ2 +JVsZzslxXHp1gpWQxGNiPblM207fg8UWla8P6hvHaDOk90UnwPkOvHjmhKmPEse6 +Eo3kMmriAErInjc+qGFcBWLSP7GzDT1+gmzw6w0JX6hTldP9FeMfZjv8ANRVeUns +TbDUG+KCCihRCmQorzrDAi25ai++sgAhvj4Np4qz3qLop81KExA= +=uIZP +-----END PGP PUBLIC KEY BLOCK----- diff --git a/tests/zypp/CMakeLists.txt b/tests/zypp/CMakeLists.txt index a0201d4..b6a08ed 100644 --- a/tests/zypp/CMakeLists.txt +++ b/tests/zypp/CMakeLists.txt @@ -21,6 +21,7 @@ ADD_TESTS( Fetcher FileChecker Flags + GZStream InstanceId KeyRing Locale @@ -54,3 +55,9 @@ ADD_TESTS( Vendor2 ) +IF (ENABLE_ZCHUNK_COMPRESSION) + ADD_TESTS ( + ZChunk + ) +ENDIF(ENABLE_ZCHUNK_COMPRESSION) + diff --git a/tests/zypp/GZStream_test.cc b/tests/zypp/GZStream_test.cc new file mode 100644 index 0000000..f34ca9a --- /dev/null +++ b/tests/zypp/GZStream_test.cc @@ -0,0 +1,80 @@ +// Boost.Test +#include + +#include +#include +#include + +BOOST_AUTO_TEST_CASE(gz_simple_read_write) +{ + const zypp::Pathname file = zypp::Pathname(TESTS_BUILD_DIR) / "test.gz"; + const std::string testString("HelloWorld"); + + { + zypp::ofgzstream strOut( file.c_str() ); + BOOST_REQUIRE ( strOut.is_open() ); + BOOST_REQUIRE ( !strOut.fail() ); + BOOST_REQUIRE ( strOut.getbuf().canWrite() ); + BOOST_REQUIRE ( !strOut.getbuf().canRead() ); + strOut << testString; + BOOST_REQUIRE ( !strOut.fail() ); + } + + { + std::string test; + zypp::ifgzstream str( file.c_str() ); + BOOST_REQUIRE ( str.is_open() ); + BOOST_REQUIRE ( !str.fail() ); + BOOST_REQUIRE ( !str.getbuf().canWrite() ); + BOOST_REQUIRE ( str.getbuf().canRead() ); + str >> test; + BOOST_REQUIRE ( !str.fail() ); + BOOST_REQUIRE_EQUAL( test, testString ); + } + + { + zypp::InputStream iStr( file ); + BOOST_REQUIRE( typeid( iStr.stream() ) == typeid( zypp::ifgzstream& ) ); + } +} + +BOOST_AUTO_TEST_CASE(gz_seek) +{ + const zypp::Pathname file = zypp::Pathname(TESTS_BUILD_DIR) / "testseek.gz"; + const std::string testString("Hello World!\nLet's see if seeking works!"); + + { + zypp::ofgzstream strOut( file.c_str() ); + BOOST_REQUIRE( strOut.is_open() ); + strOut << testString; + } + + //gzseek only supports SEEK_SET (beg) and SEEK_CUR (cur), SEEK_END (end) is not supported + { + std::string test; + zypp::ifgzstream str( file.c_str() ); + str.seekg( 6, std::ios_base::beg ); + BOOST_REQUIRE ( !str.fail() ); + BOOST_REQUIRE_EQUAL( str.tellg(), 6 ); + str >> test; + BOOST_REQUIRE_EQUAL( test, "World!" ); + BOOST_REQUIRE ( !str.fail() ); + BOOST_REQUIRE_EQUAL( str.tellg(), 12 ); + + str.seekg( 7, std::ios_base::cur ); + BOOST_REQUIRE ( !str.fail() ); + BOOST_REQUIRE_EQUAL( str.tellg(), 19 ); + str >> test; + BOOST_REQUIRE_EQUAL( test, "see" ); + BOOST_REQUIRE ( !str.fail() ); + BOOST_REQUIRE_EQUAL( str.tellg(), 22 ); + + str.seekg( 0, std::ios_base::beg ); + BOOST_REQUIRE ( !str.fail() ); + BOOST_REQUIRE_EQUAL( str.tellg(), 0 ); + str >> test; + BOOST_REQUIRE ( !str.fail() ); + BOOST_REQUIRE_EQUAL( str.tellg(), 5 ); + BOOST_REQUIRE_EQUAL( test, "Hello" ); + } +} diff --git a/tests/zypp/ZChunk_test.cc b/tests/zypp/ZChunk_test.cc new file mode 100644 index 0000000..da58162 --- /dev/null +++ b/tests/zypp/ZChunk_test.cc @@ -0,0 +1,33 @@ +// Boost.Test +#include + +#include +#include +#include +#include + +BOOST_AUTO_TEST_CASE(zchunk_simple_read_write) +{ + const zypp::Pathname file = zypp::Pathname(TESTS_BUILD_DIR) / "test.zck"; + const std::string testString("HelloWorld"); + + { + zypp::ofzckstream strOut( file.c_str() ); + BOOST_REQUIRE( strOut.is_open() ); + strOut << testString; + } + + BOOST_REQUIRE_EQUAL( zypp::filesystem::zipType( file ), zypp::filesystem::ZT_ZCHNK ); + + { + std::string test; + zypp::ifzckstream str( file.c_str() ); + str >> test; + BOOST_REQUIRE_EQUAL( test, testString ); + } + + { + zypp::InputStream iStr( file ); + BOOST_REQUIRE( typeid( iStr.stream() ) == typeid( zypp::ifzckstream& ) ); + } +} diff --git a/zypp/CMakeLists.txt b/zypp/CMakeLists.txt index 82bf074..1e86815 100644 --- a/zypp/CMakeLists.txt +++ b/zypp/CMakeLists.txt @@ -4,8 +4,11 @@ SET( POT_FILE_DEPENDS ${POT_FILE_DEPENDS} PARENT_SCOPE ) ADD_DEFINITIONS(-DLOCALEDIR="${CMAKE_INSTALL_PREFIX}/share/locale" -DTEXTDOMAIN="zypp" -DZYPP_DLL ) +INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_BINARY_DIR} ) -INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) +IF (ENABLE_ZCHUNK_COMPRESSION) + INCLUDE_DIRECTORIES( ${ZCHUNK_INCLUDEDIR} ) +ENDIF(ENABLE_ZCHUNK_COMPRESSION) #FILE(WRITE filename "message to write"... ) SET( zypp_SRCS @@ -239,6 +242,7 @@ SET( zypp_base_HEADERS base/Easy.h base/Env.h base/Errno.h + base/fXstream.h base/Random.h base/Algorithm.h base/Counter.h @@ -274,6 +278,7 @@ SET( zypp_base_HEADERS base/SetRelationMixin.h base/SetTracker.h base/Signal.h + base/SimpleStreambuf.h base/String.h base/StrMatcher.h base/Regex.h @@ -285,6 +290,18 @@ SET( zypp_base_HEADERS base/Xml.h ) +IF (ENABLE_ZCHUNK_COMPRESSION) + + list( APPEND zypp_base_SRCS + base/ZckStream.cc + ) + + list( APPEND zypp_base_HEADERS + base/ZckStream.h + ) + +ENDIF(ENABLE_ZCHUNK_COMPRESSION) + INSTALL( FILES ${zypp_base_HEADERS} DESTINATION ${INCLUDE_INSTALL_DIR}/zypp/base @@ -449,12 +466,10 @@ INSTALL( FILES SET( zypp_parser_yum_SRCS parser/yum/RepomdFileReader.cc - parser/yum/PatchesFileReader.cc ) SET( zypp_parser_yum_HEADERS parser/yum/RepomdFileReader.h - parser/yum/PatchesFileReader.h ) INSTALL( FILES @@ -754,12 +769,10 @@ INSTALL( FILES SET( zypp_repo_yum_SRCS repo/yum/Downloader.cc - repo/yum/ResourceType.cc ) SET( zypp_repo_yum_HEADERS repo/yum/Downloader.h - repo/yum/ResourceType.h ) SET( zypp_repo_susetags_SRCS @@ -882,7 +895,6 @@ SET_LOGGROUP( "libsolv" ${zypp_sat_SRCS} ) #SET_LOGGROUP( "group" ${zypp_parser_yum_SRCS} ) #SET_LOGGROUP( "group" ${zypp_pool_SRCS} ) - ADD_LIBRARY(zypp SHARED ${zypp_lib_SRCS}) SET_TARGET_PROPERTIES( zypp PROPERTIES VERSION "${LIBZYPP_VERSION_INFO}" ) SET_TARGET_PROPERTIES( zypp PROPERTIES SOVERSION "${LIBZYPP_SOVERSION_INFO}" ) @@ -902,6 +914,9 @@ TARGET_LINK_LIBRARIES(zypp ${SIGNALS_LIBRARY}) TARGET_LINK_LIBRARIES(zypp ${Boost_THREAD_LIBRARY}) TARGET_LINK_LIBRARIES(zypp ${GPGME_PTHREAD_LIBRARIES}) +IF (ENABLE_ZCHUNK_COMPRESSION) + TARGET_LINK_LIBRARIES(zypp ${ZCHUNK_LDFLAGS}) +ENDIF(ENABLE_ZCHUNK_COMPRESSION) IF ( UDEV_FOUND ) TARGET_LINK_LIBRARIES(zypp ${UDEV_LIBRARY} ) diff --git a/zypp/OnMediaLocation.cc b/zypp/OnMediaLocation.cc index 7b8f6c9..1254e78 100644 --- a/zypp/OnMediaLocation.cc +++ b/zypp/OnMediaLocation.cc @@ -45,8 +45,8 @@ namespace zypp ByteCount _openSize; CheckSum _openChecksum; - ByteCount _zchunkHeaderSize; - CheckSum _zchunkHeaderChecksum; + ByteCount _headerSize; + CheckSum _headerChecksum; public: /** Offer default Impl. */ @@ -133,17 +133,17 @@ namespace zypp OnMediaLocation & OnMediaLocation::setOpenChecksum( CheckSum val_r ) { _pimpl->_openChecksum = val_r; return *this; } - const ByteCount & OnMediaLocation::zchunkHeaderSize() const - { return _pimpl->_zchunkHeaderSize; } + const ByteCount & OnMediaLocation::headerSize() const + { return _pimpl->_headerSize; } - OnMediaLocation & OnMediaLocation::setZchunkHeaderSize( ByteCount val_r ) - { _pimpl->_zchunkHeaderSize = val_r; return *this; } + OnMediaLocation & OnMediaLocation::setHeaderSize( ByteCount val_r ) + { _pimpl->_headerSize = val_r; return *this; } - const CheckSum & OnMediaLocation::zchunkHeaderChecksum() const - { return _pimpl->_zchunkHeaderChecksum; } + const CheckSum & OnMediaLocation::headerChecksum() const + { return _pimpl->_headerChecksum; } - OnMediaLocation & OnMediaLocation::setZchunkHeaderChecksum( CheckSum val_r ) - { _pimpl->_zchunkHeaderChecksum = val_r; return *this; } + OnMediaLocation & OnMediaLocation::setHeaderChecksum( CheckSum val_r ) + { _pimpl->_headerChecksum = val_r; return *this; } std::ostream & operator<<( std::ostream & str, const OnMediaLocation & obj ) diff --git a/zypp/OnMediaLocation.h b/zypp/OnMediaLocation.h index 3825f4f..875750f 100644 --- a/zypp/OnMediaLocation.h +++ b/zypp/OnMediaLocation.h @@ -94,6 +94,7 @@ namespace zypp /** Set the \ref checksum. */ OnMediaLocation & setChecksum( CheckSum val_r ); + public: /** The size of the resource once it has been uncompressed or unpacked. */ const ByteCount & openSize() const; /** Set the \ref openSize. */ @@ -105,15 +106,15 @@ namespace zypp OnMediaLocation & setOpenChecksum( CheckSum val_r ); public: - /** zchunk: The size of the zchunk header prepending the resource. */ - const ByteCount & zchunkHeaderSize() const; - /** zchunk: Set the \ref zchunkHeaderSize. */ - OnMediaLocation & setZchunkHeaderSize( ByteCount val_r ); - - /** zchunk: The checksum of the zchunk header prepending the resource. */ - const CheckSum & zchunkHeaderChecksum() const; - /** zchunk: Set the \ref zchunkHeaderChecksum. */ - OnMediaLocation & setZchunkHeaderChecksum( CheckSum val_r ); + /** The size of the header prepending the resource (e.g. for zchunk). */ + const ByteCount & headerSize() const; + /** Set the \ref headerSize. */ + OnMediaLocation & setHeaderSize( ByteCount val_r ); + + /** The checksum of the header prepending the resource (e.g. for zchunk). */ + const CheckSum & headerChecksum() const; + /** Set the \ref headerChecksum. */ + OnMediaLocation & setHeaderChecksum( CheckSum val_r ); public: class Impl; ///< Implementation class. diff --git a/zypp/PathInfo.cc b/zypp/PathInfo.cc index add273e..cf67b79 100644 --- a/zypp/PathInfo.cc +++ b/zypp/PathInfo.cc @@ -1081,7 +1081,7 @@ namespace zypp int fd = open( file.asString().c_str(), O_RDONLY|O_CLOEXEC ); if ( fd != -1 ) { - const int magicSize = 3; + const int magicSize = 5; unsigned char magic[magicSize]; memset( magic, 0, magicSize ); if ( read( fd, magic, magicSize ) == magicSize ) { @@ -1089,6 +1089,9 @@ namespace zypp ret = ZT_GZ; } else if ( magic[0] == 'B' && magic[1] == 'Z' && magic[2] == 'h' ) { ret = ZT_BZ2; + } else if ( magic[0] == '\0' && magic[1] == 'Z' && magic[2] == 'C' && magic[3] == 'K' && magic[4] == '1') { + ret = ZT_ZCHNK; + } } close( fd ); diff --git a/zypp/PathInfo.h b/zypp/PathInfo.h index 3324897..071080b 100644 --- a/zypp/PathInfo.h +++ b/zypp/PathInfo.h @@ -775,7 +775,7 @@ namespace zypp * * @return ZT_GZ, ZT_BZ2 if file is compressed, otherwise ZT_NONE. **/ - enum ZIP_TYPE { ZT_NONE, ZT_GZ, ZT_BZ2 }; + enum ZIP_TYPE { ZT_NONE, ZT_GZ, ZT_BZ2, ZT_ZCHNK }; ZIP_TYPE zipType( const Pathname & file ); diff --git a/zypp/base/GzStream.cc b/zypp/base/GzStream.cc index e0bce7a..f310e94 100644 --- a/zypp/base/GzStream.cc +++ b/zypp/base/GzStream.cc @@ -67,64 +67,53 @@ namespace zypp /////////////////////////////////////////////////////////////////// // - // METHOD NAME : fgzstreambuf::open - // METHOD TYPE : fgzstreambuf * + // METHOD NAME : gzstreambufimpl::openImpl + // METHOD TYPE : bool // - fgzstreambuf * - fgzstreambuf::open( const char * name_r, std::ios_base::openmode mode_r ) + bool + gzstreambufimpl::openImpl(const char *name_r, std::ios_base::openmode mode_r) { - fgzstreambuf * ret = NULL; + bool ret = false; if ( ! isOpen() ) + { + // we expect gzdopen to handle errors of ::open + if ( mode_r == std::ios_base::in ) + { + _fd = ::open( name_r, O_RDONLY | O_CLOEXEC ); + _file = gzdopen( _fd, "rb" ); + } + else if ( mode_r == std::ios_base::out ) { - // we expect gzdopen to handle errors of ::open - if ( mode_r == std::ios_base::in ) - { - _fd = ::open( name_r, O_RDONLY | O_CLOEXEC ); - _file = gzdopen( _fd, "rb" ); - } - else if ( mode_r == std::ios_base::out ) - { - _fd = ::open( name_r, O_WRONLY|O_CREAT|O_CLOEXEC, 0666 ); - _file = gzdopen( _fd, "wb" ); - } - // else: not supported + _fd = ::open( name_r, O_WRONLY|O_CREAT|O_CLOEXEC, 0666 ); + _file = gzdopen( _fd, "wb" ); + } + // else: not supported - if ( isOpen() ) - { - // Store mode and initialize the internal buffer. - _mode = mode_r; - if ( inReadMode() ) - { - setp( NULL, NULL ); - setg( &(_buffer[0]), &(_buffer[0]), &(_buffer[0]) ); - } - else - { - setp( &(_buffer[0]), &(_buffer[_buffer.size()-1]) ); - setg( NULL, NULL, NULL ); - } - ret = this; - } - else - setZError(); + if ( isOpen() ) + { + // Store mode + _mode = mode_r; + ret = true; } + else + setZError(); + } return ret; } /////////////////////////////////////////////////////////////////// // - // METHOD NAME : fgzstreambuf::close - // METHOD TYPE : fgzstreambuf * + // METHOD NAME : gzstreambufimpl::closeImpl + // METHOD TYPE : bool // - fgzstreambuf * - fgzstreambuf::close() + bool + gzstreambufimpl::closeImpl() { - fgzstreambuf * ret = NULL; + bool ret = false; if ( isOpen() ) { bool failed = false; - if ( sync() != 0 ) - failed = true; + // it also closes _fd, fine int r = gzclose( _file ); if ( r != Z_OK ) @@ -139,97 +128,19 @@ namespace zypp _fd = -1; _file = NULL; _mode = std::ios_base::openmode(0); - setp( NULL, NULL ); - setg( NULL, NULL, NULL ); if ( ! failed ) - ret = this; + ret = true; } return ret; } /////////////////////////////////////////////////////////////////// // - // METHOD NAME : fgzstreambuf::sync - // METHOD TYPE : int - // - int - fgzstreambuf::sync() - { - int ret = 0; - if ( pbase() < pptr() ) { - const int_type res = overflow(); - if ( traits_type::eq_int_type( res, traits_type::eof() ) ) - ret = -1; - } - return ret; - } - - /////////////////////////////////////////////////////////////////// - // - // METHOD NAME : fgzstreambuf::overflow - // METHOD TYPE : fgzstreambuf::int_type - // - fgzstreambuf::int_type - fgzstreambuf::overflow( int_type c ) - { - int_type ret = traits_type::eof(); - if ( inWriteMode() ) - { - if ( ! traits_type::eq_int_type( c, traits_type::eof() ) ) - { - *pptr() = traits_type::to_char_type( c ); - pbump(1); - } - if ( pbase() <= pptr() ) - { - if ( zWriteFrom( pbase(), pptr() - pbase() ) ) - { - setp( &(_buffer[0]), &(_buffer[_buffer.size()-1]) ); - ret = traits_type::not_eof( c ); - } - // else: error writing the file - } - } - return ret; - } - - /////////////////////////////////////////////////////////////////// - // - // METHOD NAME : fgzstreambuf::underflow - // METHOD TYPE : fgzstreambuf::int_type - // - fgzstreambuf::int_type - fgzstreambuf::underflow() - { - int_type ret = traits_type::eof(); - if ( inReadMode() ) - { - if ( gptr() < egptr() ) - return traits_type::to_int_type( *gptr() ); - - const std::streamsize got = zReadTo( &(_buffer[0]), _buffer.size() ); - if ( got > 0 ) - { - setg( &(_buffer[0]), &(_buffer[0]), &(_buffer.data()[got]) ); - ret = traits_type::to_int_type( *gptr() ); - } - else if ( got == 0 ) - { - // EOF - setg( &(_buffer[0]), &(_buffer[0]), &(_buffer[0]) ); - } - // else: error reading the file - } - return ret; - } - - /////////////////////////////////////////////////////////////////// - // - // METHOD NAME : fgzstreambuf::zReadTo + // METHOD NAME : gzstreambufimpl::readData // METHOD TYPE : std::streamsize // std::streamsize - fgzstreambuf::zReadTo( char * buffer_r, std::streamsize maxcount_r ) + gzstreambufimpl::readData( char * buffer_r, std::streamsize maxcount_r ) { int read = gzread( _file, buffer_r, maxcount_r ); if ( read < 0 ) @@ -239,11 +150,11 @@ namespace zypp /////////////////////////////////////////////////////////////////// // - // METHOD NAME : fgzstreambuf::zWriteFrom + // METHOD NAME : gzstreambufimpl::writeData // METHOD TYPE : bool // bool - fgzstreambuf::zWriteFrom( const char * buffer_r, std::streamsize count_r ) + gzstreambufimpl::writeData( const char * buffer_r, std::streamsize count_r ) { int written = 0; if ( count_r ) @@ -256,11 +167,11 @@ namespace zypp /////////////////////////////////////////////////////////////////// // - // METHOD NAME : fgzstreambuf::zSeekTo - // METHOD TYPE : fgzstreambuf::pos_type + // METHOD NAME : gzstreambufimpl::seekTo + // METHOD TYPE : off_t // - fgzstreambuf::pos_type - fgzstreambuf::zSeekTo( off_type off_r, std::ios_base::seekdir way_r ) + off_t + gzstreambufimpl::seekTo( off_t off_r, std::ios_base::seekdir way_r, std::ios_base::openmode ) { z_off_t ret = gzseek( _file, off_r, way_r ); if ( ret == -1 ) @@ -270,11 +181,11 @@ namespace zypp /////////////////////////////////////////////////////////////////// // - // METHOD NAME : fgzstreambuf::zTell - // METHOD TYPE : fgzstreambuf::pos_type + // METHOD NAME : gzstreambufimpl::tell + // METHOD TYPE : off_t // - fgzstreambuf::pos_type - fgzstreambuf::zTell() + off_t + gzstreambufimpl::tell() const { z_off_t ret = gztell( _file ); if ( ret == -1 ) @@ -282,78 +193,12 @@ namespace zypp return ret; } - /////////////////////////////////////////////////////////////////// - // - // METHOD NAME : fgzstreambuf::seekTo - // METHOD TYPE : fgzstreambuf::pos_type - // - fgzstreambuf::pos_type - fgzstreambuf::seekTo( off_type off_r, std::ios_base::seekdir way_r ) - { - pos_type ret = pos_type(off_type(-1)); - if ( isOpen() ) - { - if ( inWriteMode() ) - { - if ( sync() == 0 ) - ret = zSeekTo( off_r, way_r ); - } - else - { - off_type zegptr = zTell(); - if ( zegptr != off_type(-1) ) - { - if ( way_r == std::ios_base::end ) - { - // Invalidate buffer and seek. - // XXX improve by transformation into ios_base::beg - // to see whether we stay inside the buffer. - setg( &(_buffer[0]), &(_buffer[0]), &(_buffer[0]) ); - ret = zSeekTo( off_r, way_r ); - } - else - { - // Transform into ios_base::beg and seek. - off_type zeback = zegptr - ( egptr() - eback() ); - off_type zgptr = zegptr - ( egptr() - gptr() ); - off_type zngptr = off_r; - if ( way_r == std::ios_base::cur ) - { - zngptr += zgptr; - way_r = std::ios_base::beg; - } - - if ( way_r == std::ios_base::beg ) - { - if ( zeback <= zngptr && zngptr <= zegptr ) - { - // Still inside buffer, adjust gptr and - // calculate new position. - setg( eback(), - eback() + (zngptr-zeback), - egptr() ); - ret = pos_type(zngptr); - } - else - { - // Invalidate buffer and seek. - setg( &(_buffer[0]), &(_buffer[0]), &(_buffer[0]) ); - ret = zSeekTo( off_r, way_r ); - } - } - } - } - } - } - return ret; - } - - fgzstreambuf::pos_type - fgzstreambuf::compressed_tell() const + off_t + gzstreambufimpl::compressed_tell() const { off_t pos = lseek (_fd, 0, SEEK_CUR); // hopefully the conversion is ok - return pos; + return pos; } ///////////////////////////////////////////////////////////////// diff --git a/zypp/base/GzStream.h b/zypp/base/GzStream.h index 6512008..507ad40 100644 --- a/zypp/base/GzStream.h +++ b/zypp/base/GzStream.h @@ -26,6 +26,9 @@ #include #include +#include "zypp/base/SimpleStreambuf.h" +#include "zypp/base/fXstream.h" + /////////////////////////////////////////////////////////////////// namespace zypp { ///////////////////////////////////////////////////////////////// @@ -68,9 +71,10 @@ namespace zypp inline std::ostream & operator<<( std::ostream & str, const ZlibError & obj ) { return str << obj.strerror(); } + /////////////////////////////////////////////////////////////////// // - // CLASS NAME : fgzstreambuf + // CLASS NAME : gzstreambufimpl /** * @short Streambuffer reading or writing gzip files. * @@ -83,201 +87,79 @@ namespace zypp * * This streambuf is used in @ref ifgzstream and @ref ofgzstream. **/ - class fgzstreambuf : public std::streambuf { - + class gzstreambufimpl { public: - fgzstreambuf( unsigned bufferSize_r = 512 ) - : _fd( -1 ) - ,_file( NULL ) - , _mode( std::ios_base::openmode(0) ) - , _buffer( (bufferSize_r?bufferSize_r:1), 0 ) - {} + using error_type = ZlibError; - virtual - ~fgzstreambuf() - { close(); } + ~gzstreambufimpl() + { closeImpl(); } bool - isOpen() const + isOpen () const { return _file; } bool - inReadMode() const + canRead () const { return( _mode == std::ios_base::in ); } bool - inWriteMode() const + canWrite () const { return( _mode == std::ios_base::out ); } - fgzstreambuf * - open( const char * name_r, std::ios_base::openmode mode_r = std::ios_base::in ); + bool + canSeek ( std::ios_base::seekdir way_r ) const + { return ( way_r == std::ios_base::beg || way_r == std::ios_base::cur ); } - fgzstreambuf * - close(); + protected: + bool openImpl( const char * name_r, std::ios_base::openmode mode_r ); + bool closeImpl (); - //! Tell the file position in the compressed file. - //! Analogous to tell(2), complementary to gztell. - pos_type compressed_tell() const; + //! Tell the file position in the compressed file. + //! Analogous to tell(2), complementary to gztell. + off_t compressed_tell() const; - /** + public: + /** * The last error returned fron zlib. **/ - ZlibError - zError() const - { return _error; } - - protected: - - virtual int - sync(); - - virtual int_type - overflow( int_type c = traits_type::eof() ); - - virtual int_type - underflow(); - - virtual pos_type - seekoff( off_type off_r, std::ios_base::seekdir way_r, std::ios_base::openmode /* ignored */ ) - { return seekTo( off_r, way_r ); } - - virtual pos_type - seekpos( pos_type pos_r, std::ios_base::openmode /* ignored */ ) - { return seekTo( off_type(pos_r), std::ios_base::beg ); } - - private: - - typedef std::vector buffer_type; - - //! file descriptor of the compressed file - int _fd; - - gzFile _file; + error_type + error() const + { return _error; } - std::ios_base::openmode _mode; - - buffer_type _buffer; - - ZlibError _error; + std::streamsize readData ( char * buffer_r, std::streamsize maxcount_r ); + bool writeData( const char * buffer_r, std::streamsize count_r ); + off_t seekTo( off_t off_r, std::ios_base::seekdir way_r, std::ios_base::openmode omode_r ); + off_t tell() const; private: void - setZError() + setZError() const { gzerror( _file, &_error._zError ); } - std::streamsize - zReadTo( char * buffer_r, std::streamsize maxcount_r ); + //! file descriptor of the compressed file + int _fd = -1; - bool - zWriteFrom( const char * buffer_r, std::streamsize count_r ); + gzFile _file = nullptr; - pos_type - zSeekTo( off_type off_r, std::ios_base::seekdir way_r ); + std::ios_base::openmode _mode = std::ios_base::openmode(0); - pos_type - zTell(); + mutable ZlibError _error; - pos_type - seekTo( off_type off_r, std::ios_base::seekdir way_r ); }; - /////////////////////////////////////////////////////////////////// - - /////////////////////////////////////////////////////////////////// - // - // CLASS NAME : fXstream - /** - * @short Common template to define ifgzstream/ofgzstream - * reading/writing gzip files. - * - * Don't use fXstream directly, but @ref ifgzstream or - * @ref ofgzstream. fXstream is just to avoid almost - * duplicate code. - **/ - template - class fXstream : public TBStream - { - public: - - typedef gzstream_detail::ZlibError ZlibError; - typedef TBStream stream_type; - typedef TStreamBuf streambuf_type; - - fXstream() - : stream_type( NULL ) - { this->init( &_streambuf ); } - - explicit - fXstream( const char * file_r ) - : stream_type( NULL ) - { this->init( &_streambuf ); this->open( file_r ); } - - virtual - ~fXstream() - {} - - bool - is_open() const - { return _streambuf.isOpen(); } - - void - open( const char * file_r ) - { - if ( !_streambuf.open( file_r, defMode(*this) ) ) - this->setstate(std::ios_base::failbit); - else - this->clear(); - } - - void - close() - { - if ( !_streambuf.close() ) - this->setstate(std::ios_base::failbit); - } - - /** - * The last error returned retuned fron zlib. - **/ - ZlibError - zError() const - { return _streambuf.zError(); } - - //! Similar to ios::rdbuf. - //! But it returns our specific type, not the generic streambuf *. - const streambuf_type& - getbuf() const - { return _streambuf; } - - private: - - streambuf_type _streambuf; - - std::ios_base::openmode - defMode( const std::istream & str_r ) - { return std::ios_base::in; } - - std::ios_base::openmode - defMode( const std::ostream & str_r ) - { return std::ios_base::out; } - - }; - /////////////////////////////////////////////////////////////////// - - ///////////////////////////////////////////////////////////////// + using fgzstreambuf = detail::SimpleStreamBuf; } // namespace gzstream_detail - /////////////////////////////////////////////////////////////////// /** * istream reading gzip files as well as plain files. **/ - typedef gzstream_detail::fXstream ifgzstream; + typedef detail::fXstream ifgzstream; /** * ostream writing gzip files. **/ - typedef gzstream_detail::fXstream ofgzstream; + typedef detail::fXstream ofgzstream; ///////////////////////////////////////////////////////////////// } // namespace zypp diff --git a/zypp/base/InputStream.cc b/zypp/base/InputStream.cc index 81c138b..2aeeb73 100644 --- a/zypp/base/InputStream.cc +++ b/zypp/base/InputStream.cc @@ -15,6 +15,10 @@ #include "zypp/base/InputStream.h" #include "zypp/base/GzStream.h" +#ifdef ENABLE_ZCHUNK_COMPRESSION + #include "zypp/base/ZckStream.h" +#endif + #include "zypp/PathInfo.h" using std::endl; @@ -27,7 +31,7 @@ namespace zypp namespace { ///////////////////////////////////////////////////////////////// - inline std::streamoff _heplerInitSize( const Pathname & file_r ) + inline std::streamoff _helperInitSize( const Pathname & file_r ) { PathInfo p( file_r ); if ( p.isFile() && filesystem::zipType( file_r ) == filesystem::ZT_NONE ) @@ -35,6 +39,19 @@ namespace zypp return -1; } + inline shared_ptr streamForFile ( const Pathname & file_r ) + { + const auto zType = filesystem::zipType( file_r ); + +#ifdef ENABLE_ZCHUNK_COMPRESSION + if ( zType == filesystem::ZT_ZCHNK ) + return shared_ptr( new ifzckstream( file_r.asString().c_str() ) ); +#endif + + //fall back to gzstream + return shared_ptr( new ifgzstream( file_r.asString().c_str() ) ); + } + ///////////////////////////////////////////////////////////////// } // namespace /////////////////////////////////////////////////////////////////// @@ -67,9 +84,9 @@ namespace zypp // InputStream::InputStream( const Pathname & file_r ) : _path( file_r ) - , _stream( new ifgzstream( _path.asString().c_str() ) ) + , _stream( streamForFile( _path.asString() ) ) , _name( _path.asString() ) - , _size( _heplerInitSize( _path ) ) + , _size( _helperInitSize( _path ) ) {} /////////////////////////////////////////////////////////////////// @@ -80,9 +97,9 @@ namespace zypp InputStream::InputStream( const Pathname & file_r, const std::string & name_r ) : _path( file_r ) - , _stream( new ifgzstream( _path.asString().c_str() ) ) + , _stream( streamForFile( _path.asString() ) ) , _name( name_r ) - , _size( _heplerInitSize( _path ) ) + , _size( _helperInitSize( _path ) ) {} /////////////////////////////////////////////////////////////////// @@ -92,9 +109,9 @@ namespace zypp // InputStream::InputStream( const std::string & file_r ) : _path( file_r ) - , _stream( new ifgzstream( _path.asString().c_str() ) ) + , _stream( streamForFile( _path.asString() ) ) , _name( _path.asString() ) - , _size( _heplerInitSize( _path ) ) + , _size( _helperInitSize( _path ) ) {} /////////////////////////////////////////////////////////////////// @@ -105,9 +122,9 @@ namespace zypp InputStream::InputStream( const std::string & file_r, const std::string & name_r ) : _path( file_r ) - , _stream( new ifgzstream( _path.asString().c_str() ) ) + , _stream( streamForFile( _path.asString() ) ) , _name( name_r ) - , _size( _heplerInitSize( _path ) ) + , _size( _helperInitSize( _path ) ) {} /////////////////////////////////////////////////////////////////// @@ -117,9 +134,9 @@ namespace zypp // InputStream::InputStream( const char * file_r ) : _path( file_r ) - , _stream( new ifgzstream( _path.asString().c_str() ) ) + , _stream( streamForFile( _path.asString() ) ) , _name( _path.asString() ) - , _size( _heplerInitSize( _path ) ) + , _size( _helperInitSize( _path ) ) {} /////////////////////////////////////////////////////////////////// @@ -130,9 +147,9 @@ namespace zypp InputStream::InputStream( const char * file_r, const std::string & name_r ) : _path( file_r ) - , _stream( new ifgzstream( _path.asString().c_str() ) ) + , _stream( streamForFile( _path.asString() ) ) , _name( name_r ) - , _size( _heplerInitSize( _path ) ) + , _size( _helperInitSize( _path ) ) {} /////////////////////////////////////////////////////////////////// diff --git a/zypp/base/SimpleStreambuf.h b/zypp/base/SimpleStreambuf.h new file mode 100644 index 0000000..e88acb3 --- /dev/null +++ b/zypp/base/SimpleStreambuf.h @@ -0,0 +1,217 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ +/** \file zypp/base/SimpleStreambuf.h + * +*/ +#ifndef ZYPP_BASE_SIMPLESTREAMBUF_H_DEFINED +#define ZYPP_BASE_SIMPLESTREAMBUF_H_DEFINED + +#include +#include + +namespace zypp { + namespace detail { + + /*! + * Implementation of a std::streambuf that is using a std::vector as buffer, + * relies on a Impl class that must implement the basic i/o functionality: + * + * \code + * class streambufimpl { + * public: + * using error_type = my_error_type; + * + * ~streambufimpl(); + * + * bool isOpen () const; // returns true if the file is currently open + * bool canRead () const; // returns true if in read mode + * bool canWrite () const; // returns true if in write mode + * bool canSeek ( std::ios_base::seekdir way_r ) const; // returns true if the backend can seek in the given way + * + * std::streamsize readData ( char * buffer_r, std::streamsize maxcount_r ); // reads data from the file and returns it in buffer_r + * bool writeData( const char * buffer_r, std::streamsize count_r ); // writes data ( if in write mode ) to file from buffer + * off_t seekTo( off_t off_r, std::ios_base::seekdir way_r, std::ios_base::openmode omode_r ); // seeks in file if supported + * off_t tell() const; // returns the current FP + * + * error_type error() const; // returns the last error that happend in backend + * + * protected: + * bool openImpl( const char * name_r, std::ios_base::openmode mode_r ); // backend implementation of opening the file + * bool closeImpl (); // closes the file + * }; + * using FullStreamBuf = detail::SimpleStreamBuf; + * \endcode + * + * \note Currently only supports reading or writing at the same time, but can be extended to support both + */ + template + class SimpleStreamBuf : public std::streambuf, public Impl + { + + public: + + SimpleStreamBuf( size_t bufsize_r = 512) : _buffer( bufsize_r ) { } + virtual ~SimpleStreamBuf() { close(); } + + SimpleStreamBuf * open( const char * name_r, std::ios_base::openmode mode_r = std::ios_base::in ) { + + if ( !this->openImpl( name_r, mode_r ) ) + return nullptr; + + if ( this->canRead() ) { + setp( NULL, NULL ); + setg( &(_buffer[0]), &(_buffer[0]), &(_buffer[0]) ); + } else { + setp( &(_buffer[0]), &(_buffer[_buffer.size()-1]) ); + setg( NULL, NULL, NULL ); + } + + return this; + } + + SimpleStreamBuf * close() { + + if ( !this->isOpen() ) + return nullptr; + + if ( this->canWrite() ) + sync(); + + if ( !this->closeImpl() ) + return nullptr; + + return this; + } + + protected: + + virtual int sync() { + int ret = 0; + if ( pbase() < pptr() ) { + const int_type res = overflow(); + if ( traits_type::eq_int_type( res, traits_type::eof() ) ) + ret = -1; + } + return ret; + } + + virtual int_type overflow( int_type c = traits_type::eof() ) { + int_type ret = traits_type::eof(); + if ( this->canWrite() ) { + if ( ! traits_type::eq_int_type( c, traits_type::eof() ) ) + { + *pptr() = traits_type::to_char_type( c ); + pbump(1); + } + if ( pbase() <= pptr() ) + { + if ( this->writeData( pbase(), pptr() - pbase() ) ) + { + setp( &(_buffer[0]), &(_buffer[_buffer.size()-1]) ); + ret = traits_type::not_eof( c ); + } + // else: error writing the file + } + } + return ret; + } + + virtual int_type underflow() { + int_type ret = traits_type::eof(); + if ( this->canRead() ) + { + if ( gptr() < egptr() ) + return traits_type::to_int_type( *gptr() ); + + const std::streamsize got = this->readData( &(_buffer[0]), _buffer.size() ); + if ( got > 0 ) + { + setg( &(_buffer[0]), &(_buffer[0]), &(_buffer.data()[got]) ); + ret = traits_type::to_int_type( *gptr() ); + } + else if ( got == 0 ) + { + // EOF + setg( &(_buffer[0]), &(_buffer[0]), &(_buffer[0]) ); + } + // else: error reading the file + } + return ret; + } + + virtual pos_type seekpos( pos_type pos_r, std::ios_base::openmode openMode ) { + return seekoff( off_type(pos_r), std::ios_base::beg, openMode ); + } + + + virtual pos_type seekoff( off_type off_r, std::ios_base::seekdir way_r, std::ios_base::openmode openMode ) { + pos_type ret = pos_type(off_type(-1)); + if ( !this->canSeek( way_r) ) + return ret; + + if ( this->isOpen() ) { + if ( openMode == std::ios_base::out ) { + //write the buffer out and invalidate it , no need to keep it around + if ( !this->canWrite() || sync() != 0 ) + return ret; + + ret = this->seekTo( off_r, way_r, openMode ); + + } else if ( openMode == std::ios_base::in ) { + if ( !this->canRead() ) + return ret; + + //current physical FP, should point to end of buffer + const off_type buffEndOff = this->tell(); + + if ( buffEndOff != off_type(-1) ) { + if ( way_r == std::ios_base::end ) { + setg( &(_buffer[0]), &(_buffer[0]), &(_buffer[0]) ); + ret = this->seekTo( off_r, way_r, openMode ); + } + + const off_type bufLen = egptr() - eback(); + const off_type bufStartFileOff = buffEndOff - bufLen; + const off_type currPtrFileOffset = buffEndOff - ( egptr() - gptr() ); + off_type newFOff = off_r; + + // Transform into ios_base::beg and seek. + if ( way_r == std::ios_base::cur ) { + newFOff += currPtrFileOffset; + way_r = std::ios_base::beg; + } + + //check if a seek would go out of the buffers boundaries + if ( way_r == std::ios_base::beg ) { + if ( bufStartFileOff <= newFOff && newFOff <= buffEndOff ) { + // Still inside buffer, adjust gptr and + // calculate new position. + setg( eback(), + eback() + ( newFOff - bufStartFileOff ), + egptr() ); + ret = pos_type( newFOff ); + } else { + // Invalidate buffer and seek. + setg( &(_buffer[0]), &(_buffer[0]), &(_buffer[0]) ); + ret = this->seekTo( off_r, way_r, openMode ); + } + } + } + } + } + return ret; + } + + private: + typedef std::vector buffer_type; + buffer_type _buffer; + }; + } +} +#endif diff --git a/zypp/base/ZckStream.cc b/zypp/base/ZckStream.cc new file mode 100644 index 0000000..728bc47 --- /dev/null +++ b/zypp/base/ZckStream.cc @@ -0,0 +1,163 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ +#include "zypp/base/ZckStream.h" +#include "zypp/base/String.h" + +#include +#include +#include +#include +#include + +extern "C" { +#include +} + +namespace zypp { + + namespace detail { + + zckstreambufimpl::~zckstreambufimpl() + { + closeImpl(); + } + + bool zckstreambufimpl::openImpl( const char *name_r, std::ios_base::openmode mode_r ) + { + if ( isOpen() ) + return false; + + if ( mode_r == std::ios_base::in ) { + _fd = ::open( name_r, O_RDONLY | O_CLOEXEC ); + _isReading = true; + + } else if ( mode_r == std::ios_base::out ) { + _fd = ::open( name_r, O_WRONLY|O_CREAT|O_CLOEXEC, 0666 ); + _isReading = false; + } else { + //unsupported mode + _lastErr = str::Format("ZChunk backend does not support the given open mode."); + return false; + } + + if ( _fd < 0 ) { + const int errSrv = errno; + _lastErr = str::Format("Opening file failed: %1%") % ::strerror( errSrv ); + return false; + } + + _zContext = ::zck_create(); + if ( !_zContext ) { + setError(); + return false; + } + + if ( _isReading ) { + if ( !::zck_init_read( _zContext, _fd ) ) { + setError(); + return false; + } + } else { + if ( !::zck_init_write( _zContext, _fd ) ) { + setError(); + return false; + } + } + + _currfp = 0; + return true; + } + + bool zckstreambufimpl::closeImpl() + { + if ( !isOpen() ) + return true; + + bool success = true; + + if ( !zck_close( _zContext ) ) { + setError(); + success = false; + } + + zck_free( &_zContext ); + _zContext = nullptr; + ::close( _fd ); + _fd = -1; + return success; + } + + void zckstreambufimpl::setError() + { + if ( !zck_is_error( _zContext ) ) + return; + _lastErr = zck_get_error( _zContext ); + zck_clear_error( _zContext ); + } + + std::streamsize zckstreambufimpl::readData(char *buffer_r, std::streamsize maxcount_r) + { + if ( !isOpen() || !canRead() ) + return -1; + + ssize_t read = zck_read( _zContext, buffer_r, maxcount_r ); + if ( read > 0 ) + _currfp += read; + else + setError(); + + return read; + } + + bool zckstreambufimpl::writeData(const char *buffer_r, std::streamsize count_r) + { + if ( !isOpen() || !canWrite() ) + return false; + + ssize_t wrote = zck_write( _zContext, buffer_r, count_r ); + if ( wrote > 0 ) + _currfp += wrote; + else + setError(); + + return wrote; + } + + bool zckstreambufimpl::isOpen() const + { + return ( _fd >= 0 ); + } + + bool zckstreambufimpl::canRead() const + { + return _isReading; + } + + bool zckstreambufimpl::canWrite() const + { + return !_isReading; + } + + bool zckstreambufimpl::canSeek( std::ios_base::seekdir ) const + { + return false; + } + + off_t zckstreambufimpl::seekTo(off_t, std::ios_base::seekdir , std::ios_base::openmode) + { + return -1; + } + + off_t zckstreambufimpl::tell() const + { + return _currfp; + } + } + +} diff --git a/zypp/base/ZckStream.h b/zypp/base/ZckStream.h new file mode 100644 index 0000000..aa6ab16 --- /dev/null +++ b/zypp/base/ZckStream.h @@ -0,0 +1,77 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ +#ifndef ZYPP_BASE_ZCKSTREAM_H +#define ZYPP_BASE_ZCKSTREAM_H + +#include +#include +#include +#include "zypp/base/SimpleStreambuf.h" +#include "zypp/base/fXstream.h" + +typedef struct zckCtx zckCtx; + +namespace zypp { + + namespace detail { + + /** + * @short Streambuffer reading or writing zchunk files. + * + * Read and write mode are mutual exclusive. Seek is not supported. + * + * This streambuf is used in @ref ifzckstream and @ref ofzckstream. + **/ + class zckstreambufimpl { + public: + + using error_type = std::string; + + ~zckstreambufimpl(); + + bool isOpen () const; + bool canRead () const; + bool canWrite () const; + bool canSeek ( std::ios_base::seekdir way_r ) const; + + std::streamsize readData ( char * buffer_r, std::streamsize maxcount_r ); + bool writeData( const char * buffer_r, std::streamsize count_r ); + off_t seekTo( off_t off_r, std::ios_base::seekdir way_r, std::ios_base::openmode omode_r ); + off_t tell() const; + + error_type error() const { return _lastErr; } + + protected: + bool openImpl( const char * name_r, std::ios_base::openmode mode_r ); + bool closeImpl (); + + private: + void setError (); + int _fd = -1; + bool _isReading = false; + zckCtx *_zContext = nullptr; + off_t _currfp = 0; + error_type _lastErr; + + }; + using ZChunkStreamBuf = detail::SimpleStreamBuf; + } + + /** + * istream reading zchunk files. + **/ + using ifzckstream = detail::fXstream; + + /** + * ostream writing zchunk files. + **/ + using ofzckstream = detail::fXstream; +} + +#endif diff --git a/zypp/base/fXstream.h b/zypp/base/fXstream.h new file mode 100644 index 0000000..ec42346 --- /dev/null +++ b/zypp/base/fXstream.h @@ -0,0 +1,96 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ +#ifndef ZYPP_BASE_FXSTREAM_H +#define ZYPP_BASE_FXSTREAM_H + +#include +#include + +namespace zypp { + namespace detail { + /** + * @short Common template to define ifgzstream/ofgzstream + * reading/writing compressed files. + * + * Don't use fXstream directly, but @ref ifgzstream or + * @ref ofgzstream. fXstream is just to avoid almost + * duplicate code. + **/ + template + class fXstream : public TBStream + { + public: + + using ZlibError = typename TStreamBuf::error_type; + using stream_type = TBStream; + using streambuf_type = TStreamBuf; + + fXstream() + : stream_type( nullptr ) + { this->init( &_streambuf ); } + + explicit + fXstream( const char * file_r ) + : stream_type( nullptr ) + { this->init( &_streambuf ); this->open( file_r ); } + + virtual + ~fXstream() + {} + + bool + is_open() const + { return _streambuf.isOpen(); } + + void + open( const char * file_r ) + { + if ( !_streambuf.open( file_r, defMode(*this) ) ) + this->setstate(std::ios_base::failbit); + else + this->clear(); + } + + void + close() + { + if ( !_streambuf.close() ) + this->setstate(std::ios_base::failbit); + } + + /** + * The last error returned retuned from zlib. + **/ + ZlibError + zError() const + { return _streambuf.error(); } + + //! Similar to ios::rdbuf. + //! But it returns our specific type, not the generic streambuf *. + const streambuf_type& + getbuf() const + { return _streambuf; } + + private: + + streambuf_type _streambuf; + + std::ios_base::openmode + defMode( const std::istream & ) + { return std::ios_base::in; } + + std::ios_base::openmode + defMode( const std::ostream & ) + { return std::ios_base::out; } + + }; + } +} + +#endif diff --git a/zypp/parser/yum/PatchesFileReader.cc b/zypp/parser/yum/PatchesFileReader.cc deleted file mode 100644 index b5ad479..0000000 --- a/zypp/parser/yum/PatchesFileReader.cc +++ /dev/null @@ -1,155 +0,0 @@ -/*---------------------------------------------------------------------\ -| ____ _ __ __ ___ | -| |__ / \ / / . \ . \ | -| / / \ V /| _/ _/ | -| / /__ | | | | | | | -| /_____||_| |_| |_| | -| | -\---------------------------------------------------------------------*/ -/** \file zypp/parser/yum/PatchesFileReader.cc - * Implementation of patches.xml file reader. - */ -#include - -#include "zypp/base/String.h" -#include "zypp/base/Logger.h" - -#include "zypp/Date.h" -#include "zypp/CheckSum.h" -#include "zypp/OnMediaLocation.h" - -#include "zypp/parser/xml/Reader.h" -#include "zypp/parser/yum/PatchesFileReader.h" - - -using namespace std; -using namespace zypp::xml; - -namespace zypp -{ - namespace parser - { - namespace yum - { - - - enum Tag - { - tag_NONE, - tag_Patches, - tag_Patch, - tag_Location, - tag_CheckSum, - tag_Timestamp, - tag_OpenCheckSum - }; - - - /////////////////////////////////////////////////////////////////////// - // - // CLASS NAME : PatchesFileReader::Impl - // - class PatchesFileReader::Impl : private base::NonCopyable - { - public: - /** - * CTOR - */ - Impl(const Pathname &patches_file, const ProcessResource & callback); - - /** - * Callback provided to the XML parser. Don't use it. - */ - bool consumeNode( Reader & reader_r ); - - private: - OnMediaLocation _location; - Tag _tag; - std::string _id; - ProcessResource _callback; - CheckSum _checksum; - std::string _checksum_type; - Date _timestamp; - }; - /////////////////////////////////////////////////////////////////////// - - - PatchesFileReader::Impl::Impl(const Pathname & patches_file, - const ProcessResource & callback) - : _tag(tag_NONE), _callback(callback) - { - Reader reader( patches_file ); - MIL << "Reading " << patches_file << endl; - reader.foreachNode(bind( &PatchesFileReader::Impl::consumeNode, this, _1 )); - } - - // -------------------------------------------------------------------------- - - bool PatchesFileReader::Impl::consumeNode( Reader & reader_r ) - { - //MIL << reader_r->name() << endl; - std::string data_type; - if ( reader_r->nodeType() == XML_READER_TYPE_ELEMENT ) - { - if ( reader_r->name() == "patches" ) - { - _tag = tag_Patches; - return true; - } - if ( reader_r->name() == "patch" ) - { - _tag = tag_Patch; - _id = reader_r->getAttribute("id").asString(); - return true; - } - if ( reader_r->name() == "location" ) - { - _tag = tag_Location; - _location.setLocation( reader_r->getAttribute("href").asString(), 1 ); - return true; - } - if ( reader_r->name() == "checksum" ) - { - _tag = tag_CheckSum; - string checksum_type = reader_r->getAttribute("type").asString() ; - string checksum_vaue = reader_r.nodeText().asString(); - _location.setChecksum( CheckSum( checksum_type, checksum_vaue ) ); - return true; - } - if ( reader_r->name() == "timestamp" ) - { - // ignore it - return true; - } - } - else if ( reader_r->nodeType() == XML_READER_TYPE_END_ELEMENT ) - { - //MIL << "end element" << endl; - if ( reader_r->name() == "patch" ) - _callback( _location, _id ); - return true; - } - return true; - } - - - /////////////////////////////////////////////////////////////////// - // - // CLASS NAME : PatchesFileReader - // - /////////////////////////////////////////////////////////////////// - - PatchesFileReader::PatchesFileReader(const Pathname & patches_file, - const ProcessResource & callback) - : _pimpl(new Impl(patches_file, callback)) - {} - - PatchesFileReader::~PatchesFileReader() - {} - - - } // ns yum - } // ns parser -} // ns zypp - -// vim: set ts=2 sts=2 sw=2 et ai: diff --git a/zypp/parser/yum/PatchesFileReader.h b/zypp/parser/yum/PatchesFileReader.h deleted file mode 100644 index 53b344a..0000000 --- a/zypp/parser/yum/PatchesFileReader.h +++ /dev/null @@ -1,82 +0,0 @@ -/*---------------------------------------------------------------------\ -| ____ _ __ __ ___ | -| |__ / \ / / . \ . \ | -| / / \ V /| _/ _/ | -| / /__ | | | | | | | -| /_____||_| |_| |_| | -| | -\---------------------------------------------------------------------*/ -/** \file zypp/parser/yum/PatchesFileReader.h - * Interface of patches.xml file reader. - */ -#ifndef zypp_source_yum_PatchesFileReader_H -#define zypp_source_yum_PatchesFileReader_H - -#include "zypp/base/PtrTypes.h" -#include "zypp/base/NonCopyable.h" -#include "zypp/base/Function.h" - - -namespace zypp -{ - namespace parser - { - namespace yum - { - - - /** - * Iterates through a patches.xml file giving on each iteration - * a \ref OnMediaLocation object with the resource and its - * patch id. - * The iteration is done via a callback provided on - * construction. - * - * \code - * PatchesFileReader reader(patches_file, - * bind( &SomeClass::callbackfunc, &object, _1, _2 ) ); - * \endcode - */ - class PatchesFileReader : private base::NonCopyable - { - public: - - /** - * Callback definition - * first parameter is a \ref OnMediaLocation object with the resource - * second parameter is the patch id. - */ - typedef - function - ProcessResource; - - - /** - * CTOR. Creates also \ref xml::Reader and starts reading. - * - * \param patches_file is the patches.xml file you want to read - * \param callback is a function. - * - * \see PatchesFileReader::ProcessResource - */ - PatchesFileReader(const Pathname &patches_file, - const ProcessResource & callback); - - /** - * DTOR - */ - ~PatchesFileReader(); - - private: - class Impl; - RW_pointer > _pimpl; - }; - - - } // ns yum - } // ns parser -} // ns zypp - -#endif /*zypp_source_yum_PatchesFileReader_H*/ - -// vim: set ts=2 sts=2 sw=2 et ai: diff --git a/zypp/parser/yum/RepomdFileReader.cc b/zypp/parser/yum/RepomdFileReader.cc index 5d8a1ab..16e4d53 100644 --- a/zypp/parser/yum/RepomdFileReader.cc +++ b/zypp/parser/yum/RepomdFileReader.cc @@ -26,7 +26,6 @@ using namespace std; using namespace zypp::xml; -using zypp::repo::yum::ResourceType; namespace zypp { @@ -43,57 +42,37 @@ namespace zypp class RepomdFileReader::Impl : private base::NonCopyable { public: - - /** - * Enumeration of repomd.xml tags. - * \see _tag - */ - enum Tag - { - tag_NONE, - tag_Repomd, - tag_Data, - tag_Location, - tag_CheckSum, - tag_Timestamp, - tag_OpenCheckSum - }; - - public: - /** Ctro taking a ProcessResource2 callback */ - Impl(const Pathname &repomd_file, const ProcessResource2 & callback ) + /** Ctro taking a ProcessResource callback */ + Impl(const Pathname &repomd_file, const ProcessResource & callback ) : _callback( callback ) - , _tag( tag_NONE ) - , _type( ResourceType::NONE_e ) { Reader reader( repomd_file ); MIL << "Reading " << repomd_file << endl; reader.foreachNode( bind( &RepomdFileReader::Impl::consumeNode, this, _1 ) ); } - /** \overload Redirect an old ProcessResource callback */ - Impl(const Pathname &repomd_file, const ProcessResource & callback) - : Impl( repomd_file, ProcessResource2( bind( callback, _1, _2 ) ) ) - {} /** * Callback provided to the XML parser. */ bool consumeNode( Reader & reader_r ); + private: + /** Retrieve a checksum node. */ + CheckSum getChecksum( Reader & reader_r ) + { return CheckSum( reader_r->getAttribute("type").asString(), reader_r.nodeText().asString() ); } + + /** Retrieve a size node. */ + ByteCount getSize( Reader & reader_r ) + { return ByteCount( str::strtonum( reader_r.nodeText().asString() ) ); } + private: /** Function for processing collected data. Passed-in through constructor. */ - ProcessResource2 _callback; + ProcessResource _callback; - /** Used to remember currently processed tag */ - Tag _tag; - - /** Type of metadata file (string) */ + /** The resource type string. */ std::string _typeStr; - /** Type of metadata file as enum of well known repoinded.xml entries. */ - repo::yum::ResourceType _type; - /** Location of metadata file. */ OnMediaLocation _location; }; @@ -117,23 +96,19 @@ namespace zypp // xpath: /repomd if ( reader_r->name() == "repomd" ) { - _tag = tag_Repomd; return true; } // xpath: /repomd/data (+) if ( reader_r->name() == "data" ) { - _tag = tag_Data; _typeStr = reader_r->getAttribute("type").asString(); - _type = ResourceType(_typeStr); return true; } // xpath: /repomd/location if ( reader_r->name() == "location" ) { - _tag = tag_Location; _location.setLocation( reader_r->getAttribute("href").asString(), 1 ); // ignoring attribute xml:base return true; @@ -142,10 +117,14 @@ namespace zypp // xpath: /repomd/checksum if ( reader_r->name() == "checksum" ) { - _tag = tag_CheckSum; - string checksum_type = reader_r->getAttribute("type").asString() ; - string checksum_vaue = reader_r.nodeText().asString(); - _location.setChecksum( CheckSum( checksum_type, checksum_vaue ) ); + _location.setChecksum( getChecksum( reader_r ) ); + return true; + } + + // xpath: /repomd/header-checksum + if ( reader_r->name() == "header-checksum" ) + { + _location.setHeaderChecksum( getChecksum( reader_r ) ); return true; } @@ -159,9 +138,14 @@ namespace zypp // xpath: /repomd/size if ( reader_r->name() == "size" ) { - string size_value = reader_r.nodeText().asString(); - zypp::ByteCount size = zypp::ByteCount( str::strtonum( size_value ) ); - _location.setDownloadSize( size ); + _location.setDownloadSize( getSize( reader_r ) ); + return true; + } + + // xpath: /repomd/header-size + if ( reader_r->name() == "header-size" ) + { + _location.setHeaderSize( getSize( reader_r ) ); return true; } @@ -173,9 +157,11 @@ namespace zypp // xpath: /repomd/data if ( reader_r->name() == "data" ) { - if (_callback) - _callback( _location, _type, _typeStr ); - + if (_callback) { + _callback( std::move(_location), _typeStr ); + _location = OnMediaLocation(); + _typeStr.clear(); + } return true; } } @@ -194,10 +180,6 @@ namespace zypp : _pimpl( new Impl(repomd_file, callback) ) {} - RepomdFileReader::RepomdFileReader( const Pathname & repomd_file, const ProcessResource2 & callback ) - : _pimpl( new Impl(repomd_file, callback) ) - {} - RepomdFileReader::~RepomdFileReader() {} diff --git a/zypp/parser/yum/RepomdFileReader.h b/zypp/parser/yum/RepomdFileReader.h index be10c0e..fdebdea 100644 --- a/zypp/parser/yum/RepomdFileReader.h +++ b/zypp/parser/yum/RepomdFileReader.h @@ -17,7 +17,6 @@ #include "zypp/base/Function.h" #include "zypp/OnMediaLocation.h" -#include "zypp/repo/yum/ResourceType.h" namespace zypp { @@ -31,26 +30,14 @@ namespace zypp * Reads through a repomd.xml file and collects type, location, checksum and * other data about metadata files to be processed. * - * After each file entry is read, a \ref OnMediaLocation - * and \ref repo::yum::ResourceType are prepared and passed to the \ref _callback. - * - * Depending on the \ref _callback type provided on construction, ResourceType may - * additionally be passed as a plain string. This form allows handling custom - * resource types (e.g. ones with embedded locale tag). - * - * \code - * RepomdFileReader reader(repomd_file, - * bind( &SomeClass::callbackfunc, &SomeClassInstance, _1, _2 ) ); - * \endcode + * After each file entry is read, an \ref OnMediaLocation and the resource type + * string are prepared and passed to the \ref _callback. */ class RepomdFileReader : private base::NonCopyable { public: - /** Callbacl taking \ref OnMediaLocation and \ref repo::yum::ResourceType */ - typedef function< bool( const OnMediaLocation &, const repo::yum::ResourceType & )> ProcessResource; - - /** Alternate callback also receiving the ResourceType as string. */ - typedef function< bool( const OnMediaLocation &, const repo::yum::ResourceType &, const std::string & )> ProcessResource2; + /** Callback taking \ref OnMediaLocation and the resource type string */ + typedef function< bool( OnMediaLocation &&, const std::string & )> ProcessResource; /** * CTOR. Creates also \ref xml::Reader and starts reading. @@ -61,8 +48,6 @@ namespace zypp * \see RepomdFileReader::ProcessResource */ RepomdFileReader( const Pathname & repomd_file, const ProcessResource & callback ); - /** \overload taking ProcessResource2 callback */ - RepomdFileReader( const Pathname & repomd_file, const ProcessResource2 & callback ); /** DTOR */ ~RepomdFileReader(); diff --git a/zypp/repo/susetags/Downloader.h b/zypp/repo/susetags/Downloader.h index 1b4be79..06e9396 100644 --- a/zypp/repo/susetags/Downloader.h +++ b/zypp/repo/susetags/Downloader.h @@ -53,11 +53,11 @@ namespace zypp */ void download( MediaSetAccess &media, const Pathname &dest_dir, - const ProgressData::ReceiverFnc & progress = ProgressData::ReceiverFnc() ); + const ProgressData::ReceiverFnc & progress = ProgressData::ReceiverFnc() ) override; /** * \short Status of the remote repository */ - RepoStatus status( MediaSetAccess &media ); + RepoStatus status( MediaSetAccess &media ) override; /** * Content file parser consumer diff --git a/zypp/repo/yum/Downloader.cc b/zypp/repo/yum/Downloader.cc index b127c1e..436a57c 100644 --- a/zypp/repo/yum/Downloader.cc +++ b/zypp/repo/yum/Downloader.cc @@ -8,19 +8,18 @@ \---------------------------------------------------------------------*/ #include +#include #include "zypp/base/String.h" #include "zypp/base/LogTools.h" #include "zypp/base/Function.h" #include "zypp/ZConfig.h" -#include "zypp/parser/yum/RepomdFileReader.h" -#include "zypp/parser/yum/PatchesFileReader.h" #include "Downloader.h" #include "zypp/repo/MediaInfoDownloader.h" #include "zypp/base/UserRequestException.h" #include "zypp/parser/xml/Reader.h" +#include "zypp/parser/yum/RepomdFileReader.h" -using namespace std; using namespace zypp::xml; using namespace zypp::parser::yum; @@ -30,109 +29,124 @@ namespace repo { namespace yum { - -Downloader::Downloader( const RepoInfo &repoinfo , const Pathname &delta_dir) - : repo::Downloader(repoinfo), _delta_dir(delta_dir), _media_ptr(0L) -{} - -RepoStatus Downloader::status( MediaSetAccess &media ) -{ - RepoStatus ret( media.provideOptionalFile( repoInfo().path() / "/repodata/repomd.xml" ) ); - if ( !ret.empty() ) // else: mandatory master index is missing - ret = ret && RepoStatus( media.provideOptionalFile( "/media.1/media" ) ); - // else: mandatory master index is missing -> stay empty - return ret; -} - -static OnMediaLocation loc_with_path_prefix( const OnMediaLocation & loc, const Pathname & prefix ) -{ - if (prefix.empty() || prefix == "/") - return loc; - - OnMediaLocation loc_with_path(loc); - loc_with_path.changeFilename(prefix / loc.filename()); - return loc_with_path; -} - -// search old repository file file to run the delta algorithm on -static Pathname search_deltafile( const Pathname & dir, const Pathname & file ) -{ - Pathname deltafile; - if (!PathInfo(dir).isDir()) - return deltafile; - string base = file.basename(); - size_t hypoff = base.find("-"); - if (hypoff != string::npos) - base.replace(0, hypoff + 1, ""); - size_t basesize = base.size(); - std::list retlist; - if (!filesystem::readdir(retlist, dir, false)) + /////////////////////////////////////////////////////////////////// + namespace { - for_( it, retlist.begin(), retlist.end() ) + inline OnMediaLocation loc_with_path_prefix( OnMediaLocation loc_r, const Pathname & prefix_r ) { - string fn = it->asString(); - if (fn.size() >= basesize && fn.substr(fn.size() - basesize, basesize) == base) - deltafile = *it; + if ( ! prefix_r.empty() && prefix_r != "/" ) + loc_r.changeFilename( prefix_r / loc_r.filename() ); + return loc_r; } - } - return deltafile; -} -bool Downloader::patches_Callback( const OnMediaLocation & loc_r, const string & id_r ) -{ - OnMediaLocation loc_with_path(loc_with_path_prefix(loc_r, repoInfo().path())); - MIL << id_r << " : " << loc_with_path << endl; - this->enqueueDigested(loc_with_path, FileChecker(), search_deltafile(_delta_dir + "repodata", loc_r.filename())); - return true; -} - - -//bool repomd_Callback2( const OnMediaLocation &loc, const ResourceType &dtype, const std::string &typestr, UserData & userData_r ); + // search old repository file to run the delta algorithm on + Pathname search_deltafile( const Pathname & dir, const Pathname & file ) + { + Pathname deltafile; + if ( ! PathInfo(dir).isDir() ) + return deltafile; + + // Strip the checksum preceding the file stem so we can look for an + // old *-primary.xml which may contain some reusable blocks. + std::string base { file.basename() }; + size_t hypoff = base.find( "-" ); + if ( hypoff != std::string::npos ) + base.replace( 0, hypoff + 1, "" ); + + std::list retlist; + if ( ! filesystem::readdir( retlist, dir, false ) ) + { + for ( const auto & fn : retlist ) + { + if ( str::endsWith( fn, base ) ) + deltafile = fn; + } + } + return deltafile; + } + } // namespace + /////////////////////////////////////////////////////////////////// -/////////////////////////////////////////////////////////////////// -namespace -{ /////////////////////////////////////////////////////////////////// - /// \class Impl + /// \class Downloader::Impl /// \brief Helper filtering the files offered by a RepomdFileReader /// /// Clumsy construct; basically an Impl class for Downloader, maintained /// in Downloader::download only while parsing a repomd.xml. - /// - /// Introduced because Downloader itself lacks an Impl class, thus can't - /// be extended to provide more data to the callbacks without losing - /// binary compatibility. + /// File types: + /// type (plain) + /// type_db (sqlite, ignored by zypp) + /// type_zck (zchunk, preferred) + /// Localized type: + /// susedata.LOCALE /////////////////////////////////////////////////////////////////// - struct RepomdFileReaderCallback2 + struct Downloader::Impl { - RepomdFileReaderCallback2( const RepomdFileReader::ProcessResource & origCallback_r ) - : _origCallback( origCallback_r ) + NON_COPYABLE( Impl ); + NON_MOVABLE( Impl ); + + Impl( Downloader & downloader_r, MediaSetAccess & media_r, const Pathname & destDir_r ) + : _downloader { downloader_r } + , _media { media_r } + , _destDir { destDir_r } { addWantedLocale( ZConfig::instance().textLocale() ); for ( const Locale & it : ZConfig::instance().repoRefreshLocales() ) addWantedLocale( it ); } - /** The callback invoked by the RepomdFileReader */ - bool repomd_Callback2( const OnMediaLocation & loc_r, const ResourceType & dtype_r, const std::string & typestr_r ) + /** The callback invoked by the RepomdFileReader. + * It's a pity, but in the presence of separate "type" and "type_zck" entries, + * we have to scan the whole file before deciding what to download.... + */ + bool operator()( const OnMediaLocation & loc_r, const std::string & typestr_r ) { + if ( str::endsWith( typestr_r, "_db" ) ) + return true; // skip sqlitedb + + bool zchk { str::endsWith( typestr_r, "_zck" ) }; +#ifdef LIBSOLVEXT_FEATURE_ZSTD_COMPRESSION + const std::string & basetype { zchk ? typestr_r.substr( 0, typestr_r.size()-4 ) : typestr_r }; +#else + if ( zchk ) + return true; // skip zchunk if not supported by libsolv + const std::string & basetype { typestr_r }; +#endif + // filter well known resource types - if ( dtype_r == ResourceType::OTHER || dtype_r == ResourceType::FILELISTS ) + if ( basetype == "other" || basetype == "filelists" ) return true; // skip it - // filter custom resource types (by string) - if ( dtype_r == ResourceType::NONE ) + // filter localized susedata + if ( str::startsWith( basetype, "susedata." ) ) { // susedata.LANG - if ( str::hasPrefix( typestr_r, "susedata." ) && ! wantLocale( Locale(typestr_r.c_str()+9) ) ) + if ( ! wantLocale( Locale(basetype.c_str()+9) ) ) return true; // skip it } - // take it - return( _origCallback ? _origCallback( loc_r, dtype_r ) : true ); + // may take it... (prefer zchnk) + if ( zchk || !_wantedFiles.count( basetype ) ) + _wantedFiles[basetype] = loc_r; + + return true; + } + + void finalize() + { + // schedule fileS for download + for ( const auto & el : _wantedFiles ) + { + const OnMediaLocation & loc { el.second }; + const OnMediaLocation & loc_with_path { loc_with_path_prefix( loc, _downloader.repoInfo().path() ) }; + _downloader.enqueueDigested( loc_with_path, FileChecker(), search_deltafile( deltaDir()/"repodata", loc.filename() ) ); + } } private: + const Pathname & deltaDir() const + { return _downloader._deltaDir; } + bool wantLocale( const Locale & locale_r ) const { return _wantedLocales.count( locale_r ); } @@ -146,56 +160,49 @@ namespace } private: - RepomdFileReader::ProcessResource _origCallback; ///< Original Downloader callback - LocaleSet _wantedLocales; ///< Locales do download + Downloader & _downloader; + MediaSetAccess & _media; + const Pathname & _destDir; + LocaleSet _wantedLocales; ///< Locales do download + std::map _wantedFiles; }; -} // namespace -/////////////////////////////////////////////////////////////////// -bool Downloader::repomd_Callback( const OnMediaLocation & loc_r, const ResourceType & dtype_r ) -{ - // NOTE: Filtering of unwanted files is done in RepomdFileReaderCallback2! + /////////////////////////////////////////////////////////////////// + // + // class Downloader + // + /////////////////////////////////////////////////////////////////// - // schedule file for download - const OnMediaLocation & loc_with_path(loc_with_path_prefix(loc_r, repoInfo().path())); - this->enqueueDigested(loc_with_path, FileChecker(), search_deltafile(_delta_dir + "repodata", loc_r.filename())); + Downloader::Downloader( const RepoInfo & info_r, const Pathname & deltaDir_r ) + : repo::Downloader { info_r} + , _deltaDir { deltaDir_r } + {} - // We got a patches file we need to read, to add patches listed - // there, so we transfer what we have in the queue, and - // queue the patches in the patches callback - if ( dtype_r == ResourceType::PATCHES ) + void Downloader::download( MediaSetAccess & media_r, const Pathname & destDir_r, const ProgressData::ReceiverFnc & progress_r ) { - this->start( _dest_dir, *_media_ptr ); - // now the patches.xml file must exists - PatchesFileReader( _dest_dir + repoInfo().path() + loc_r.filename(), - bind( &Downloader::patches_Callback, this, _1, _2)); - } - return true; -} - -void Downloader::download( MediaSetAccess & media, const Pathname & dest_dir, const ProgressData::ReceiverFnc & progressrcv ) -{ - downloadMediaInfo( dest_dir, media ); + downloadMediaInfo( destDir_r, media_r ); - Pathname masterIndex( repoInfo().path() / "/repodata/repomd.xml" ); - defaultDownloadMasterIndex( media, dest_dir, masterIndex ); + Pathname masterIndex { repoInfo().path() / "/repodata/repomd.xml" }; + defaultDownloadMasterIndex( media_r, destDir_r, masterIndex ); - // init the data stored in Downloader itself - _media_ptr = (&media); - _dest_dir = dest_dir; + // setup parser + Impl pimpl( *this, media_r, destDir_r ); + RepomdFileReader( destDir_r / masterIndex, std::ref(pimpl) ); + pimpl.finalize(); - // init the extended data - RepomdFileReaderCallback2 pimpl( bind(&Downloader::repomd_Callback, this, _1, _2) ); - - // setup parser - RepomdFileReader( dest_dir / masterIndex, - RepomdFileReader::ProcessResource2( bind(&RepomdFileReaderCallback2::repomd_Callback2, &pimpl, _1, _2, _3) ) ); - - // ready, go! - start( dest_dir, media ); -} + // ready, go! + start( destDir_r, media_r ); + } + RepoStatus Downloader::status( MediaSetAccess & media_r ) + { + RepoStatus ret { media_r.provideOptionalFile( repoInfo().path() / "/repodata/repomd.xml" ) }; + if ( !ret.empty() ) // else: mandatory master index is missing + ret = ret && RepoStatus( media_r.provideOptionalFile( "/media.1/media" ) ); + // else: mandatory master index is missing -> stay empty + return ret; + } } // namespace yum } // namespace repo } // namespace zypp diff --git a/zypp/repo/yum/Downloader.h b/zypp/repo/yum/Downloader.h index e775299..591c9f4 100644 --- a/zypp/repo/yum/Downloader.h +++ b/zypp/repo/yum/Downloader.h @@ -19,7 +19,6 @@ #include "zypp/RepoInfo.h" #include "zypp/RepoStatus.h" #include "zypp/repo/Downloader.h" -#include "zypp/repo/yum/ResourceType.h" namespace zypp { @@ -41,7 +40,7 @@ namespace zypp class Downloader : public repo::Downloader { public: - + /** * \short Constructor from the repository information * @@ -50,34 +49,28 @@ namespace zypp * * \param info Repository information */ - Downloader( const RepoInfo &info , const Pathname &delta_dir = Pathname()); + Downloader( const RepoInfo & info_r, const Pathname & deltaDir_r = Pathname() ); /** * \short Download metadata to a local directory * * \param media Media access to the repository url - * \param dest_dir Local destination directory + * \param destDir Local destination directory * \param progress progress receiver */ - void download( MediaSetAccess &media, - const Pathname &dest_dir, - const ProgressData::ReceiverFnc & progress = ProgressData::ReceiverFnc() ); - + void download( MediaSetAccess & media_r, + const Pathname & destDir_r, + const ProgressData::ReceiverFnc & progress_r = ProgressData::ReceiverFnc() ) override; + /** * \short Status of the remote repository */ - RepoStatus status( MediaSetAccess &media ); - - protected: - bool repomd_Callback( const OnMediaLocation &loc, const ResourceType &dtype ); - bool patches_Callback( const OnMediaLocation &loc, const std::string &id ); - private: - // TODO: Use pimpl to be extensible; but breaks bincompat :( - Pathname _dest_dir; - Pathname _delta_dir; - std::list _patches_files; - - MediaSetAccess *_media_ptr; + RepoStatus status( MediaSetAccess & media_r ) override; + + private: + class Impl; + friend class Impl; + Pathname _deltaDir; }; } // ns yum diff --git a/zypp/repo/yum/ResourceType.cc b/zypp/repo/yum/ResourceType.cc deleted file mode 100644 index 650ba9f..0000000 --- a/zypp/repo/yum/ResourceType.cc +++ /dev/null @@ -1,98 +0,0 @@ -/*---------------------------------------------------------------------\ -| ____ _ __ __ ___ | -| |__ / \ / / . \ . \ | -| / / \ V /| _/ _/ | -| / /__ | | | | | | | -| /_____||_| |_| |_| | -| | -\---------------------------------------------------------------------*/ - -#include -#include -#include "zypp/base/Exception.h" -#include "ResourceType.h" - -namespace zypp -{ - namespace repo - { - namespace yum - { - - - static std::map _table; - - const ResourceType ResourceType::NONE(ResourceType::NONE_e); - const ResourceType ResourceType::REPOMD(ResourceType::REPOMD_e); - const ResourceType ResourceType::PRIMARY(ResourceType::PRIMARY_e); - const ResourceType ResourceType::OTHER(ResourceType::OTHER_e); - const ResourceType ResourceType::FILELISTS(ResourceType::FILELISTS_e); - const ResourceType ResourceType::GROUP(ResourceType::GROUP_e); - const ResourceType ResourceType::PATCHES(ResourceType::PATCHES_e); - const ResourceType ResourceType::PATCH(ResourceType::PATCH_e); - const ResourceType ResourceType::PRODUCT(ResourceType::PRODUCT_e); - const ResourceType ResourceType::PATTERNS(ResourceType::PATTERNS_e); - const ResourceType ResourceType::PRIMARY_DB(ResourceType::PRIMARY_DB_e); - const ResourceType ResourceType::OTHER_DB(ResourceType::OTHER_DB_e); - - ResourceType::ResourceType(const std::string & strval_r) - : _type(parse(strval_r)) - {} - - ResourceType::Type ResourceType::parse(const std::string & strval_r) - { - if (_table.empty()) - { - // initialize it - _table["repomd"] = ResourceType::REPOMD_e; - _table["primary"] = ResourceType::PRIMARY_e; - _table["other"] = ResourceType::OTHER_e; - _table["filelists"] = ResourceType::FILELISTS_e; - _table["group"] = ResourceType::GROUP_e; - _table["patches"] = ResourceType::PATCHES_e; - _table["patch"] = ResourceType::PATCH_e; - _table["product"] = ResourceType::PRODUCT_e; - _table["patterns"] = ResourceType::PATTERNS_e; - _table["primary_db"] = ResourceType::PRIMARY_DB_e; - _table["other_db"] = ResourceType::OTHER_DB_e; - _table["NONE"] = _table["none"] = ResourceType::NONE_e; - } - - std::map::const_iterator it - = _table.find(strval_r); - if (it == _table.end()) - { - return ResourceType::NONE_e; - } - return it->second; - } - - - const std::string & ResourceType::asString() const - { - static std::map _table; - if ( _table.empty() ) - { - // initialize it - _table[REPOMD_e] = "repomd"; - _table[PRIMARY_e] = "primary"; - _table[OTHER_e] = "other"; - _table[FILELISTS_e] = "filelists"; - _table[GROUP_e] = "group"; - _table[PATCHES_e] = "patches"; - _table[PATCH_e] = "patch"; - _table[PRODUCT_e] = "product"; - _table[PATTERNS_e] = "patterns"; - _table[OTHER_DB_e] = "other_db"; - _table[PRIMARY_DB_e] = "primary_db"; - _table[NONE_e] = "NONE"; - } - return _table[_type]; - } - - - } // ns yum - } // ns source -} // ns zypp - -// vim: set ts=2 sts=2 sw=2 et ai: diff --git a/zypp/repo/yum/ResourceType.h b/zypp/repo/yum/ResourceType.h deleted file mode 100644 index 2d5cf9e..0000000 --- a/zypp/repo/yum/ResourceType.h +++ /dev/null @@ -1,86 +0,0 @@ -/*---------------------------------------------------------------------\ -| ____ _ __ __ ___ | -| |__ / \ / / . \ . \ | -| / / \ V /| _/ _/ | -| / /__ | | | | | | | -| /_____||_| |_| |_| | -| | -\---------------------------------------------------------------------*/ - -#ifndef YUMRESOURCETYPE_H_ -#define YUMRESOURCETYPE_H_ - -#include -#include - -namespace zypp -{ - namespace repo - { - namespace yum - { - - - /** - * - */ - struct ResourceType - { - static const ResourceType NONE; // unknown - static const ResourceType REPOMD; - static const ResourceType PRIMARY; - static const ResourceType OTHER; - static const ResourceType FILELISTS; - static const ResourceType GROUP; - static const ResourceType PATCHES; // suse extension - static const ResourceType PATCH; // suse extension - static const ResourceType PRODUCT; // suse extension - static const ResourceType PATTERNS; // suse extension - // sqlite caches yum extensions: - static const ResourceType PRIMARY_DB; // yum extension - static const ResourceType OTHER_DB; // yum extension - - enum Type - { - NONE_e, - REPOMD_e, - PRIMARY_e, - OTHER_e, - FILELISTS_e, - GROUP_e, - PATCHES_e, - PATCH_e, - PRODUCT_e, - PATTERNS_e, - PRIMARY_DB_e, - OTHER_DB_e, - }; - - ResourceType(Type type) : _type(type) {} - - explicit ResourceType(const std::string & strval_r); - - Type toEnum() const { return _type; } - - ResourceType::Type parse(const std::string & strval_r); - - const std::string & asString() const; - - Type _type; - }; - - - inline std::ostream & operator<<( std::ostream & str, const ResourceType & obj ) - { return str << obj.asString(); } - - inline bool operator==(const ResourceType & obj1, const ResourceType & obj2) - { return obj1._type == obj2._type; } - - - } // ns yum - } // ns source -} // ns zypp - -#endif /*YUMRESOURCETYPE_H_*/ - -// vim: set ts=2 sts=2 sw=2 et ai: