Imported Upstream version 14.30.0
[platform/upstream/libzypp.git] / zypp / RepoInfo.cc
index a2adf61..a8dcaa0 100644 (file)
  *
 */
 #include <iostream>
+#include <vector>
 
 #include "zypp/base/Logger.h"
 #include "zypp/base/DefaultIntegral.h"
-#include "zypp/media/MediaAccess.h"
+#include "zypp/parser/xml/XmlEscape.h"
 
 #include "zypp/RepoInfo.h"
+#include "zypp/TriBool.h"
+#include "zypp/Pathname.h"
+#include "zypp/repo/RepoMirrorList.h"
+#include "zypp/ExternalProgram.h"
+#include "zypp/media/MediaAccess.h"
+
+#include "zypp/base/IOStream.h"
+#include "zypp/base/InputStream.h"
+#include "zypp/parser/xml/Reader.h"
 
-using namespace std;
+using std::endl;
+using zypp::xml::escape;
 
 ///////////////////////////////////////////////////////////////////
 namespace zypp
@@ -30,27 +41,16 @@ namespace zypp
   /** RepoInfo implementation. */
   struct RepoInfo::Impl
   {
-    enum FlagsDeterminedState
-    {
-      FLAG_ENABLED      = 1,
-      FLAG_AUTOREFRESH  = 2,
-      FLAG_GPGCHECK     = 4,
-      FLAG_KEEPPACKAGES = 8
-    };
-
     Impl()
-      : enabled (false),
-        autorefresh(false),
-        gpgcheck(true),
-       keeppackages(false),
-        type(repo::RepoType::NONE_e),
-        flags_determined(0)
+      : gpgcheck(indeterminate)
+      ,        keeppackages(indeterminate)
+      , type(repo::RepoType::NONE_e)
+      , emptybaseurls(false)
     {}
 
     ~Impl()
-    {
-      //MIL << std::endl;
-    }
+    {}
+
   public:
     static const unsigned defaultPriority = 99;
 
@@ -65,26 +65,104 @@ namespace zypp
     }
 
   public:
-    bool enabled;
-    bool autorefresh;
-    bool gpgcheck;
-    bool keeppackages;
+    Pathname licenseTgz() const
+    { return metadatapath.empty() ? Pathname() : metadatapath / path / "license.tar.gz"; }
+
+    Url getmirrorListUrl() const
+    { return replacer(mirrorlist_url); }
+
+    Url &setmirrorListUrl()
+    { return mirrorlist_url; }
+
+    const url_set & baseUrls() const
+    {
+      if ( _baseUrls.empty() && ! getmirrorListUrl().asString().empty() )
+      {
+        emptybaseurls = true;
+        DBG << "MetadataPath: " << metadatapath << endl;
+       const std::vector<Url> & rmurls( ( metadatapath.empty()
+                                        ? repo::RepoMirrorList( getmirrorListUrl() )
+                                        : repo::RepoMirrorList( getmirrorListUrl(), metadatapath ) ).getUrls() );
+        _baseUrls.insert( _baseUrls.end(), rmurls.begin(), rmurls.end() );
+      }
+      return _baseUrls;
+    }
+
+    url_set & baseUrls()
+    { return _baseUrls; }
+
+    bool baseurl2dump() const
+    { return !emptybaseurls && !_baseUrls.empty(); }
+
+
+    void addContent( const std::string & keyword_r )
+    { _keywords.insert( keyword_r ); }
+
+    bool hasContent( const std::string & keyword_r ) const
+    {
+      if ( _keywords.empty() && ! metadatapath.empty() )
+      {
+       // HACK directly check master index file until RepoManager offers
+       // some content probing ans zypepr uses it.
+       /////////////////////////////////////////////////////////////////
+       MIL << "Empty keywords...." << metadatapath << endl;
+       Pathname master;
+       if ( PathInfo( (master=metadatapath/"/repodata/repomd.xml") ).isFile() )
+       {
+         //MIL << "GO repomd.." << endl;
+         xml::Reader reader( master );
+         while ( reader.seekToNode( 2, "content" ) )
+         {
+           _keywords.insert( reader.nodeText().asString() );
+           reader.seekToEndNode( 2, "content" );
+         }
+         _keywords.insert( "" );       // valid content in _keywords even if empty
+       }
+       else if ( PathInfo( (master=metadatapath/"/content") ).isFile() )
+       {
+         //MIL << "GO content.." << endl;
+         iostr::forEachLine( InputStream( master ),
+                            [this]( int num_r, std::string line_r )->bool
+                            {
+                              if ( str::startsWith( line_r, "REPOKEYWORDS" ) )
+                             {
+                               std::vector<std::string> words;
+                               if ( str::split( line_r, std::back_inserter(words) ) > 1
+                                 && words[0].length() == 12 /*"REPOKEYWORDS"*/ )
+                               {
+                                 this->_keywords.insert( ++words.begin(), words.end() );
+                               }
+                               return true; // mult. occurrances are ok.
+                             }
+                             return( ! str::startsWith( line_r, "META " ) );   // no need to parse into META section.
+                           } );
+         _keywords.insert( "" );
+       }
+       /////////////////////////////////////////////////////////////////
+      }
+      return( _keywords.find( keyword_r ) != _keywords.end() );
+
+    }
+
+  public:
+    TriBool gpgcheck;
+    TriBool keeppackages;
     Url gpgkey_url;
     repo::RepoType type;
-    Url mirrorlist_url;
-    std::set<Url> baseUrls;
     Pathname path;
-    std::string alias;
-    std::string escaped_alias;
-    std::string name;
-    Pathname filepath;
+    std::string service;
+    std::string targetDistro;
     Pathname metadatapath;
     Pathname packagespath;
     DefaultIntegral<unsigned,defaultPriority> priority;
-    int flags_determined;
-  public:
+    mutable bool emptybaseurls;
+    repo::RepoVariablesUrlReplacer replacer;
 
   private:
+    Url mirrorlist_url;
+    mutable url_set _baseUrls;
+    mutable std::set<std::string> _keywords;
+
     friend Impl * rwcowClone<Impl>( const Impl * rhs );
     /** clone for RWCOW_pointer */
     Impl * clone() const
@@ -104,6 +182,8 @@ namespace zypp
   //
   ///////////////////////////////////////////////////////////////////
 
+  const RepoInfo RepoInfo::noRepo;
+
   ///////////////////////////////////////////////////////////////////
   //
   //   METHOD NAME : RepoInfo::RepoInfo
@@ -125,164 +205,66 @@ namespace zypp
 
   unsigned RepoInfo::priority() const
   { return _pimpl->priority; }
+
   unsigned RepoInfo::defaultPriority()
   { return Impl::defaultPriority; }
-  RepoInfo & RepoInfo::setPriority( unsigned newval_r )
-  {
-    _pimpl->priority = newval_r ? newval_r : Impl::defaultPriority;
-    return *this;
-  }
-
-
-  RepoInfo & RepoInfo::setEnabled( bool enabled )
-  {
-    _pimpl->enabled = enabled;
-    _pimpl->flags_determined |= Impl::FLAG_ENABLED;
-    return *this;
-  }
-
-  RepoInfo & RepoInfo::setAutorefresh( bool autorefresh )
-  {
-    _pimpl->autorefresh = autorefresh;
-    _pimpl->flags_determined |= Impl::FLAG_AUTOREFRESH;
-    return *this;
-  }
-
-  RepoInfo & RepoInfo::setGpgCheck( bool check )
-  {
-    _pimpl->gpgcheck = check;
-    _pimpl->flags_determined |= Impl::FLAG_GPGCHECK;
-    return *this;
-  }
 
-  RepoInfo & RepoInfo::setMirrorListUrl( const Url &url )
-  {
-    _pimpl->mirrorlist_url = url;
-    return *this;
-  }
+  void RepoInfo::setPriority( unsigned newval_r )
+  { _pimpl->priority = newval_r ? newval_r : Impl::defaultPriority; }
 
-  RepoInfo & RepoInfo::setGpgKeyUrl( const Url &url )
-  {
-    _pimpl->gpgkey_url = url;
-    return *this;
-  }
+  void RepoInfo::setGpgCheck( bool check )
+  { _pimpl->gpgcheck = check; }
 
-  RepoInfo & RepoInfo::addBaseUrl( const Url &url )
-  {
-    // set only if not already set externally (bnc #394728)
-    if (!(_pimpl->flags_determined & Impl::FLAG_KEEPPACKAGES) &&
-        _pimpl->baseUrls.empty())
-    {
-      if ( media::MediaAccess::downloads( url ) )
-        // don't do this via setKeepPackages, it would set the flags_determined
-        // for FLAG_KEEPPACKAGES  
-        _pimpl->keeppackages = true;
-      else
-        _pimpl->keeppackages = false;
-    }
+  void RepoInfo::setMirrorListUrl( const Url & url_r )
+  { _pimpl->setmirrorListUrl() = url_r; }
 
-    _pimpl->baseUrls.insert(url);
-    return *this;
-  }
+  void RepoInfo::setGpgKeyUrl( const Url & url_r )
+  { _pimpl->gpgkey_url = url_r; }
 
-  RepoInfo & RepoInfo::setBaseUrl( const Url &url )
+  void RepoInfo::addBaseUrl( const Url & url_r )
   {
-    _pimpl->baseUrls.clear();
-    addBaseUrl(url);
-    return *this;
+    for ( const auto & url : _pimpl->baseUrls() )      // unique!
+      if ( url == url_r )
+       return;
+    _pimpl->baseUrls().push_back( url_r );
   }
 
-  RepoInfo & RepoInfo::setPath( const Pathname &path )
+  void RepoInfo::setBaseUrl( const Url & url_r )
   {
-    _pimpl->path = path;
-    return *this;
+    _pimpl->baseUrls().clear();
+    _pimpl->baseUrls().push_back( url_r );
   }
 
-  RepoInfo & RepoInfo::setAlias( const std::string &alias )
-  {
-    _pimpl->alias = alias;
-    // replace slashes with underscores
-    std::string fnd="/";
-    std::string rep="_";
-    std::string escaped_alias = alias;
-    size_t pos = escaped_alias.find(fnd);
-    while(pos!=string::npos)
-    {
-      escaped_alias.replace(pos,fnd.length(),rep);
-      pos = escaped_alias.find(fnd,pos+rep.length());
-    }
-    _pimpl->escaped_alias = escaped_alias;
-    return *this;
-  }
+  void RepoInfo::setPath( const Pathname &path )
+  { _pimpl->path = path; }
 
-  RepoInfo & RepoInfo::setType( const repo::RepoType &t )
-  {
-    _pimpl->type = t;
-    return *this;
-  }
+  void RepoInfo::setType( const repo::RepoType &t )
+  { _pimpl->type = t; }
 
   void RepoInfo::setProbedType( const repo::RepoType &t ) const
   { _pimpl->setProbedType( t ); }
 
-  RepoInfo & RepoInfo::setName( const std::string &name )
-  {
-    _pimpl->name = name;
-    return *this;
-  }
-
-  RepoInfo & RepoInfo::setFilepath( const Pathname &filepath )
-  {
-    _pimpl->filepath = filepath;
-    return *this;
-  }
 
-  RepoInfo & RepoInfo::setMetadataPath( const Pathname &path )
-  {
-    _pimpl->metadatapath = path;
-    return *this;
-  }
+  void RepoInfo::setMetadataPath( const Pathname &path )
+  { _pimpl->metadatapath = path; }
 
-  RepoInfo & RepoInfo::setPackagesPath( const Pathname &path )
-  {
-    _pimpl->packagespath = path;
-    return *this;
-  }
+  void RepoInfo::setPackagesPath( const Pathname &path )
+  { _pimpl->packagespath = path; }
 
-  RepoInfo & RepoInfo::setKeepPackages( bool keep )
-  {
-    _pimpl->keeppackages = keep;
-    _pimpl->flags_determined |= Impl::FLAG_KEEPPACKAGES;
-    return *this;
-  }
+  void RepoInfo::setKeepPackages( bool keep )
+  { _pimpl->keeppackages = keep; }
 
-  bool RepoInfo::enabled() const
-  { return _pimpl->enabled; }
+  void RepoInfo::setService( const std::string& name )
+  { _pimpl->service = name; }
 
-  bool RepoInfo::autorefresh() const
-  { return _pimpl->autorefresh; }
+  void RepoInfo::setTargetDistribution( const std::string & targetDistribution )
+  { _pimpl->targetDistro = targetDistribution; }
 
   bool RepoInfo::gpgCheck() const
-  { return _pimpl->gpgcheck; }
+  { return indeterminate(_pimpl->gpgcheck) ? true : (bool)_pimpl->gpgcheck; }
 
-  std::string RepoInfo::alias() const
-  { return _pimpl->alias; }
-
-  std::string RepoInfo::escaped_alias() const
-  { return _pimpl->escaped_alias; }
-
-  std::string RepoInfo::name() const
-  {
-    if ( _pimpl->name.empty() )
-    {
-      return alias();
-    }
-
-    repo::RepoVariablesStringReplacer replacer;
-    return replacer(_pimpl->name);
-  }
-
-  Pathname RepoInfo::filepath() const
-  { return _pimpl->filepath; }
+  bool RepoInfo::keepPackages() const
+  { return indeterminate(_pimpl->keeppackages) ? false : (bool)_pimpl->keeppackages; }
 
   Pathname RepoInfo::metadataPath() const
   { return _pimpl->metadatapath; }
@@ -294,117 +276,274 @@ namespace zypp
   { return _pimpl->type; }
 
   Url RepoInfo::mirrorListUrl() const
-  { return _pimpl->mirrorlist_url; }
+  { return _pimpl->getmirrorListUrl(); }
 
   Url RepoInfo::gpgKeyUrl() const
   { return _pimpl->gpgkey_url; }
 
-  std::set<Url> RepoInfo::baseUrls() const
-  {
-    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;
-  }
+  RepoInfo::url_set RepoInfo::baseUrls() const
+  { return url_set( baseUrlsBegin(), baseUrlsEnd() ); }        // Variables replaced!
 
   Pathname RepoInfo::path() const
   { return _pimpl->path; }
 
+  std::string RepoInfo::service() const
+  { return _pimpl->service; }
+
+  std::string RepoInfo::targetDistribution() const
+  { return _pimpl->targetDistro; }
+
   RepoInfo::urls_const_iterator RepoInfo::baseUrlsBegin() const
   {
-    return make_transform_iterator( _pimpl->baseUrls.begin(),
-                                    repo::RepoVariablesUrlReplacer() );
-    //return _pimpl->baseUrls.begin();
+    return make_transform_iterator( _pimpl->baseUrls().begin(),
+                                    _pimpl->replacer );
   }
 
   RepoInfo::urls_const_iterator RepoInfo::baseUrlsEnd() const
   {
-    //return _pimpl->baseUrls.end();
-    return make_transform_iterator( _pimpl->baseUrls.end(),
-                                    repo::RepoVariablesUrlReplacer() );
+    return make_transform_iterator( _pimpl->baseUrls().end(),
+                                    _pimpl->replacer );
   }
 
   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(); }
 
-  bool RepoInfo::keepPackages() const
-  { return _pimpl->keeppackages; }
+  bool RepoInfo::baseUrlSet() const
+  { return _pimpl->baseurl2dump(); }
+
+
+  void RepoInfo::addContent( const std::string & keyword_r )
+  { _pimpl->addContent( keyword_r ); }
+
+  bool RepoInfo::hasContent( const std::string & keyword_r ) const
+  { return _pimpl->hasContent( keyword_r ); }
+
+  ///////////////////////////////////////////////////////////////////
+
+  bool RepoInfo::hasLicense() const
+  {
+    Pathname licenseTgz( _pimpl->licenseTgz() );
+    return ! licenseTgz.empty() &&  PathInfo(licenseTgz).isFile();
+  }
+
+  bool RepoInfo::needToAcceptLicense() const
+  {
+    static const std::string noAcceptanceFile = "no-acceptance-needed\n";
+    bool accept = true;
+
+    Pathname licenseTgz( _pimpl->licenseTgz() );
+    if ( licenseTgz.empty() || ! PathInfo( licenseTgz ).isFile() )
+      return false;     // no licenses at all
+
+    ExternalProgram::Arguments cmd;
+    cmd.push_back( "tar" );
+    cmd.push_back( "-t" );
+    cmd.push_back( "-z" );
+    cmd.push_back( "-f" );
+    cmd.push_back( licenseTgz.asString() );
+
+    ExternalProgram prog( cmd, ExternalProgram::Stderr_To_Stdout );
+    for ( std::string output( prog.receiveLine() ); output.length(); output = prog.receiveLine() )
+    {
+      if ( output == noAcceptanceFile )
+      {
+        accept = false;
+      }
+    }
+    MIL << "License for " << this->name() << " has to be accepted: " << (accept?"true":"false" ) << endl;
+    return accept;
+  }
+
+  std::string RepoInfo::getLicense( const Locale & lang_r )
+  {
+    LocaleSet avlocales( getLicenseLocales() );
+    if ( avlocales.empty() )
+      return std::string();
+
+    Locale getLang( Locale::bestMatch( avlocales, lang_r ) );
+    if ( getLang == Locale::noCode
+         && avlocales.find( Locale::noCode ) == avlocales.end() )
+    {
+      WAR << "License.tar.gz contains no fallback text! " << *this << endl;
+      // Using the fist locale instead of returning no text at all.
+      // So the user might recognize that there is a license, even if he
+      // can't read it.
+      getLang = *avlocales.begin();
+    }
+
+    // now extract the license file.
+    static const std::string licenseFileFallback( "license.txt" );
+    std::string licenseFile( getLang == Locale::noCode
+                             ? licenseFileFallback
+                             : str::form( "license.%s.txt", getLang.code().c_str() ) );
+
+    ExternalProgram::Arguments cmd;
+    cmd.push_back( "tar" );
+    cmd.push_back( "-x" );
+    cmd.push_back( "-z" );
+    cmd.push_back( "-O" );
+    cmd.push_back( "-f" );
+    cmd.push_back( _pimpl->licenseTgz().asString() ); // if it not exists, avlocales was empty.
+    cmd.push_back( licenseFile );
+
+    std::string ret;
+    ExternalProgram prog( cmd, ExternalProgram::Discard_Stderr );
+    for ( std::string output( prog.receiveLine() ); output.length(); output = prog.receiveLine() )
+    {
+      ret += output;
+    }
+    prog.close();
+    return ret;
+  }
+
+  LocaleSet RepoInfo::getLicenseLocales() const
+  {
+    Pathname licenseTgz( _pimpl->licenseTgz() );
+    if ( licenseTgz.empty() || ! PathInfo( licenseTgz ).isFile() )
+      return LocaleSet();
+
+    ExternalProgram::Arguments cmd;
+    cmd.push_back( "tar" );
+    cmd.push_back( "-t" );
+    cmd.push_back( "-z" );
+    cmd.push_back( "-f" );
+    cmd.push_back( licenseTgz.asString() );
+
+    LocaleSet ret;
+    ExternalProgram prog( cmd, ExternalProgram::Stderr_To_Stdout );
+    for ( std::string output( prog.receiveLine() ); output.length(); output = prog.receiveLine() )
+    {
+      static const C_Str license( "license." );
+      static const C_Str dotTxt( ".txt\n" );
+      if ( str::hasPrefix( output, license ) && str::hasSuffix( output, dotTxt ) )
+      {
+        if ( output.size() <= license.size() +  dotTxt.size() ) // license.txt
+          ret.insert( Locale() );
+        else
+          ret.insert( Locale( std::string( output.c_str()+license.size(), output.size()- license.size() - dotTxt.size() ) ) );
+      }
+    }
+    prog.close();
+    return ret;
+  }
+
+  ///////////////////////////////////////////////////////////////////
 
   std::ostream & RepoInfo::dumpOn( std::ostream & str ) const
   {
-    str << "--------------------------------------" << std::endl;
-    str << "- alias       : " << alias() << std::endl;
-    for ( urls_const_iterator it = baseUrlsBegin();
-          it != baseUrlsEnd();
-          ++it )
+    RepoInfoBase::dumpOn(str);
+    if ( _pimpl->baseurl2dump() )
     {
-      str << "- url         : " << *it << std::endl;
+      for ( const auto & url : _pimpl->baseUrls() )
+      {
+        str << "- url         : " << url << std::endl;
+      }
     }
-    str << "- path        : " << path() << std::endl;
+
+    // print if non empty value
+    auto strif( [&] ( const std::string & tag_r, const std::string & value_r ) {
+      if ( ! value_r.empty() )
+       str << tag_r << value_r << std::endl;
+    });
+
+    strif( "- mirrorlist  : ", _pimpl->getmirrorListUrl().asString() );
+    strif( "- path        : ", path().asString() );
     str << "- type        : " << type() << std::endl;
-    str << "- enabled     : " << enabled() << std::endl;
     str << "- priority    : " << priority() << std::endl;
-
-    str << "- autorefresh : " << autorefresh() << std::endl;
     str << "- gpgcheck    : " << gpgCheck() << std::endl;
-    str << "- gpgkey      : " << gpgKeyUrl() << std::endl;
-    str << "- keeppackages: " << keepPackages() << std::endl;
+    strif( "- gpgkey      : ", gpgKeyUrl().asString() );
+
+    if ( ! indeterminate(_pimpl->keeppackages) )
+      str << "- keeppackages: " << keepPackages() << std::endl;
+
+    strif( "- service     : ", service() );
+    strif( "- targetdistro: ", targetDistribution() );
+    strif( "- metadataPath: ", metadataPath().asString() );
+    strif( "- packagesPath: ", packagesPath().asString() );
 
     return str;
   }
 
-  std::ostream & RepoInfo::dumpRepoOn( std::ostream & str ) const
+  std::ostream & RepoInfo::dumpAsIniOn( std::ostream & str ) const
   {
-    // we save the original data without variable replacement
-    str << "[" << alias() << "]" << endl;
-    str << "name=" << _pimpl->name << 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=";
+      std::string indent;
+      for ( const auto & url : _pimpl->baseUrls() )
+      {
+        str << indent << url << endl;
+       if ( indent.empty() ) indent = "        ";      // "baseurl="
+      }
     }
 
     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 << "enabled=" << (enabled() ? "1" : "0") << endl;
 
     if ( priority() != defaultPriority() )
       str << "priority=" << priority() << endl;
 
-    str << "autorefresh=" << (autorefresh() ? "1" : "0") << endl;
-    str << "gpgcheck=" << (gpgCheck() ? "1" : "0") << endl;
+    if (!indeterminate(_pimpl->gpgcheck))
+      str << "gpgcheck=" << (gpgCheck() ? "1" : "0") << endl;
     if ( ! (gpgKeyUrl().asString().empty()) )
       str << "gpgkey=" <<gpgKeyUrl() << endl;
 
-    str << "keeppackages=" << keepPackages() << endl;
+    if (!indeterminate(_pimpl->keeppackages))
+      str << "keeppackages=" << keepPackages() << endl;
+
+    if( ! service().empty() )
+      str << "service=" << service() << endl;
 
     return str;
   }
 
+  std::ostream & RepoInfo::dumpAsXmlOn( std::ostream & str, const std::string & content ) const
+  {
+    std::string tmpstr;
+    str
+      << "<repo"
+      << " alias=\"" << escape(alias()) << "\""
+      << " name=\"" << escape(name()) << "\"";
+    if (type() != repo::RepoType::NONE)
+      str << " type=\"" << type().asString() << "\"";
+    str
+      << " priority=\"" << priority() << "\""
+      << " enabled=\"" << enabled() << "\""
+      << " autorefresh=\"" << autorefresh() << "\""
+      << " gpgcheck=\"" << gpgCheck() << "\"";
+    if (!(tmpstr = gpgKeyUrl().asString()).empty())
+      str << " gpgkey=\"" << escape(tmpstr) << "\"";
+    if (!(tmpstr = mirrorListUrl().asString()).empty())
+      str << " mirrorlist=\"" << escape(tmpstr) << "\"";
+    str << ">" << endl;
+
+    if ( _pimpl->baseurl2dump() )
+    {
+      for (  const auto & url : _pimpl->baseUrls() )
+       str << "<url>" << escape(url.asString()) << "</url>" << endl;
+    }
+
+    str << "</repo>" << endl;
+    return str;
+  }
+
+
   std::ostream & operator<<( std::ostream & str, const RepoInfo & obj )
   {
     return obj.dumpOn(str);
   }
 
+
   /////////////////////////////////////////////////////////////////
 } // namespace zypp
 ///////////////////////////////////////////////////////////////////