#include <boost/test/parameterized_test.hpp>
#include <boost/test/unit_test_log.hpp>
+#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;
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*
{ 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; }
{ return _pimpl->gpgkey_url; }
std::set<Url> 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; }
{
str << "--------------------------------------" << std::endl;
str << "- alias : " << alias() << std::endl;
- std::set<Url> url_set(baseUrls());
- for ( std::set<Url>::const_iterator it = url_set.begin();
- it != url_set.end();
+ for ( urls_const_iterator it = baseUrlsBegin();
+ it != baseUrlsEnd();
++it )
{
str << "- url : " << *it << std::endl;
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;
#include <set>
#include "zypp/base/PtrTypes.h"
#include "zypp/base/Iterator.h"
+#include "zypp/base/Deprecated.h"
#include "zypp/Pathname.h"
#include "zypp/Url.h"
*
* \deprecated IMO superfluous as we provide begin/end iterator.
*/
- std::set<Url> baseUrls() const;
+ ZYPP_DEPRECATED std::set<Url> baseUrls() const;
/**
* \short Repository path
static void assert_urls( const RepoInfo &info )
{
- if (info.baseUrls().empty())
+ if (info.baseUrlsEmpty())
ZYPP_THROW(RepoNoUrlException());
}
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() );
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) )
"$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;
}