Imported Upstream version 14.45.0
[platform/upstream/libzypp.git] / zypp / RepoInfo.cc
index a91e9f5..679a432 100644 (file)
@@ -48,7 +48,6 @@ namespace zypp
       , _pkgGpgCheck( indeterminate )
       , _validRepoSignature( indeterminate )
       ,        keeppackages(indeterminate)
-      , _mirrorListForceMetalink(false)
       , type(repo::RepoType::NONE_e)
       , emptybaseurls(false)
     {}
@@ -58,7 +57,6 @@ namespace zypp
 
   public:
     static const unsigned defaultPriority = 99;
-    static const unsigned noPriority = unsigned(-1);
 
     void setProbedType( const repo::RepoType & t ) const
     {
@@ -81,7 +79,7 @@ namespace zypp
       {
         emptybaseurls = true;
         DBG << "MetadataPath: " << metadatapath << endl;
-       repo::RepoMirrorList rmurls( mlurl, metadatapath, _mirrorListForceMetalink );
+       repo::RepoMirrorList rmurls( mlurl, metadatapath );
        _baseUrls.raw().insert( _baseUrls.raw().end(), rmurls.getUrls().begin(), rmurls.getUrls().end() );
       }
       return _baseUrls;
@@ -100,19 +98,15 @@ namespace zypp
     RepoVariablesReplacedUrlList & gpgKeyUrls()
     { return _gpgKeyUrls; }
 
-
-    const std::set<std::string> & contentKeywords() const
-    { hasContent()/*init if not yet done*/; return _keywords.second; }
-
     void addContent( const std::string & keyword_r )
-    { _keywords.second.insert( keyword_r ); if ( ! hasContent() ) _keywords.first = true; }
+    { _keywords.insert( keyword_r ); }
 
-    bool hasContent() const
+    bool hasContent( const std::string & keyword_r ) const
     {
-      if ( !_keywords.first && ! metadatapath.empty() )
+      if ( _keywords.empty() && ! metadatapath.empty() )
       {
        // HACK directly check master index file until RepoManager offers
-       // some content probing and zypper uses it.
+       // some content probing ans zypepr uses it.
        /////////////////////////////////////////////////////////////////
        MIL << "Empty keywords...." << metadatapath << endl;
        Pathname master;
@@ -122,10 +116,10 @@ namespace zypp
          xml::Reader reader( master );
          while ( reader.seekToNode( 2, "content" ) )
          {
-           _keywords.second.insert( reader.nodeText().asString() );
+           _keywords.insert( reader.nodeText().asString() );
            reader.seekToEndNode( 2, "content" );
          }
-         _keywords.first = true;       // valid content in _keywords even if empty
+         _keywords.insert( "" );       // valid content in _keywords even if empty
        }
        else if ( PathInfo( (master=metadatapath/"/content") ).isFile() )
        {
@@ -139,22 +133,19 @@ namespace zypp
                                if ( str::split( line_r, std::back_inserter(words) ) > 1
                                  && words[0].length() == 12 /*"REPOKEYWORDS"*/ )
                                {
-                                 this->_keywords.second.insert( ++words.begin(), words.end() );
+                                 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.first = true;       // valid content in _keywords even if empty
+         _keywords.insert( "" );
        }
        /////////////////////////////////////////////////////////////////
       }
-      return _keywords.first;
+      return( _keywords.find( keyword_r ) != _keywords.end() );
     }
 
-    bool hasContent( const std::string & keyword_r ) const
-    { return( hasContent() && _keywords.second.find( keyword_r ) != _keywords.second.end() ); }
-
     /** Signature check result needs to be stored/retrieved from _metadatapath.
      * Don't call them from outside validRepoSignature/setValidRepoSignature
      */
@@ -222,7 +213,6 @@ namespace zypp
   public:
     TriBool keeppackages;
     RepoVariablesReplacedUrl _mirrorListUrl;
-    bool                     _mirrorListForceMetalink;
     repo::RepoType type;
     Pathname path;
     std::string service;
@@ -235,7 +225,7 @@ namespace zypp
 
   private:
     mutable RepoVariablesReplacedUrlList _baseUrls;
-    mutable std::pair<FalseBool, std::set<std::string> > _keywords;
+    mutable std::set<std::string> _keywords;
 
     RepoVariablesReplacedUrlList _gpgKeyUrls;
 
@@ -273,9 +263,6 @@ namespace zypp
   unsigned RepoInfo::defaultPriority()
   { return Impl::defaultPriority; }
 
-  unsigned RepoInfo::noPriority()
-  { return Impl::noPriority; }
-
   void RepoInfo::setPriority( unsigned newval_r )
   { _pimpl->priority = newval_r ? newval_r : Impl::defaultPriority; }
 
@@ -333,10 +320,7 @@ namespace zypp
 
 
   void RepoInfo::setMirrorListUrl( const Url & url_r ) // Raw
-  { _pimpl->_mirrorListUrl.raw() = url_r; _pimpl->_mirrorListForceMetalink = false; }
-
-  void  RepoInfo::setMetalinkUrl( const Url & url_r )  // Raw
-  { _pimpl->_mirrorListUrl.raw() = url_r; _pimpl->_mirrorListForceMetalink = true; }
+  { _pimpl->_mirrorListUrl.raw() = url_r; }
 
   void RepoInfo::setGpgKeyUrls( url_set urls )
   { _pimpl->gpgKeyUrls().raw().swap( urls ); }
@@ -458,15 +442,10 @@ namespace zypp
   bool RepoInfo::baseUrlSet() const
   { return _pimpl->baseurl2dump(); }
 
-  const std::set<std::string> & RepoInfo::contentKeywords() const
-  { return _pimpl->contentKeywords(); }
 
   void RepoInfo::addContent( const std::string & keyword_r )
   { _pimpl->addContent( keyword_r ); }
 
-  bool RepoInfo::hasContent() const
-  { return _pimpl->hasContent(); }
-
   bool RepoInfo::hasContent( const std::string & keyword_r ) const
   { return _pimpl->hasContent( keyword_r ); }
 
@@ -516,7 +495,8 @@ namespace zypp
       return std::string();
 
     Locale getLang( Locale::bestMatch( avlocales, lang_r ) );
-    if ( !getLang && avlocales.find( Locale::noCode ) == avlocales.end() )
+    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.
@@ -527,8 +507,9 @@ namespace zypp
 
     // now extract the license file.
     static const std::string licenseFileFallback( "license.txt" );
-    std::string licenseFile( !getLang ? licenseFileFallback
-                                     : str::form( "license.%s.txt", getLang.c_str() ) );
+    std::string licenseFile( getLang == Locale::noCode
+                             ? licenseFileFallback
+                             : str::form( "license.%s.txt", getLang.code().c_str() ) );
 
     ExternalProgram::Arguments cmd;
     cmd.push_back( "tar" );
@@ -599,7 +580,7 @@ namespace zypp
        str << tag_r << value_r << std::endl;
     });
 
-    strif( (_pimpl->_mirrorListForceMetalink ? "- metalink    : " : "- mirrorlist  : "), rawMirrorListUrl().asString() );
+    strif( "- mirrorlist  : ", rawMirrorListUrl().asString() );
     strif( "- path        : ", path().asString() );
     str << "- type        : " << type() << std::endl;
     str << "- priority    : " << priority() << std::endl;
@@ -648,7 +629,7 @@ namespace zypp
       str << "path="<< path() << endl;
 
     if ( ! (rawMirrorListUrl().asString().empty()) )
-      str << (_pimpl->_mirrorListForceMetalink ? "metalink=" : "mirrorlist=") << rawMirrorListUrl() << endl;
+      str << "mirrorlist=" << rawMirrorListUrl() << endl;
 
     str << "type=" << type().asString() << endl;
 
@@ -702,7 +683,7 @@ namespace zypp
     if (!(tmpstr = gpgKeyUrl().asString()).empty())
       str << " gpgkey=\"" << escape(tmpstr) << "\"";
     if (!(tmpstr = mirrorListUrl().asString()).empty())
-      str << (_pimpl->_mirrorListForceMetalink ? " metalink=\"" : " mirrorlist=\"") << escape(tmpstr) << "\"";
+      str << " mirrorlist=\"" << escape(tmpstr) << "\"";
     str << ">" << endl;
 
     if ( _pimpl->baseurl2dump() )