From 7c6967719b1ab786984ce2eeb55a4dcb073a9565 Mon Sep 17 00:00:00 2001 From: Duncan Mac-Vicar P Date: Tue, 12 Jun 2007 15:12:30 +0000 Subject: [PATCH] - rename some classes to avoid things like yum::YUMBlah - add Repository link to ResObject, to allow the download on commit --- tests/parser/yum/RepomdFileReader_test.cc | 8 +- tests/repo/yum/YUMDownloader_test.cc | 6 +- zypp/CMakeLists.txt | 49 ++++++++---- zypp/RepoManager.cc | 11 ++- zypp/Repository.cc | 5 ++ zypp/Repository.h | 3 + zypp/ResObject.cc | 7 ++ zypp/ResObject.h | 18 ++++- zypp/detail/ResObjectImplIf.cc | 7 ++ zypp/detail/ResObjectImplIf.h | 10 +++ zypp/parser/yum/RepoParser.cc | 32 ++++---- zypp/parser/yum/RepomdFileReader.cc | 8 +- zypp/parser/yum/RepomdFileReader.h | 6 +- zypp/repo/cached/AtomImpl.cc | 2 +- zypp/repo/cached/AtomImpl.h | 2 +- zypp/repo/cached/MessageImpl.cc | 2 +- zypp/repo/cached/MessageImpl.h | 2 +- zypp/repo/cached/PackageImpl.cc | 2 +- zypp/repo/cached/PackageImpl.h | 2 +- zypp/repo/cached/PatchImpl.cc | 2 +- zypp/repo/cached/PatchImpl.h | 2 +- zypp/repo/cached/PatternImpl.cc | 2 +- zypp/repo/cached/PatternImpl.h | 2 +- zypp/repo/cached/ProductImpl.cc | 2 +- zypp/repo/cached/ProductImpl.h | 2 +- zypp/repo/cached/ScriptImpl.cc | 2 +- zypp/repo/cached/ScriptImpl.h | 2 +- zypp/repo/cached/SrcPackageImpl.cc | 2 +- zypp/repo/cached/SrcPackageImpl.h | 2 +- .../susetags/Downloader.cc} | 8 +- .../susetags/Downloader.h} | 6 +- .../YUMDownloader.cc => repo/yum/Downloader.cc} | 20 ++--- .../yum/YUMDownloader.h => repo/yum/Downloader.h} | 12 +-- zypp/repo/yum/ResourceType.cc | 92 ++++++++++++++++++++++ .../YUMResourceType.h => repo/yum/ResourceType.h} | 32 ++++---- zypp/source/yum/YUMResourceType.cc | 92 ---------------------- 36 files changed, 261 insertions(+), 203 deletions(-) rename zypp/{source/susetags/SUSETagsDownloader.cc => repo/susetags/Downloader.cc} (87%) rename zypp/{source/susetags/SUSETagsDownloader.h => repo/susetags/Downloader.h} (89%) rename zypp/{source/yum/YUMDownloader.cc => repo/yum/Downloader.cc} (79%) rename zypp/{source/yum/YUMDownloader.h => repo/yum/Downloader.h} (89%) create mode 100644 zypp/repo/yum/ResourceType.cc rename zypp/{source/yum/YUMResourceType.h => repo/yum/ResourceType.h} (59%) delete mode 100644 zypp/source/yum/YUMResourceType.cc diff --git a/tests/parser/yum/RepomdFileReader_test.cc b/tests/parser/yum/RepomdFileReader_test.cc index 2025089..8398a3e 100644 --- a/tests/parser/yum/RepomdFileReader_test.cc +++ b/tests/parser/yum/RepomdFileReader_test.cc @@ -16,7 +16,7 @@ using namespace zypp; using namespace boost::unit_test; using namespace zypp::parser::yum; -using source::yum::YUMResourceType; +using repo::yum::ResourceType; class Collector { @@ -24,7 +24,7 @@ public: Collector() {} - bool callback( const OnMediaLocation &loc, const YUMResourceType &t ) + bool callback( const OnMediaLocation &loc, const ResourceType &t ) { items.push_back( make_pair( t, loc ) ); //items.push_back(loc); @@ -32,7 +32,7 @@ public: return true; } - vector > items; + vector > items; //vector items; }; @@ -63,7 +63,7 @@ void repomd_read_test(const string &dir) string loc; getline(ifs, dtype); - BOOST_CHECK_EQUAL( collect.items[count].first, YUMResourceType(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) ); diff --git a/tests/repo/yum/YUMDownloader_test.cc b/tests/repo/yum/YUMDownloader_test.cc index 56a44d5..750076e 100644 --- a/tests/repo/yum/YUMDownloader_test.cc +++ b/tests/repo/yum/YUMDownloader_test.cc @@ -10,7 +10,7 @@ #include "zypp/Url.h" #include "zypp/PathInfo.h" #include "zypp/TmpPath.h" -#include "zypp/source/yum/YUMDownloader.h" +#include "zypp/repo/yum/Downloader.h" using std::cout; @@ -19,13 +19,13 @@ using std::string; using namespace zypp; using namespace boost::unit_test; -using namespace zypp::source::yum; +using namespace zypp::repo; void yum_download_test(const string &dir) { Pathname p = dir + "/10.2-updates-subset"; Url url("dir:" + p.asString()); - YUMDownloader yum(url, "/"); + yum::Downloader yum(url, "/"); filesystem::TmpDir tmp; Pathname localdir(tmp.path()); diff --git a/zypp/CMakeLists.txt b/zypp/CMakeLists.txt index 5e217f7..fb8b4ea 100644 --- a/zypp/CMakeLists.txt +++ b/zypp/CMakeLists.txt @@ -741,7 +741,6 @@ INSTALL( FILES ) SET( zypp_source_susetags_SRCS - source/susetags/SUSETagsDownloader.cc source/susetags/MediaMetadataParser.cc source/susetags/MediaPatchesMetadataParser.cc source/susetags/PackagesLangParser.cc @@ -758,7 +757,6 @@ SET( zypp_source_susetags_SRCS ) SET( zypp_source_susetags_HEADERS - source/susetags/SUSETagsDownloader.h source/susetags/MediaMetadataParser.h source/susetags/MediaPatchesMetadataParser.h source/susetags/PackagesLangParser.h @@ -780,7 +778,6 @@ INSTALL( FILES ) SET( zypp_source_yum_SRCS - source/yum/YUMDownloader.cc source/yum/YUMAtomImpl.cc source/yum/YUMGroupImpl.cc source/yum/YUMMessageImpl.cc @@ -790,11 +787,9 @@ SET( zypp_source_yum_SRCS source/yum/YUMProductImpl.cc source/yum/YUMScriptImpl.cc source/yum/YUMSourceImpl.cc - source/yum/YUMResourceType.cc ) SET( zypp_source_yum_HEADERS - source/yum/YUMDownloader.h source/yum/YUMAtomImpl.h source/yum/YUMGroupImpl.h source/yum/YUMMessageImpl.h @@ -804,7 +799,6 @@ SET( zypp_source_yum_HEADERS source/yum/YUMProductImpl.h source/yum/YUMScriptImpl.h source/yum/YUMSourceImpl.h - source/yum/YUMResourceType.h ) INSTALL( FILES @@ -1060,25 +1054,25 @@ SET( zypp_cache_sqlite3x_HEADERS # DESTINATION ${CMAKE_INSTALL_PREFIX}/include/zypp/cache/sqlite3x #) -SET( zypp_repository_SRCS +SET( zypp_repo_SRCS repo/dummy.cc repo/RepositoryImpl.cc repo/RepoException.cc repo/RepoType.cc ) -SET( zypp_repository_HEADERS +SET( zypp_repo_HEADERS repo/RepositoryImpl.h repo/RepoException.h repo/RepoType.h ) INSTALL( FILES - ${zypp_repository_HEADERS} + ${zypp_repo_HEADERS} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/zypp/repo ) -SET( zypp_repository_cached_SRCS +SET( zypp_repo_cached_SRCS repo/cached/RepoImpl.cc repo/cached/PackageImpl.cc repo/cached/PatchImpl.cc @@ -1089,7 +1083,7 @@ SET( zypp_repository_cached_SRCS repo/cached/AtomImpl.cc ) -SET( zypp_repository_cached_HEADERS +SET( zypp_repo_cached_HEADERS repo/cached/RepoImpl.h repo/cached/PackageImpl.h repo/cached/PatchImpl.h @@ -1100,14 +1094,33 @@ SET( zypp_repository_cached_HEADERS repo/cached/AtomImpl.h ) -SET( zypp_repository_data_SRCS +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 + repo/susetags/Downloader.cc +) + +SET( zypp_repo_susetags_HEADERS + repo/susetags/Downloader.h +) + + +SET( zypp_repo_data_SRCS repo/memory/PackageImpl.cc repo/memory/PatternImpl.cc repo/memory/ProductImpl.cc repo/memory/SrcPackageImpl.cc ) -SET( zypp_repository_data_HEADERS +SET( zypp_repo_data_HEADERS repo/memory/PackageImpl.h repo/memory/PatternImpl.h repo/memory/ProductImpl.h @@ -1135,9 +1148,11 @@ ${zypp_data_SRCS} ${zypp_media_proxyinfo_SRCS} ${zypp_media_SRCS} ${zypp_url_SRCS} -${zypp_repository_SRCS} -${zypp_repository_cached_SRCS} -${zypp_repository_data_SRCS} +${zypp_repo_SRCS} +${zypp_repo_cached_SRCS} +${zypp_repo_yum_SRCS} +${zypp_repo_susetags_SRCS} +${zypp_repo_data_SRCS} ${zypp_target_store_xml_SRCS} ${zypp_target_store_SRCS} ${zypp_target_rpm_SRCS} @@ -1179,7 +1194,7 @@ ${zypp_parser_HEADERS} ${zypp_HEADERS} ${zypp_zypp_detail_HEADERS} ${zypp_thread_HEADERS} -${zypp_repository_HEADERS} +${zypp_repo_HEADERS} ${zypp_source_susetags_HEADERS} ${zypp_target_modalias_HEADERS} ${zypp_target_HEADERS} diff --git a/zypp/RepoManager.cc b/zypp/RepoManager.cc index 42edaca..5698ddc 100644 --- a/zypp/RepoManager.cc +++ b/zypp/RepoManager.cc @@ -27,10 +27,10 @@ #include "zypp/MediaSetAccess.h" #include "zypp/parser/RepoFileReader.h" -#include "zypp/source/yum/YUMDownloader.h" +#include "zypp/repo/yum/Downloader.h" #include "zypp/parser/yum/RepoParser.h" -#include "zypp/source/susetags/SUSETagsDownloader.h" +#include "zypp/repo/susetags/Downloader.h" #include "zypp/parser/susetags/RepoParser.h" using namespace std; @@ -38,8 +38,7 @@ using namespace zypp; using namespace zypp::repo; using namespace zypp::filesystem; -using zypp::source::yum::YUMDownloader; -using zypp::source::susetags::SUSETagsDownloader; +using namespace zypp::repo; /////////////////////////////////////////////////////////////////// namespace zypp @@ -242,14 +241,14 @@ namespace zypp { case RepoType::RPMMD_e : { - YUMDownloader downloader( url, "/" ); + yum::Downloader downloader( url, "/" ); downloader.download(tmpdir.path()); // no error } break; case RepoType::YAST2_e : { - SUSETagsDownloader downloader( url, "/" ); + susetags::Downloader downloader( url, "/" ); downloader.download(tmpdir.path()); // no error } diff --git a/zypp/Repository.cc b/zypp/Repository.cc index 2a61085..a4f8a8d 100644 --- a/zypp/Repository.cc +++ b/zypp/Repository.cc @@ -46,5 +46,10 @@ namespace zypp return _pimpl->resolvables(); } + const RepoInfo Repository::info() const + { + return _pimpl->info(); + } + } diff --git a/zypp/Repository.h b/zypp/Repository.h index b596c2a..14d18d9 100644 --- a/zypp/Repository.h +++ b/zypp/Repository.h @@ -8,6 +8,7 @@ #include "zypp/base/PtrTypes.h" #include "zypp/base/SafeBool.h" #include "zypp/ResStore.h" +#include "zypp/RepoInfo.h" namespace zypp { @@ -53,6 +54,8 @@ namespace zypp const ResStore & resolvables(); + const RepoInfo info() const; + private: friend base::SafeBool::operator bool_type() const; /** \ref SafeBool test. */ diff --git a/zypp/ResObject.cc b/zypp/ResObject.cc index 9f34401..847b5a6 100644 --- a/zypp/ResObject.cc +++ b/zypp/ResObject.cc @@ -11,6 +11,7 @@ */ #include "zypp/ResObject.h" #include "zypp/source/SourceImpl.h" +#include "zypp/Repository.h" #include "zypp/detail/ResObjectImplIf.h" using namespace std; @@ -83,6 +84,12 @@ namespace zypp unsigned ResObject::sourceMediaNr() const { return pimpl().sourceMediaNr(); } + + Repository ResObject::repository() const + { return pimpl().repository(); } + + unsigned ResObject::mediaNr() const + { return pimpl().mediaNr(); } bool ResObject::installOnly() const { return pimpl().installOnly(); } diff --git a/zypp/ResObject.h b/zypp/ResObject.h index d0a349b..dac9851 100644 --- a/zypp/ResObject.h +++ b/zypp/ResObject.h @@ -27,6 +27,7 @@ namespace zypp class ResObjectImplIf; } class Source_Ref; + class Repository; class ByteCount; /////////////////////////////////////////////////////////////////// @@ -99,18 +100,29 @@ namespace zypp /** * Source providing this resolvable */ - Source_Ref source() const; + /*ZYPP_DEPRECATED */ Source_Ref source() const; /** + * Source providing this resolvable + */ + Repository repository() const; + + /** + * Media number where the resolvable is located + * 0 if no media access is required. + */ + unsigned mediaNr() const; + + /** * Media number where the resolvable is located * 0 if no media access is required. */ - unsigned sourceMediaNr() const; + /* ZYPP_DEPRECATED */ unsigned sourceMediaNr() const; /** * \deprecated Use sourceMediaNr */ - ZYPP_DEPRECATED unsigned mediaId() const + /* ZYPP_DEPRECATED */ unsigned mediaId() const { return sourceMediaNr(); } /** diff --git a/zypp/detail/ResObjectImplIf.cc b/zypp/detail/ResObjectImplIf.cc index f2a1489..86b3bd0 100644 --- a/zypp/detail/ResObjectImplIf.cc +++ b/zypp/detail/ResObjectImplIf.cc @@ -12,6 +12,7 @@ #include "zypp/detail/ResObjectImplIf.h" #include "zypp/source/SourceImpl.h" #include "zypp/SourceFactory.h" +#include "zypp/Repository.h" /////////////////////////////////////////////////////////////////// namespace zypp @@ -51,7 +52,13 @@ namespace zypp Source_Ref ResObjectImplIf::source() const { return Source_Ref::noSource; } + + Repository ResObjectImplIf::repository() const + { return Repository::noRepository; } + unsigned ResObjectImplIf::mediaNr() const + { return 0; } + unsigned ResObjectImplIf::sourceMediaNr() const { return 0; } diff --git a/zypp/detail/ResObjectImplIf.h b/zypp/detail/ResObjectImplIf.h index 486cd8b..33496f8 100644 --- a/zypp/detail/ResObjectImplIf.h +++ b/zypp/detail/ResObjectImplIf.h @@ -35,6 +35,7 @@ namespace zypp class Resolvable; class Source_Ref; + class Repository; /////////////////////////////////////////////////////////////////// namespace detail @@ -84,6 +85,15 @@ namespace zypp virtual ByteCount archivesize() const PURE_VIRTUAL; /** Backlink to the source providing this. */ + virtual Repository repository() const PURE_VIRTUAL; + + /** Number of the source media that provides the data + * required for installation. Zero, if no media access + * is required. + */ + virtual unsigned mediaNr() const PURE_VIRTUAL; + + /** Backlink to the source providing this. */ virtual Source_Ref source() const PURE_VIRTUAL; /** Number of the source media that provides the data diff --git a/zypp/parser/yum/RepoParser.cc b/zypp/parser/yum/RepoParser.cc index 55d1c84..58b0963 100644 --- a/zypp/parser/yum/RepoParser.cc +++ b/zypp/parser/yum/RepoParser.cc @@ -6,7 +6,7 @@ | /_____||_| |_| |_| | | | \---------------------------------------------------------------------*/ -/** \file zypp2/parser/yum/RepoParser.cc +/** \file zypp/parser/yum/RepoParser.cc * YUM repository metadata parser implementation. */ #include @@ -15,7 +15,7 @@ #include "zypp/base/Logger.h" #include "zypp/base/UserRequestException.h" -#include "zypp/source/yum/YUMResourceType.h" +#include "zypp/repo/yum/ResourceType.h" #include "zypp/parser/yum/RepomdFileReader.h" #include "zypp/parser/yum/PrimaryFileReader.h" @@ -33,7 +33,7 @@ #define ZYPP_BASE_LOGGER_LOGGROUP "parser" using namespace std; -using zypp::source::yum::YUMResourceType; +using zypp::repo::yum::ResourceType; namespace zypp { @@ -57,17 +57,17 @@ namespace zypp */ struct RepoParserJob { - RepoParserJob(const Pathname & filename, const YUMResourceType & type) + RepoParserJob(const Pathname & filename, const ResourceType & type) : _filename(filename), _type(type) {} const Pathname & filename() const { return _filename; } - const YUMResourceType & type() const { return _type; } + const ResourceType & type() const { return _type; } private: /** File to be processed */ Pathname _filename; /** Type of YUM file */ - YUMResourceType _type; + ResourceType _type; }; @@ -104,7 +104,7 @@ namespace zypp * \param loc location of discovered data file * \param dtype YUM data type */ - bool repomd_CB(const OnMediaLocation & loc, const YUMResourceType & dtype); + bool repomd_CB(const OnMediaLocation & loc, const ResourceType & dtype); /** * Callback for processing packages returned from \ref PrimaryFileReader. @@ -199,7 +199,7 @@ namespace zypp // ------------------------------------------------------------------------- bool RepoParser::Impl::repomd_CB( - const OnMediaLocation & loc, const YUMResourceType & dtype) + const OnMediaLocation & loc, const ResourceType & dtype) { DBG << "Adding " << dtype << " (" << loc.filename() << ") to RepoParser jobs " << endl; @@ -232,7 +232,7 @@ namespace zypp { DBG << "Adding patch " << loc.filename() << " to RepoParser jobs " << endl; - _jobs.push_back(RepoParserJob(loc.filename(), YUMResourceType::PATCH)); + _jobs.push_back(RepoParserJob(loc.filename(), ResourceType::PATCH)); return true; } @@ -339,7 +339,7 @@ namespace zypp switch(job.type().toEnum()) { // parse primary.xml.gz - case YUMResourceType::PRIMARY_e: + case ResourceType::PRIMARY_e: { PrimaryFileReader( cache_dir + job.filename(), @@ -348,7 +348,7 @@ namespace zypp break; } - case YUMResourceType::PATCHES_e: + case ResourceType::PATCHES_e: { PatchesFileReader( cache_dir + job.filename(), @@ -359,7 +359,7 @@ namespace zypp break; } - case YUMResourceType::PATCH_e: + case ResourceType::PATCH_e: { PatchFileReader( cache_dir + job.filename(), @@ -367,7 +367,7 @@ namespace zypp break; } - case YUMResourceType::OTHER_e: + case ResourceType::OTHER_e: { if (!_options.skipOther) { @@ -381,7 +381,7 @@ namespace zypp break; } - case YUMResourceType::FILELISTS_e: + case ResourceType::FILELISTS_e: { if (!_options.skipFilelists) { @@ -396,7 +396,7 @@ namespace zypp break; } - case YUMResourceType::PATTERNS_e: + case ResourceType::PATTERNS_e: { PatternFileReader( cache_dir + job.filename(), @@ -404,7 +404,7 @@ namespace zypp break; } - case YUMResourceType::PRODUCTS_e: + case ResourceType::PRODUCTS_e: { ProductFileReader( cache_dir + job.filename(), diff --git a/zypp/parser/yum/RepomdFileReader.cc b/zypp/parser/yum/RepomdFileReader.cc index cb7e33f..a55ac78 100644 --- a/zypp/parser/yum/RepomdFileReader.cc +++ b/zypp/parser/yum/RepomdFileReader.cc @@ -20,7 +20,7 @@ using namespace std; using namespace zypp::xml; -using zypp::source::yum::YUMResourceType; +using zypp::repo::yum::ResourceType; namespace zypp { @@ -75,7 +75,7 @@ namespace zypp Tag _tag; /** Type of metadata file. */ - source::yum::YUMResourceType _type; + repo::yum::ResourceType _type; /** Function for processing collected data. Passed-in through constructor. */ ProcessResource _callback; @@ -94,7 +94,7 @@ namespace zypp RepomdFileReader::Impl::Impl( const Pathname &repomd_file, const ProcessResource & callback) : - _tag(tag_NONE), _type(YUMResourceType::NONE_e), _callback(callback) + _tag(tag_NONE), _type(ResourceType::NONE_e), _callback(callback) { Reader reader( repomd_file ); MIL << "Reading " << repomd_file << endl; @@ -129,7 +129,7 @@ namespace zypp if ( reader_r->name() == "data" ) { _tag = tag_Data; - _type = YUMResourceType(reader_r->getAttribute("type").asString()); + _type = ResourceType(reader_r->getAttribute("type").asString()); return true; } diff --git a/zypp/parser/yum/RepomdFileReader.h b/zypp/parser/yum/RepomdFileReader.h index d0a4267..dd193ea 100644 --- a/zypp/parser/yum/RepomdFileReader.h +++ b/zypp/parser/yum/RepomdFileReader.h @@ -17,7 +17,7 @@ #include "zypp/base/Function.h" #include "zypp/OnMediaLocation.h" -#include "zypp/source/yum/YUMResourceType.h" +#include "zypp/repo/yum/ResourceType.h" namespace zypp { @@ -32,7 +32,7 @@ namespace zypp * other data about metadata files to be processed. * * After each package is read, a \ref OnMediaLocation - * and \ref source::yum::YUMResourceType is prepared and \ref _callback + * and \ref repo::yum::ResourceType is prepared and \ref _callback * is called with these two objects passed in. * * The \ref _callback is provided on construction. @@ -53,7 +53,7 @@ namespace zypp */ typedef function< bool( const OnMediaLocation &, - const source::yum::YUMResourceType &)> + const repo::yum::ResourceType &)> ProcessResource; /** diff --git a/zypp/repo/cached/AtomImpl.cc b/zypp/repo/cached/AtomImpl.cc index 43c33e8..505a4fa 100644 --- a/zypp/repo/cached/AtomImpl.cc +++ b/zypp/repo/cached/AtomImpl.cc @@ -109,7 +109,7 @@ Source_Ref AtomImpl::source() const return Source_Ref::noSource; } -unsigned AtomImpl::sourceMediaNr() const +unsigned AtomImpl::mediaNr() const { return 1; } diff --git a/zypp/repo/cached/AtomImpl.h b/zypp/repo/cached/AtomImpl.h index d4e73be..a09f02e 100644 --- a/zypp/repo/cached/AtomImpl.h +++ b/zypp/repo/cached/AtomImpl.h @@ -44,7 +44,7 @@ namespace cached virtual Date installtime() const; virtual Source_Ref source() const; - virtual unsigned sourceMediaNr() const; + virtual unsigned mediaNr() const; virtual Repository repository() const; diff --git a/zypp/repo/cached/MessageImpl.cc b/zypp/repo/cached/MessageImpl.cc index c9b0d21..944c77e 100644 --- a/zypp/repo/cached/MessageImpl.cc +++ b/zypp/repo/cached/MessageImpl.cc @@ -109,7 +109,7 @@ Source_Ref MessageImpl::source() const return Source_Ref::noSource; } -unsigned MessageImpl::sourceMediaNr() const +unsigned MessageImpl::mediaNr() const { return 1; } diff --git a/zypp/repo/cached/MessageImpl.h b/zypp/repo/cached/MessageImpl.h index 3225128..8b0c6f9 100644 --- a/zypp/repo/cached/MessageImpl.h +++ b/zypp/repo/cached/MessageImpl.h @@ -44,7 +44,7 @@ namespace cached virtual Date installtime() const; virtual Source_Ref source() const; - virtual unsigned sourceMediaNr() const; + virtual unsigned mediaNr() const; // MESSAGE virtual TranslatedText text() const; diff --git a/zypp/repo/cached/PackageImpl.cc b/zypp/repo/cached/PackageImpl.cc index 649fa94..93c952f 100644 --- a/zypp/repo/cached/PackageImpl.cc +++ b/zypp/repo/cached/PackageImpl.cc @@ -117,7 +117,7 @@ Source_Ref PackageImpl::source() const return Source_Ref::noSource; } -unsigned PackageImpl::sourceMediaNr() const +unsigned PackageImpl::mediaNr() const { return 1; } diff --git a/zypp/repo/cached/PackageImpl.h b/zypp/repo/cached/PackageImpl.h index 07c4b9c..bc51a36 100644 --- a/zypp/repo/cached/PackageImpl.h +++ b/zypp/repo/cached/PackageImpl.h @@ -44,7 +44,7 @@ namespace cached virtual Date installtime() const; virtual Source_Ref source() const; - virtual unsigned sourceMediaNr() const; + virtual unsigned mediaNr() const; // PACKAGE virtual CheckSum checksum() const; diff --git a/zypp/repo/cached/PatchImpl.cc b/zypp/repo/cached/PatchImpl.cc index ba8a667..0c11124 100644 --- a/zypp/repo/cached/PatchImpl.cc +++ b/zypp/repo/cached/PatchImpl.cc @@ -112,7 +112,7 @@ Source_Ref PatchImpl::source() const return Source_Ref::noSource; } -unsigned PatchImpl::sourceMediaNr() const +unsigned PatchImpl::mediaNr() const { return 1; } diff --git a/zypp/repo/cached/PatchImpl.h b/zypp/repo/cached/PatchImpl.h index 8d516f5..7aa9267 100644 --- a/zypp/repo/cached/PatchImpl.h +++ b/zypp/repo/cached/PatchImpl.h @@ -44,7 +44,7 @@ namespace cached virtual Date installtime() const; virtual Source_Ref source() const; - virtual unsigned sourceMediaNr() const; + virtual unsigned mediaNr() const; // PATCH virtual std::string id() const; diff --git a/zypp/repo/cached/PatternImpl.cc b/zypp/repo/cached/PatternImpl.cc index 859146f..fc9c442 100644 --- a/zypp/repo/cached/PatternImpl.cc +++ b/zypp/repo/cached/PatternImpl.cc @@ -112,7 +112,7 @@ Source_Ref PatternImpl::source() const return Source_Ref::noSource; } -unsigned PatternImpl::sourceMediaNr() const +unsigned PatternImpl::mediaNr() const { return 1; } diff --git a/zypp/repo/cached/PatternImpl.h b/zypp/repo/cached/PatternImpl.h index c9ff46a..1a049d0 100644 --- a/zypp/repo/cached/PatternImpl.h +++ b/zypp/repo/cached/PatternImpl.h @@ -44,7 +44,7 @@ namespace cached virtual Date installtime() const; virtual Source_Ref source() const; - virtual unsigned sourceMediaNr() const; + virtual unsigned mediaNr() const; // PATTERN virtual bool isDefault() const; diff --git a/zypp/repo/cached/ProductImpl.cc b/zypp/repo/cached/ProductImpl.cc index bee8bb3..bc39202 100644 --- a/zypp/repo/cached/ProductImpl.cc +++ b/zypp/repo/cached/ProductImpl.cc @@ -109,7 +109,7 @@ Source_Ref ProductImpl::source() const return Source_Ref::noSource; } -unsigned ProductImpl::sourceMediaNr() const +unsigned ProductImpl::mediaNr() const { return 1; } diff --git a/zypp/repo/cached/ProductImpl.h b/zypp/repo/cached/ProductImpl.h index 4ebca07..45fa465 100644 --- a/zypp/repo/cached/ProductImpl.h +++ b/zypp/repo/cached/ProductImpl.h @@ -44,7 +44,7 @@ namespace cached virtual Date installtime() const; virtual Source_Ref source() const; - virtual unsigned sourceMediaNr() const; + virtual unsigned mediaNr() const; // PRODUCT virtual std::string category() const; diff --git a/zypp/repo/cached/ScriptImpl.cc b/zypp/repo/cached/ScriptImpl.cc index d2a415b..140037d 100644 --- a/zypp/repo/cached/ScriptImpl.cc +++ b/zypp/repo/cached/ScriptImpl.cc @@ -109,7 +109,7 @@ Source_Ref ScriptImpl::source() const return Source_Ref::noSource; } -unsigned ScriptImpl::sourceMediaNr() const +unsigned ScriptImpl::mediaNr() const { return 1; } diff --git a/zypp/repo/cached/ScriptImpl.h b/zypp/repo/cached/ScriptImpl.h index e1cf2dc..9545694 100644 --- a/zypp/repo/cached/ScriptImpl.h +++ b/zypp/repo/cached/ScriptImpl.h @@ -44,7 +44,7 @@ namespace cached virtual Date installtime() const; virtual Source_Ref source() const; - virtual unsigned sourceMediaNr() const; + virtual unsigned mediaNr() const; // SCRIPT virtual Pathname do_script() const; diff --git a/zypp/repo/cached/SrcPackageImpl.cc b/zypp/repo/cached/SrcPackageImpl.cc index e9fc15a..d533824 100644 --- a/zypp/repo/cached/SrcPackageImpl.cc +++ b/zypp/repo/cached/SrcPackageImpl.cc @@ -82,7 +82,7 @@ bool SrcPackageImpl::installOnly() const return _install_only; } -unsigned SrcPackageImpl::sourceMediaNr() const +unsigned SrcPackageImpl::mediaNr() const { return _media_nr; } diff --git a/zypp/repo/cached/SrcPackageImpl.h b/zypp/repo/cached/SrcPackageImpl.h index d07d6f3..6e0c962 100644 --- a/zypp/repo/cached/SrcPackageImpl.h +++ b/zypp/repo/cached/SrcPackageImpl.h @@ -39,7 +39,7 @@ namespace cached virtual Pathname location() const; virtual bool installOnly() const; virtual Source_Ref source() const; - virtual unsigned sourceMediaNr() const; + virtual unsigned mediaNr() const; virtual Vendor vendor() const; protected: diff --git a/zypp/source/susetags/SUSETagsDownloader.cc b/zypp/repo/susetags/Downloader.cc similarity index 87% rename from zypp/source/susetags/SUSETagsDownloader.cc rename to zypp/repo/susetags/Downloader.cc index 623599d..54a209b 100644 --- a/zypp/source/susetags/SUSETagsDownloader.cc +++ b/zypp/repo/susetags/Downloader.cc @@ -5,24 +5,24 @@ #include "zypp/MediaSetAccess.h" #include "zypp/Fetcher.h" -#include "zypp/source/susetags/SUSETagsDownloader.h" +#include "zypp/repo/susetags/Downloader.h" using namespace std; namespace zypp { -namespace source +namespace repo { namespace susetags { -SUSETagsDownloader::SUSETagsDownloader( const Url &url, const Pathname &path ) +Downloader::Downloader( const Url &url, const Pathname &path ) : _url(url), _path(path) { } -void SUSETagsDownloader::download( const Pathname &dest_dir ) +void Downloader::download( const Pathname &dest_dir ) { MediaSetAccess media(_url, _path); Fetcher fetcher; diff --git a/zypp/source/susetags/SUSETagsDownloader.h b/zypp/repo/susetags/Downloader.h similarity index 89% rename from zypp/source/susetags/SUSETagsDownloader.h rename to zypp/repo/susetags/Downloader.h index 1d3ad5a..bb76fc6 100644 --- a/zypp/source/susetags/SUSETagsDownloader.h +++ b/zypp/repo/susetags/Downloader.h @@ -15,15 +15,15 @@ namespace zypp { - namespace source + namespace repo { namespace susetags { - class SUSETagsDownloader + class Downloader { public: - SUSETagsDownloader( const Url &url, const Pathname &path ); + Downloader( const Url &url, const Pathname &path ); void download( const Pathname &dest_dir ); private: Url _url; diff --git a/zypp/source/yum/YUMDownloader.cc b/zypp/repo/yum/Downloader.cc similarity index 79% rename from zypp/source/yum/YUMDownloader.cc rename to zypp/repo/yum/Downloader.cc index 34e6faa..0615f79 100644 --- a/zypp/source/yum/YUMDownloader.cc +++ b/zypp/repo/yum/Downloader.cc @@ -16,7 +16,7 @@ #include "zypp/parser/yum/RepomdFileReader.h" #include "zypp/parser/yum/PatchesFileReader.h" -#include "YUMDownloader.h" +#include "Downloader.h" using namespace std; using namespace zypp::xml; @@ -24,17 +24,17 @@ using namespace zypp::parser::yum; namespace zypp { -namespace source +namespace repo { namespace yum { -YUMDownloader::YUMDownloader( const Url &url, const Pathname &path ) +Downloader::Downloader( const Url &url, const Pathname &path ) : _url(url), _path(path), _media(url, path) { } -bool YUMDownloader::patches_Callback( const OnMediaLocation &loc, const string &id ) +bool Downloader::patches_Callback( const OnMediaLocation &loc, const string &id ) { MIL << id << " : " << loc << endl; _fetcher.enqueueDigested(loc); @@ -42,12 +42,12 @@ bool YUMDownloader::patches_Callback( const OnMediaLocation &loc, const string & } -bool YUMDownloader::repomd_Callback( const OnMediaLocation &loc, const YUMResourceType &dtype ) +bool Downloader::repomd_Callback( const OnMediaLocation &loc, const ResourceType &dtype ) { MIL << dtype << " : " << loc << endl; // skip other - if ( dtype == YUMResourceType::OTHER ) + if ( dtype == ResourceType::OTHER ) { MIL << "Skipping other.xml" << endl; return true; @@ -58,17 +58,17 @@ bool YUMDownloader::repomd_Callback( const OnMediaLocation &loc, const YUMResour // 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 == YUMResourceType::PATCHES ) + if ( dtype == ResourceType::PATCHES ) { _fetcher.start( _dest_dir, _media); // now the patches.xml file must exists - PatchesFileReader( _dest_dir + loc.filename(), bind( &YUMDownloader::patches_Callback, this, _1, _2)); + PatchesFileReader( _dest_dir + loc.filename(), bind( &Downloader::patches_Callback, this, _1, _2)); } return true; } -void YUMDownloader::download( const Pathname &dest_dir ) +void Downloader::download( const Pathname &dest_dir ) { Pathname repomdpath = "/repodata/repomd.xml"; Pathname keypath = "/repodata/repomd.xml.key"; @@ -99,7 +99,7 @@ void YUMDownloader::download( const Pathname &dest_dir ) _fetcher.reset(); Reader reader( dest_dir + "/repodata/repomd.xml" ); - RepomdFileReader( dest_dir + "/repodata/repomd.xml", bind( &YUMDownloader::repomd_Callback, this, _1, _2)); + RepomdFileReader( dest_dir + "/repodata/repomd.xml", bind( &Downloader::repomd_Callback, this, _1, _2)); // ready, go! _fetcher.start( dest_dir, _media); diff --git a/zypp/source/yum/YUMDownloader.h b/zypp/repo/yum/Downloader.h similarity index 89% rename from zypp/source/yum/YUMDownloader.h rename to zypp/repo/yum/Downloader.h index 3ecf504..ce2bf12 100644 --- a/zypp/source/yum/YUMDownloader.h +++ b/zypp/repo/yum/Downloader.h @@ -16,11 +16,11 @@ #include "zypp/OnMediaLocation.h" #include "zypp/MediaSetAccess.h" #include "zypp/parser/xml/Reader.h" -#include "zypp/source/yum/YUMResourceType.h" +#include "zypp/repo/yum/ResourceType.h" namespace zypp { - namespace source + namespace repo { namespace yum { @@ -29,25 +29,25 @@ namespace zypp * to a local directory * * \code - * YUMDownloader yum(url, path); + * Downloader yum(url, path); * yum.download("localdir"); * \endcode */ - class YUMDownloader + class Downloader { public: /** * Create the download object for a repository * located in \a url with path \a path */ - YUMDownloader( const Url &url, const Pathname &path ); + Downloader( const Url &url, const Pathname &path ); /** * starts the download to local directory \a dest_dir */ void download( const Pathname &dest_dir ); protected: - bool repomd_Callback( const OnMediaLocation &loc, const YUMResourceType &dtype ); + bool repomd_Callback( const OnMediaLocation &loc, const ResourceType &dtype ); bool patches_Callback( const OnMediaLocation &loc, const std::string &id ); private: Url _url; diff --git a/zypp/repo/yum/ResourceType.cc b/zypp/repo/yum/ResourceType.cc new file mode 100644 index 0000000..3642803 --- /dev/null +++ b/zypp/repo/yum/ResourceType.cc @@ -0,0 +1,92 @@ +/*---------------------------------------------------------------------\ +| ____ _ __ __ ___ | +| |__ / \ / / . \ . \ | +| / / \ V /| _/ _/ | +| / /__ | | | | | | | +| /_____||_| |_| |_| | +| | +\---------------------------------------------------------------------*/ + +#include +#include "zypp/base/Exception.h" +#include "ResourceType.h" + +namespace zypp +{ + namespace repo + { + namespace yum + { + + + static std::map _table; + + 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::PRODUCTS(ResourceType::PRODUCTS_e); + const ResourceType ResourceType::PATTERNS(ResourceType::PATTERNS_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["products"] = ResourceType::PRODUCTS_e; + _table["patterns"] = ResourceType::PATTERNS_e; + _table["NONE"] = _table["none"] = ResourceType::NONE_e; + } + + std::map::const_iterator it + = _table.find(strval_r); + if (it == _table.end()) + { + ZYPP_THROW(Exception( + "ResourceType parse: illegal string value '" + strval_r + "'")); + } + 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[PRODUCTS_e] = "products"; + _table[PATTERNS_e] = "patterns"; + _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/source/yum/YUMResourceType.h b/zypp/repo/yum/ResourceType.h similarity index 59% rename from zypp/source/yum/YUMResourceType.h rename to zypp/repo/yum/ResourceType.h index 01fc615..6126902 100644 --- a/zypp/source/yum/YUMResourceType.h +++ b/zypp/repo/yum/ResourceType.h @@ -15,7 +15,7 @@ namespace zypp { - namespace source + namespace repo { namespace yum { @@ -24,17 +24,17 @@ namespace zypp /** * */ - struct YUMResourceType + struct ResourceType { - static const YUMResourceType REPOMD; - static const YUMResourceType PRIMARY; - static const YUMResourceType OTHER; - static const YUMResourceType FILELISTS; - static const YUMResourceType GROUP; - static const YUMResourceType PATCHES; // suse extension - static const YUMResourceType PATCH; // suse extension - static const YUMResourceType PRODUCTS; // suse extension - static const YUMResourceType PATTERNS; // suse extension + 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 PRODUCTS; // suse extension + static const ResourceType PATTERNS; // suse extension enum Type { @@ -50,13 +50,13 @@ namespace zypp PATTERNS_e }; - YUMResourceType(Type type) : _type(type) {} + ResourceType(Type type) : _type(type) {} - explicit YUMResourceType(const std::string & strval_r); + explicit ResourceType(const std::string & strval_r); const Type toEnum() const { return _type; } - YUMResourceType::Type parse(const std::string & strval_r); + ResourceType::Type parse(const std::string & strval_r); const std::string & asString() const; @@ -64,10 +64,10 @@ namespace zypp }; - inline std::ostream & operator<<( std::ostream & str, const YUMResourceType & obj ) + inline std::ostream & operator<<( std::ostream & str, const ResourceType & obj ) { return str << obj.asString(); } - inline bool operator==(const YUMResourceType & obj1, const YUMResourceType & obj2) + inline bool operator==(const ResourceType & obj1, const ResourceType & obj2) { return obj1._type == obj2._type; } diff --git a/zypp/source/yum/YUMResourceType.cc b/zypp/source/yum/YUMResourceType.cc deleted file mode 100644 index b3f98a1..0000000 --- a/zypp/source/yum/YUMResourceType.cc +++ /dev/null @@ -1,92 +0,0 @@ -/*---------------------------------------------------------------------\ -| ____ _ __ __ ___ | -| |__ / \ / / . \ . \ | -| / / \ V /| _/ _/ | -| / /__ | | | | | | | -| /_____||_| |_| |_| | -| | -\---------------------------------------------------------------------*/ - -#include -#include "zypp/base/Exception.h" -#include "YUMResourceType.h" - -namespace zypp -{ - namespace source - { - namespace yum - { - - - static std::map _table; - - const YUMResourceType YUMResourceType::REPOMD(YUMResourceType::REPOMD_e); - const YUMResourceType YUMResourceType::PRIMARY(YUMResourceType::PRIMARY_e); - const YUMResourceType YUMResourceType::OTHER(YUMResourceType::OTHER_e); - const YUMResourceType YUMResourceType::FILELISTS(YUMResourceType::FILELISTS_e); - const YUMResourceType YUMResourceType::GROUP(YUMResourceType::GROUP_e); - const YUMResourceType YUMResourceType::PATCHES(YUMResourceType::PATCHES_e); - const YUMResourceType YUMResourceType::PATCH(YUMResourceType::PATCH_e); - const YUMResourceType YUMResourceType::PRODUCTS(YUMResourceType::PRODUCTS_e); - const YUMResourceType YUMResourceType::PATTERNS(YUMResourceType::PATTERNS_e); - - - YUMResourceType::YUMResourceType(const std::string & strval_r) - : _type(parse(strval_r)) - {} - - YUMResourceType::Type YUMResourceType::parse(const std::string & strval_r) - { - if (_table.empty()) - { - // initialize it - _table["repomd"] = YUMResourceType::REPOMD_e; - _table["primary"] = YUMResourceType::PRIMARY_e; - _table["other"] = YUMResourceType::OTHER_e; - _table["filelists"] = YUMResourceType::FILELISTS_e; - _table["group"] = YUMResourceType::GROUP_e; - _table["patches"] = YUMResourceType::PATCHES_e; - _table["patch"] = YUMResourceType::PATCH_e; - _table["products"] = YUMResourceType::PRODUCTS_e; - _table["patterns"] = YUMResourceType::PATTERNS_e; - _table["NONE"] = _table["none"] = YUMResourceType::NONE_e; - } - - std::map::const_iterator it - = _table.find(strval_r); - if (it == _table.end()) - { - ZYPP_THROW(Exception( - "YUMResourceType parse: illegal string value '" + strval_r + "'")); - } - return it->second; - } - - - const std::string & YUMResourceType::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[PRODUCTS_e] = "products"; - _table[PATTERNS_e] = "patterns"; - _table[NONE_e] = "NONE"; - } - return _table[_type]; - } - - - } // ns yum - } // ns source -} // ns zypp - -// vim: set ts=2 sts=2 sw=2 et ai: -- 2.7.4