--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<metalink version="3.0" xmlns="http://www.metalinker.org/" type="dynamic" pubdate="Wed, 03 Nov 2010 13:30:11 GMT" generator="mirrormanager" xmlns:mm0="http://fedorahosted.org/mirrormanager">
+ <files>
+ <file name="repomd.xml">
+ <mm0:timestamp>1288734483</mm0:timestamp>
+ <size>4834</size>
+ <verification>
+ <hash type="md5">8fd7745c38277ac8b5618107edb72b7e</hash>
+ <hash type="sha1">de06c2b34f5b13fe6029da59475359675931eb9d</hash>
+ <hash type="sha256">d6f8135c9d5ac370fafd258c89cfb574989cd8557044d9551eefd1aaf2c54c48</hash>
+ <hash type="sha512">f43d747fa0134e9990297f98771f74a7a449f1b5a53a6936949af5e0b51f3b3834b69af3e25ae4dd7c97415d5570abb5c0a4588ddfae673228f46a83f200b5cd</hash>
+ </verification>
+ <mm0:alternates>
+ <mm0:alternate>
+ <mm0:timestamp>1288642986</mm0:timestamp>
+ <size>4834</size>
+ <verification>
+ <hash type="md5">bd32127a8b2ae7a370be3dbf876afbc7</hash>
+ <hash type="sha1">b4b9ea2494aefd82ff08915c28f6548a31625744</hash>
+ <hash type="sha256">b0d8ae9c43bfd06829092273b409cb0f6e2b581fafd370f11752842c0cd0c2c6</hash>
+ <hash type="sha512">78d2eff26e6a12bb1b1bbc78956f548734e921335943afabcfbf4f3ba6d164e8820eb2e685fad78088d2b42b7ec75fe4bde8ad6f5d7e9cf44e70837ce23fb758</hash>
+ </verification>
+ </mm0:alternate>
+ </mm0:alternates>
+ <resources maxconnections="1">
+ <url protocol="http" type="http" location="DE" preference="100" >http://ftp-stud.hs-esslingen.de/pub/fedora/linux/updates/13/x86_64/repodata/repomd.xml</url>
+ <url protocol="ftp" type="ftp" location="DE" preference="100" >ftp://ftp-stud.hs-esslingen.de/pub/fedora/linux/updates/13/x86_64/repodata/repomd.xml</url>
+ <url protocol="rsync" type="rsync" location="DE" preference="100" >rsync://ftp-stud.hs-esslingen.de/fedora/linux/updates/13/x86_64/repodata/repomd.xml</url>
+ <url protocol="http" type="http" location="BE" preference="45" >http://mirror.eurid.eu/fedora/linux/updates/13/x86_64/repodata/repomd.xml</url>
+ <url protocol="ftp" type="ftp" location="BE" preference="45" >ftp://mirror.eurid.eu/fedora/linux/updates/13/x86_64/repodata/repomd.xml</url>
+ </resources>
+ </file>
+ </files>
+</metalink>
*
*/
#include <iostream>
+#include <vector>
#include "zypp/base/Logger.h"
#include "zypp/base/DefaultIntegral.h"
#include "zypp/RepoInfo.h"
#include "zypp/repo/RepoInfoBaseImpl.h"
+#include "zypp/repo/RepoMirrorList.h"
#include "zypp/ExternalProgram.h"
#include "zypp/media/MediaAccess.h"
, gpgcheck(indeterminate)
, keeppackages(indeterminate)
, type(repo::RepoType::NONE_e)
+ , emptybaseurls(false)
{}
~Impl()
Pathname licenseTgz() const
{ return metadatapath.empty() ? Pathname() : metadatapath / path / "license.tar.gz"; }
+ Url getmirrorListUrl() const
+ {
+ repo::RepoVariablesUrlReplacer replacer;
+ return replacer(mirrorlist_url);
+ }
+
+ Url &setmirrorListUrl()
+ {
+ return mirrorlist_url;
+ }
+
+ const std::set<Url> &baseUrls() const
+ {
+ if ( _baseUrls.empty() && ! (getmirrorListUrl().asString().empty()) )
+ {
+ emptybaseurls = true;
+ repo::RepoMirrorList rmirrorlist (getmirrorListUrl());
+ std::vector<Url> rmurls = rmirrorlist.getUrls();
+ _baseUrls.insert(rmurls.begin(), rmurls.end());
+ }
+ return _baseUrls;
+ }
+
+ std::set<Url> &baseUrls()
+ {
+ return _baseUrls;
+ }
+
+ bool baseurl2dump() const
+ {
+ return !emptybaseurls && !_baseUrls.empty();
+ }
+
public:
TriBool gpgcheck;
TriBool keeppackages;
Url gpgkey_url;
repo::RepoType type;
- Url mirrorlist_url;
- std::set<Url> baseUrls;
Pathname path;
std::string service;
std::string targetDistro;
Pathname metadatapath;
Pathname packagespath;
DefaultIntegral<unsigned,defaultPriority> priority;
- public:
+ mutable bool emptybaseurls;
private:
+ Url mirrorlist_url;
+ mutable std::set<Url> _baseUrls;
+
friend Impl * rwcowClone<Impl>( const Impl * rhs );
/** clone for RWCOW_pointer */
Impl * clone() const
void RepoInfo::setMirrorListUrl( const Url &url )
{
- _pimpl->mirrorlist_url = url;
+ _pimpl->setmirrorListUrl() = url;
}
void RepoInfo::setGpgKeyUrl( const Url &url )
void RepoInfo::addBaseUrl( const Url &url )
{
- _pimpl->baseUrls.insert(url);
+ _pimpl->baseUrls().insert(url);
}
void RepoInfo::setBaseUrl( const Url &url )
{
- _pimpl->baseUrls.clear();
+ _pimpl->baseUrls().clear();
addBaseUrl(url);
}
Url RepoInfo::mirrorListUrl() const
{
- repo::RepoVariablesUrlReplacer replacer;
- return replacer(_pimpl->mirrorlist_url);
+ return _pimpl->getmirrorListUrl();
}
Url RepoInfo::gpgKeyUrl() const
{
RepoInfo::url_set replaced_urls;
repo::RepoVariablesUrlReplacer replacer;
- for ( url_set::const_iterator it = _pimpl->baseUrls.begin();
- it != _pimpl->baseUrls.end();
+ for ( url_set::const_iterator it = _pimpl->baseUrls().begin();
+ it != _pimpl->baseUrls().end();
++it )
{
replaced_urls.insert(replacer(*it));
RepoInfo::urls_const_iterator RepoInfo::baseUrlsBegin() const
{
- return make_transform_iterator( _pimpl->baseUrls.begin(),
+ return make_transform_iterator( _pimpl->baseUrls().begin(),
repo::RepoVariablesUrlReplacer() );
//return _pimpl->baseUrls.begin();
}
RepoInfo::urls_const_iterator RepoInfo::baseUrlsEnd() const
{
//return _pimpl->baseUrls.end();
- return make_transform_iterator( _pimpl->baseUrls.end(),
+ return make_transform_iterator( _pimpl->baseUrls().end(),
repo::RepoVariablesUrlReplacer() );
}
RepoInfo::urls_size_type RepoInfo::baseUrlsSize() const
- { return _pimpl->baseUrls.size(); }
+ { return _pimpl->baseUrls().size(); }
bool RepoInfo::baseUrlsEmpty() const
- { return _pimpl->baseUrls.empty(); }
+ { return _pimpl->baseUrls().empty(); }
// false by default (if not set by setKeepPackages)
bool RepoInfo::keepPackages() const
{
if (indeterminate(_pimpl->keeppackages))
{
- if (_pimpl->baseUrls.empty())
+ if (_pimpl->baseUrls().empty())
return false;
else if ( baseUrlsBegin()->schemeIsDownloading() )
return true;
std::ostream & RepoInfo::dumpOn( std::ostream & str ) const
{
RepoInfoBase::dumpOn(str);
- for ( urls_const_iterator it = baseUrlsBegin();
- it != baseUrlsEnd();
- ++it )
+ if ( _pimpl->baseurl2dump() )
{
- str << "- url : " << *it << std::endl;
+ for ( urls_const_iterator it = baseUrlsBegin();
+ it != baseUrlsEnd();
+ ++it )
+ {
+ str << "- url : " << *it << std::endl;
+ }
+ }
+ if ( ! (_pimpl->getmirrorListUrl().asString().empty()) )
+ {
+ str << "- mirrorlist : " << _pimpl->getmirrorListUrl() << std::endl;
}
str << "- path : " << path() << std::endl;
str << "- type : " << type() << std::endl;
{
RepoInfoBase::dumpAsIniOn(str);
- if ( ! _pimpl->baseUrls.empty() )
- str << "baseurl=";
- for ( url_set::const_iterator it = _pimpl->baseUrls.begin();
- it != _pimpl->baseUrls.end();
- ++it )
+ if ( _pimpl->baseurl2dump() )
{
- str << *it << endl;
+ str << "baseurl=";
+ for ( url_set::const_iterator it = _pimpl->baseUrls().begin();
+ it != _pimpl->baseUrls().end();
+ ++it )
+ {
+ str << *it << endl;
+ }
}
if ( ! _pimpl->path.empty() )
str << "path="<< path() << endl;
- if ( ! (_pimpl->mirrorlist_url.asString().empty()) )
- str << "mirrorlist=" << _pimpl->mirrorlist_url << endl;
+ if ( ! (_pimpl->getmirrorListUrl().asString().empty()) )
+ str << "mirrorlist=" << _pimpl->getmirrorListUrl() << endl;
str << "type=" << type().asString() << endl;
str << " mirrorlist=\"" << escape(tmpstr) << "\"";
str << ">" << endl;
- for (RepoInfo::urls_const_iterator urlit = baseUrlsBegin();
- urlit != baseUrlsEnd(); ++urlit)
- str << "<url>" << escape(urlit->asString()) << "</url>" << endl;
+ if ( _pimpl->baseurl2dump() )
+ {
+ for (RepoInfo::urls_const_iterator urlit = baseUrlsBegin();
+ urlit != baseUrlsEnd(); ++urlit)
+ str << "<url>" << escape(urlit->asString()) << "</url>" << endl;
+ }
str << "</repo>" << endl;
return str;
--- /dev/null
+/*---------------------------------------------------------------------\
+| ____ _ __ __ ___ |
+| |__ / \ / / . \ . \ |
+| / / \ V /| _/ _/ |
+| / /__ | | | | | | |
+| /_____||_| |_| |_| |
+| |
+\---------------------------------------------------------------------*/
+/** \file zypp/repo/RepoMirrorList.cc
+ *
+*/
+
+#include <iostream>
+#include <vector>
+#include "zypp/repo/RepoMirrorList.h"
+#include "zypp/media/MetaLinkParser.h"
+#include "zypp/MediaSetAccess.h"
+#include "zypp/base/LogTools.h"
+
+using namespace std;
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////
+ namespace repo
+ { /////////////////////////////////////////////////////////////////
+
+ RepoMirrorList::RepoMirrorList( const Url &url )
+ {
+ Pathname filepath (url.getPathName());
+ Url abs_url (url);
+ std::vector<Url> my_urls;
+
+ DBG << "Getting MirrorList from URL: " << abs_url << endl;
+
+ abs_url.setPathName("");
+ abs_url.setQueryParam("mediahandler", "curl");
+
+ MediaSetAccess access (abs_url);
+ Pathname tmpfile = access.provideFile(filepath);
+
+ InputStream tmpfstream (tmpfile);
+
+ if ( url.asString().find("/metalink") != string::npos )
+ {
+ media::MetaLinkParser metalink;
+ metalink.parse(tmpfstream);
+ my_urls = metalink.getUrls();
+ }
+ else
+ {
+ string tmpurl;
+ while (getline(tmpfstream.stream(), tmpurl))
+ {
+ my_urls.push_back(Url(tmpurl));
+ }
+ }
+
+ int valid_urls = 0;
+ for (std::vector<Url>::iterator it = my_urls.begin() ; it != my_urls.end() and valid_urls < 4 ; ++it)
+ {
+ if ( it->getScheme() != "rsync" )
+ {
+ size_t delpos = it->getPathName().find("repodata/repomd.xml");
+ if( delpos != string::npos )
+ {
+ it->setPathName( it->getPathName().erase(delpos) );
+ }
+ urls.push_back(*it);
+ ++valid_urls;
+ }
+ }
+ }
+
+ std::vector<Url> RepoMirrorList::getUrls() const
+ {
+ return urls;
+ }
+
+ RepoMirrorList::~RepoMirrorList()
+ {}
+
+ /////////////////////////////////////////////////////////////////
+ } // namespace repo
+ ///////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////