Imported Upstream version 15.23.0 06/94706/1
authorDongHun Kwak <dh0128.kwak@samsung.com>
Tue, 1 Nov 2016 02:10:54 +0000 (11:10 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Tue, 1 Nov 2016 02:10:55 +0000 (11:10 +0900)
Change-Id: Id7fdf66eb9ac20d9c0baa98337426f5858ad59c9
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
VERSION.cmake
package/libzypp.changes
tests/parser/RepoFileReader_test.cc
zypp/RepoInfo.cc
zypp/RepoInfo.h
zypp/RepoManager.cc
zypp/parser/RepoFileReader.cc

index 6c19dc9..b313b5a 100644 (file)
@@ -60,9 +60,9 @@
 #
 SET(LIBZYPP_MAJOR "15")
 SET(LIBZYPP_COMPATMINOR "19")
-SET(LIBZYPP_MINOR "22")
-SET(LIBZYPP_PATCH "5")
+SET(LIBZYPP_MINOR "23")
+SET(LIBZYPP_PATCH "0")
 #
-# LAST RELEASED: 15.22.5 (19)
+# LAST RELEASED: 15.23.0 (19)
 # (The number in parenthesis is LIBZYPP_COMPATMINOR)
 #=======
index 88f4bc1..3cb9e9a 100644 (file)
@@ -1,4 +1,10 @@
 -------------------------------------------------------------------
+Tue Oct 11 12:33:49 CEST 2016 - ma@suse.de
+
+- RepoInfo: Allow parsing multiple gpgkey= URLs (bsc#1003748)
+- version 15.23.0 (19)
+
+-------------------------------------------------------------------
 Fri Sep 16 12:57:51 CEST 2016 - ma@suse.de
 
 - guessPackageSpec: Don't break globbing (fixes openSUSE/zypper#97)
index feed8df..28d7d5c 100644 (file)
@@ -23,12 +23,15 @@ static string suse_repo = "[factory-oss]\n"
 static string fedora_repo = "[fedora]\n"
 "name=Fedora $releasever - $basearch\n"
 "failovermethod=priority\n"
-"#baseurl=http://download.fedora.redhat.com/pub/fedora/linux/releases/$releasever/Everything/$basearch/os/\n"
-"#mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-$releasever&arch=$basearch\n"
+"baseurl=http://download.fedora.redhat.com/pub/fedora/linux/releases/$releasever/Everything/$basearch/os/\n"
+"        http://download.fedora.redhat.com/pub/fedora/linux/releases/$releasever/Everything/$basearch/os2/\n"
+"mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-$releasever&arch=$basearch\n"
 "mirrorlist=file:///etc/yum.repos.d/local.mirror\n"
 "enabled=1\n"
 "gpgcheck=1\n"
-"gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora file:///etc/pki/rpm-gpg/RPM-GPG-KEY\n";
+"gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora file:///etc/pki/rpm-gpg/RPM-GPG-KEY-$releasever/\n"
+"gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-3\n"
+"file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-4\n";
 
 struct RepoCollector : private base::NonCopyable
 {
@@ -52,7 +55,7 @@ BOOST_AUTO_TEST_CASE(read_repo_file)
 
     const RepoInfo & repo( collector.repos.front() );
     BOOST_CHECK_EQUAL( 4, repo.baseUrlsSize() );
-    cout << repo << endl;
+    // cout << repo << endl;
   }
   // fedora
   {
@@ -64,6 +67,14 @@ BOOST_AUTO_TEST_CASE(read_repo_file)
     RepoInfo repo = *collector.repos.begin();
     // should have taken the first url if more are present
     BOOST_CHECK_EQUAL(Url("file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora"), repo.gpgKeyUrl());
+    BOOST_CHECK_EQUAL( 4, repo.gpgKeyUrlsSize() );
+    // cout << repo << endl;
+    // cout << "------------------------------------------------------------" << endl;
+    // repo.dumpOn( cout ) << endl;
+    // cout << "------------------------------------------------------------" << endl;
+    // repo.dumpAsIniOn( cout ) << endl;
+    // cout << "------------------------------------------------------------" << endl;
+    // repo.dumpAsXmlOn( cout ) << endl;
   }
 
 }
index 6ac2015..a91e9f5 100644 (file)
@@ -94,6 +94,13 @@ namespace zypp
     { return !emptybaseurls && !_baseUrls.empty(); }
 
 
+    const RepoVariablesReplacedUrlList & gpgKeyUrls() const
+    { return _gpgKeyUrls; }
+
+    RepoVariablesReplacedUrlList & gpgKeyUrls()
+    { return _gpgKeyUrls; }
+
+
     const std::set<std::string> & contentKeywords() const
     { hasContent()/*init if not yet done*/; return _keywords.second; }
 
@@ -214,7 +221,6 @@ namespace zypp
     TriBool _validRepoSignature;///< have  signed and valid repo metadata
   public:
     TriBool keeppackages;
-    RepoVariablesReplacedUrl _gpgKeyUrl;
     RepoVariablesReplacedUrl _mirrorListUrl;
     bool                     _mirrorListForceMetalink;
     repo::RepoType type;
@@ -231,6 +237,8 @@ namespace zypp
     mutable RepoVariablesReplacedUrlList _baseUrls;
     mutable std::pair<FalseBool, std::set<std::string> > _keywords;
 
+    RepoVariablesReplacedUrlList _gpgKeyUrls;
+
     friend Impl * rwcowClone<Impl>( const Impl * rhs );
     /** clone for RWCOW_pointer */
     Impl * clone() const
@@ -330,8 +338,14 @@ namespace zypp
   void  RepoInfo::setMetalinkUrl( const Url & url_r )  // Raw
   { _pimpl->_mirrorListUrl.raw() = url_r; _pimpl->_mirrorListForceMetalink = true; }
 
+  void RepoInfo::setGpgKeyUrls( url_set urls )
+  { _pimpl->gpgKeyUrls().raw().swap( urls ); }
+
   void RepoInfo::setGpgKeyUrl( const Url & url_r )
-  { _pimpl->_gpgKeyUrl.raw() = url_r; }
+  {
+    _pimpl->gpgKeyUrls().raw().clear();
+    _pimpl->gpgKeyUrls().raw().push_back( url_r );
+  }
 
   void RepoInfo::addBaseUrl( const Url & url_r )
   {
@@ -393,11 +407,23 @@ namespace zypp
   Url RepoInfo::rawMirrorListUrl() const               // Raw
   { return _pimpl->_mirrorListUrl.raw(); }
 
+  bool RepoInfo::gpgKeyUrlsEmpty() const
+  { return _pimpl->gpgKeyUrls().empty(); }
+
+  RepoInfo::urls_size_type RepoInfo::gpgKeyUrlsSize() const
+  { return _pimpl->gpgKeyUrls().size(); }
+
+  RepoInfo::url_set RepoInfo::gpgKeyUrls() const       // Variables replaced!
+  { return _pimpl->gpgKeyUrls().transformed(); }
+
+  RepoInfo::url_set RepoInfo::rawGpgKeyUrls() const    // Raw
+  { return _pimpl->gpgKeyUrls().raw(); }
+
   Url RepoInfo::gpgKeyUrl() const                      // Variables replaced!
-  { return _pimpl->_gpgKeyUrl.transformed(); }
+  { return( _pimpl->gpgKeyUrls().empty() ? Url() : *_pimpl->gpgKeyUrls().transformedBegin() ); }
 
   Url RepoInfo::rawGpgKeyUrl() const                   // Raw
-  {  return _pimpl->_gpgKeyUrl.raw(); }
+  { return( _pimpl->gpgKeyUrls().empty() ? Url() : *_pimpl->gpgKeyUrls().rawBegin() ) ; }
 
   RepoInfo::url_set RepoInfo::baseUrls() const         // Variables replaced!
   { return _pimpl->baseUrls().transformed(); }
@@ -587,7 +613,10 @@ namespace zypp
                              << std::endl;
 #undef OUTS
 
-    strif( "- gpgkey      : ", rawGpgKeyUrl().asString() );
+    for ( const auto & url : _pimpl->gpgKeyUrls().raw() )
+    {
+      str << "- gpgkey      : " << url << std::endl;
+    }
 
     if ( ! indeterminate(_pimpl->keeppackages) )
       str << "- keeppackages: " << keepPackages() << std::endl;
@@ -635,8 +664,15 @@ namespace zypp
     if ( ! indeterminate(_pimpl->_pkgGpgCheck) )
       str << "pkg_gpgcheck=" << (_pimpl->_pkgGpgCheck ? "1" : "0") << endl;
 
-    if ( ! (rawGpgKeyUrl().asString().empty()) )
-      str << "gpgkey=" << rawGpgKeyUrl() << endl;
+    {
+      std::string indent( "gpgkey=");
+      for ( const auto & url : _pimpl->gpgKeyUrls().raw() )
+      {
+       str << indent << url << endl;
+       if ( indent[0] != ' ' )
+         indent = "       ";
+      }
+    }
 
     if (!indeterminate(_pimpl->keeppackages))
       str << "keeppackages=" << keepPackages() << endl;
index 075df3c..70a47e3 100644 (file)
@@ -290,31 +290,27 @@ namespace zypp
       /** Set the value for \ref validRepoSignature (or \c indeterminate if unsigned). */
       void setValidRepoSignature( TriBool value_r );
 
-      /**
-       * \short Key to use for gpg checking of this repository
-       *
-       * \param url Url to the key in ASCII armored format
-       *
-       * \note This is a just a hint to the application and can
-       * be ignored.
-       *
-       */
+
+      /** Whether gpgkey URLs are defined */
+      bool gpgKeyUrlsEmpty() const;
+      /** Number of gpgkey URLs defined */
+      urls_size_type gpgKeyUrlsSize() const;
+
+      /** The list of gpgkey URLs defined for this repo */
+      url_set gpgKeyUrls() const;
+      /** The list of raw gpgkey URLs defined for this repo (no variables replaced) */
+      url_set rawGpgKeyUrls() const;
+      /** Set a list of gpgkey URLs defined for this repo */
+      void setGpgKeyUrls( url_set urls );
+
+      /** (leagcy API) The 1st gpgkey URL defined for this repo */
       Url gpgKeyUrl() const;
-      /**
-       * The raw gpgKeyUrl (no variables replaced).
-       */
+      /** (leagcy API) The 1st raw gpgkey URL defined for this repo (no variables replaced) */
       Url rawGpgKeyUrl() const;
-      /**
-       * \short Key to use for gpg checking of this repository
-       *
-       * \param url Url to the key in ASCII armored format
-       *
-       * \note This is a just a hint to the application and can
-       * be ignored.
-       *
-       */
+      /** (leagcy API) Set the gpgkey URL defined for this repo */
       void setGpgKeyUrl( const Url &gpgkey );
 
+
       /**
        * \short Whether packages downloaded from this repository will be kept in local cache
        */
index 8c455c9..6747c67 100644 (file)
@@ -1201,6 +1201,9 @@ namespace zypp
         // cause of the problem of the first URL remembered
         if (it == info.baseUrlsBegin())
           rexception.remember(e);
+       else
+         rexception.addHistory(  e.asUserString() );
+
       }
     } // for every url
     ERR << "No more urls..." << endl;
index ff0309c..5c4db23 100644 (file)
@@ -46,33 +46,64 @@ namespace zypp
        {
          if ( key_r == "baseurl" )
          {
-           setInBaseurls( true );
+           _inMultiline = MultiLine::baseurl;
            _baseurls[section_r].push_back( Url(value_r) );
          }
+         else if ( key_r == "gpgkey" )
+         {
+           _inMultiline = MultiLine::gpgkey;
+           legacyStoreUrl( _gpgkeys[section_r], value_r );
+         }
          else
          {
-           setInBaseurls( false );
+           _inMultiline = MultiLine::none;
            IniDict::consume( section_r, key_r, value_r );
          }
        }
 
        virtual void garbageLine( const std::string & section_r, const std::string & line_r )
        {
-         if ( _inBaseurls )
-           _baseurls[section_r].push_back( Url(line_r) );
-         else
-           IniDict::garbageLine( section_r, line_r );  // throw
+         switch ( _inMultiline )
+         {
+           case MultiLine::baseurl:
+             _baseurls[section_r].push_back( Url(line_r) );
+             break;
+
+           case MultiLine::gpgkey:
+             legacyStoreUrl( _gpgkeys[section_r], line_r );
+             break;
+
+           case MultiLine::none:
+             IniDict::garbageLine( section_r, line_r );        // throw
+             break;
+         }
        }
 
        std::list<Url> & baseurls( const std::string & section_r )
        { return _baseurls[section_r]; }
 
+       std::list<Url> & gpgkeys( const std::string & section_r )
+       { return _gpgkeys[section_r]; }
+
       private:
-       void setInBaseurls( bool yesno_r )
-       { if ( _inBaseurls != yesno_r ) _inBaseurls = yesno_r; }
+       void legacyStoreUrl( std::list<Url> & store_r, const std::string & line_r )
+       {
+         // Legacy:
+         //    commit 4ef65a442038caf7a1e310bc719e329b34dbdb67
+         //    - split the gpgkey line and take the first one as url to avoid
+         //      crash when creating an url from the line, as Fedora hat the
+         //      *BRILLIANT* idea of using more than one url per line.
+         std::vector<std::string> keys;
+         str::split( line_r, std::back_inserter(keys) );
+         for ( auto && str : keys )
+           store_r.push_back( Url(std::move(str)) );
+       }
+
+       enum class MultiLine { none, baseurl, gpgkey };
+       MultiLine _inMultiline = MultiLine::none;
 
-       DefaultIntegral<bool,false> _inBaseurls;
        std::map<std::string,std::list<Url>> _baseurls;
+       std::map<std::string,std::list<Url>> _gpgkeys;
       };
 
     } //namespace
@@ -113,13 +144,6 @@ namespace zypp
             info.setMirrorListUrl(Url(it->second));
          else if ( it->first == "metalink" && !it->second.empty())
            info.setMetalinkUrl(Url(it->second));
-          else if ( it->first == "gpgkey" && !it->second.empty())
-          {
-            std::vector<std::string> keys;
-            str::split( it->second, std::back_inserter(keys) );
-            if ( ! keys.empty() )
-              info.setGpgKeyUrl( Url(*keys.begin()) );
-          }
           else if ( it->first == "gpgcheck" )
             info.setGpgCheck( str::strToTriBool( it->second ) );
           else if ( it->first == "repo_gpgcheck" )
@@ -161,6 +185,8 @@ namespace zypp
          info.addBaseUrl( url );
        }
 
+       info.setGpgKeyUrls( std::move(dict.gpgkeys( *its )) );
+
         info.setFilepath(is.path());
         MIL << info << endl;
         // add it to the list.