From: Duncan Mac-Vicar P Date: Mon, 30 Jul 2007 21:55:39 +0000 (+0000) Subject: arch and basearch working X-Git-Tag: BASE-SuSE-Linux-10_3-Branch~438 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f0ac3fe24012798a47a80773c896a5a2e0856ba0;p=platform%2Fupstream%2Flibzypp.git arch and basearch working --- diff --git a/tests/repo/RepoVariables_test.cc b/tests/repo/RepoVariables_test.cc index 85f3638..44289a5 100644 --- a/tests/repo/RepoVariables_test.cc +++ b/tests/repo/RepoVariables_test.cc @@ -7,13 +7,13 @@ #include #include +#include "zypp/ZYppFactory.h" #include "zypp/Url.h" #include "zypp/PathInfo.h" #include "zypp/TmpPath.h" #include "zypp/ZConfig.h" #include "zypp/repo/RepoVariables.h" - using std::cout; using std::endl; using std::string; @@ -28,6 +28,10 @@ void replace_test(const string &dir) BOOST_CHECK_EQUAL(replacer("http://foo/$arch/bar"), "http://foo/"+ ZConfig::instance().systemArchitecture().asString() + "/bar"); + + getZYpp()->setArchitecture(Arch("i686")); + BOOST_CHECK_EQUAL(replacer("http://foo/$arch/bar/$basearch"), + "http://foo/i686/bar/i386"); } test_suite* diff --git a/zypp/RepoInfo.cc b/zypp/RepoInfo.cc index bf5baa9..f68dded 100644 --- a/zypp/RepoInfo.cc +++ b/zypp/RepoInfo.cc @@ -186,7 +186,10 @@ namespace zypp { return _pimpl->alias; } std::string RepoInfo::name() const - { return _pimpl->name; } + { + repo::RepoVariablesStringReplacer replacer; + return replacer(_pimpl->name); + } Pathname RepoInfo::filepath() const { return _pimpl->filepath; } @@ -204,7 +207,19 @@ namespace zypp { return _pimpl->gpgkey_url; } std::set RepoInfo::baseUrls() const - { return _pimpl->baseUrls; } + { + RepoInfo::url_set replaced_urls; + repo::RepoVariablesUrlReplacer replacer; + for ( url_set::const_iterator it = _pimpl->baseUrls.begin(); + it != _pimpl->baseUrls.end(); + ++it ) + { + replaced_urls.insert(replacer(*it)); + } + return replaced_urls; + + return _pimpl->baseUrls; + } Pathname RepoInfo::path() const { return _pimpl->path; } @@ -233,9 +248,8 @@ namespace zypp { str << "--------------------------------------" << std::endl; str << "- alias : " << alias() << std::endl; - std::set url_set(baseUrls()); - for ( std::set::const_iterator it = url_set.begin(); - it != url_set.end(); + for ( urls_const_iterator it = baseUrlsBegin(); + it != baseUrlsEnd(); ++it ) { str << "- url : " << *it << std::endl; @@ -253,23 +267,24 @@ namespace zypp std::ostream & RepoInfo::dumpRepoOn( std::ostream & str ) const { + // we save the original data without variable replacement str << "[" << alias() << "]" << endl; - str << "name=" << name() << endl; + str << "name=" << _pimpl->name << endl; - if ( ! baseUrls().empty() ) + if ( ! _pimpl->baseUrls.empty() ) str << "baseurl="; - for ( urls_const_iterator it = baseUrlsBegin(); - it != baseUrlsEnd(); + for ( url_set::const_iterator it = _pimpl->baseUrls.begin(); + it != _pimpl->baseUrls.end(); ++it ) { str << *it << endl; } - if ( ! path().empty() ) + if ( ! _pimpl->path.empty() ) str << "path="<< path() << endl; - if ( ! (mirrorListUrl().asString().empty()) ) - str << "mirrorlist=" << mirrorListUrl() << endl; + if ( ! (_pimpl->mirrorlist_url.asString().empty()) ) + str << "mirrorlist=" << _pimpl->mirrorlist_url << endl; str << "type=" << type().asString() << endl; str << "enabled=" << (enabled() ? "1" : "0") << endl; diff --git a/zypp/RepoInfo.h b/zypp/RepoInfo.h index 7c06ff9..4de790a 100644 --- a/zypp/RepoInfo.h +++ b/zypp/RepoInfo.h @@ -17,6 +17,7 @@ #include #include "zypp/base/PtrTypes.h" #include "zypp/base/Iterator.h" +#include "zypp/base/Deprecated.h" #include "zypp/Pathname.h" #include "zypp/Url.h" @@ -88,7 +89,7 @@ namespace zypp * * \deprecated IMO superfluous as we provide begin/end iterator. */ - std::set baseUrls() const; + ZYPP_DEPRECATED std::set baseUrls() const; /** * \short Repository path diff --git a/zypp/RepoManager.cc b/zypp/RepoManager.cc index c91dba9..5e639f8 100644 --- a/zypp/RepoManager.cc +++ b/zypp/RepoManager.cc @@ -170,7 +170,7 @@ namespace zypp static void assert_urls( const RepoInfo &info ) { - if (info.baseUrls().empty()) + if (info.baseUrlsEmpty()) ZYPP_THROW(RepoNoUrlException()); } diff --git a/zypp/repo/PackageProvider.cc b/zypp/repo/PackageProvider.cc index 633518f..a2de3fb 100644 --- a/zypp/repo/PackageProvider.cc +++ b/zypp/repo/PackageProvider.cc @@ -90,10 +90,10 @@ namespace zypp Url url; RepoInfo info = _package->repository().info(); // FIXME we only support the first url for now. - if ( info.baseUrls().empty() ) + if ( info.baseUrlsEmpty() ) ZYPP_THROW(Exception("No url in repository.")); else - url = * info.baseUrls().begin(); + url = * info.baseUrlsBegin(); MIL << "provide Package " << _package << endl; ScopedGuard guardReport( newReport() ); @@ -125,10 +125,10 @@ namespace zypp Url url; RepoInfo info = _package->repository().info(); // FIXME we only support the first url for now. - if ( info.baseUrls().empty() ) + if ( info.baseUrlsEmpty() ) ZYPP_THROW(Exception("No url in repository.")); else - url = * info.baseUrls().begin(); + url = * info.baseUrlsBegin(); // check whether to process patch/delta rpms if ( MediaManager::downloads(url) ) diff --git a/zypp/repo/RepoVariables.cc b/zypp/repo/RepoVariables.cc index 445d32c..4e8cb23 100644 --- a/zypp/repo/RepoVariables.cc +++ b/zypp/repo/RepoVariables.cc @@ -62,9 +62,22 @@ std::string RepoVariablesStringReplacer::operator()( const std::string &value ) "$arch", ZConfig::instance().systemArchitecture().asString() ); // $basearch - ZConfig::instance().systemArchitecture(); - ZConfig::instance(); + Arch::CompatSet cset( Arch::compatSet( ZConfig::instance().systemArchitecture() ) ); + Arch::CompatSet::const_iterator it = cset.end(); + --it; + // now at noarch + --it; + + Arch basearch = *it; + if ( basearch == Arch_noarch ) + { + basearch = ZConfig::instance().systemArchitecture(); + } + + newvalue = gsub( newvalue, + "$basearch", + basearch.asString() ); return newvalue; }