Imported Upstream version 14.44.0 54/94654/1
authorDongHun Kwak <dh0128.kwak@samsung.com>
Tue, 1 Nov 2016 01:39:58 +0000 (10:39 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Tue, 1 Nov 2016 01:39:59 +0000 (10:39 +0900)
Change-Id: If6a900323efccdf871aeb944073681b60a614737
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 fe80259..a4c5475 100644 (file)
@@ -60,9 +60,9 @@
 #
 SET(LIBZYPP_MAJOR "14")
 SET(LIBZYPP_COMPATMINOR "39")
-SET(LIBZYPP_MINOR "43")
-SET(LIBZYPP_PATCH "4")
+SET(LIBZYPP_MINOR "44")
+SET(LIBZYPP_PATCH "0")
 #
-# LAST RELEASED: 14.43.4 (39)
+# LAST RELEASED: 14.44.0 (39)
 # (The number in parenthesis is LIBZYPP_COMPATMINOR)
 #=======
index f7fbcfa..c29d55a 100644 (file)
@@ -1,4 +1,10 @@
 -------------------------------------------------------------------
+Tue Oct 11 12:32:32 CEST 2016 - ma@suse.de
+
+- RepoInfo: Allow parsing multiple gpgkey= URLs (bsc#1003748)
+- version 14.44.0 (39)
+
+-------------------------------------------------------------------
 Fri Sep 16 12:58:46 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 e81c584..679a432 100644 (file)
@@ -92,6 +92,12 @@ namespace zypp
     { return !emptybaseurls && !_baseUrls.empty(); }
 
 
+    const RepoVariablesReplacedUrlList & gpgKeyUrls() const
+    { return _gpgKeyUrls; }
+
+    RepoVariablesReplacedUrlList & gpgKeyUrls()
+    { return _gpgKeyUrls; }
+
     void addContent( const std::string & keyword_r )
     { _keywords.insert( keyword_r ); }
 
@@ -206,7 +212,6 @@ namespace zypp
     TriBool _validRepoSignature;///< have  signed and valid repo metadata
   public:
     TriBool keeppackages;
-    RepoVariablesReplacedUrl _gpgKeyUrl;
     RepoVariablesReplacedUrl _mirrorListUrl;
     repo::RepoType type;
     Pathname path;
@@ -222,6 +227,8 @@ namespace zypp
     mutable RepoVariablesReplacedUrlList _baseUrls;
     mutable std::set<std::string> _keywords;
 
+    RepoVariablesReplacedUrlList _gpgKeyUrls;
+
     friend Impl * rwcowClone<Impl>( const Impl * rhs );
     /** clone for RWCOW_pointer */
     Impl * clone() const
@@ -315,8 +322,14 @@ namespace zypp
   void RepoInfo::setMirrorListUrl( const Url & url_r ) // Raw
   { _pimpl->_mirrorListUrl.raw() = url_r; }
 
+  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 )
   {
@@ -378,11 +391,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(); }
@@ -569,7 +594,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;
@@ -617,8 +645,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 616bf60..7ddcc7c 100644 (file)
@@ -282,31 +282,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 438df5e..f8e7f9a 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 dee8c02..25ededf 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
@@ -111,13 +142,6 @@ namespace zypp
             info.setAutorefresh( str::strToTrue( it->second ) );
           else if ( it->first == "mirrorlist" && !it->second.empty())
             info.setMirrorListUrl(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" )
@@ -159,6 +183,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.