1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
13 #include "zypp/base/String.h"
14 #include "zypp/repo/RepoException.h"
15 #include "zypp/ZConfig.h"
16 #include "zypp/ZYppFactory.h"
17 #include "RepoVariables.h"
26 RepoVariablesStringReplacer::RepoVariablesStringReplacer()
29 RepoVariablesStringReplacer::~RepoVariablesStringReplacer()
32 std::string RepoVariablesStringReplacer::operator()( const std::string &value ) const
34 string newvalue(value);
37 Arch sysarch( ZConfig::instance().systemArchitecture() );
38 newvalue = str::gsub( newvalue, "$arch", sysarch.asString() );
41 Arch basearch( sysarch.baseArch( ) );
43 newvalue = str::gsub( newvalue, "$basearch", basearch.asString() );
45 // $releasever (Target::distributionVersion assumes root=/ if target not initialized)
46 newvalue = str::gsub( newvalue, "$releasever", Target::distributionVersion(Pathname()/*guess*/) );
51 //////////////////////////////////////////////////////////////////////
53 RepoVariablesUrlReplacer::RepoVariablesUrlReplacer()
56 RepoVariablesUrlReplacer::~RepoVariablesUrlReplacer()
60 * Replaces '$arch' and '$basearch' in the path and query part of the URL
61 * with the global ZYpp values. Examples:
63 * ftp://user:secret@site.net/$arch/ -> ftp://user:secret@site.net/i686/
64 * http://site.net/?basearch=$basearch -> http://site.net/?basearch=i386
66 Url RepoVariablesUrlReplacer::operator()( const Url &value ) const
69 RepoVariablesStringReplacer replacer;
70 newurl.setPathData(replacer(value.getPathData()));
71 newurl.setQueryString(replacer(value.getQueryString()));
79 // vim: set ts=2 sts=2 sw=2 et ai: