Imported Upstream version 17.23.2 upstream/17.23.2
authorDongHun Kwak <dh0128.kwak@samsung.com>
Fri, 27 Nov 2020 06:48:17 +0000 (15:48 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Fri, 27 Nov 2020 06:48:17 +0000 (15:48 +0900)
CMakeLists.txt
VERSION.cmake
cmake/modules/ZyppCommon.cmake
libzypp.spec.cmake
package/libzypp.changes
tools/zypp-NameReqPrv.cc
zypp/Fetcher.cc
zypp/media/CredentialManager.cc
zypp/media/CredentialManager.h
zypp/repo/RepoVariables.cc

index e79e871..1245837 100644 (file)
@@ -1,9 +1,9 @@
+cmake_minimum_required(VERSION 3.1)
 PROJECT(LIBZYPP)
 SET( PACKAGE "libzypp" )
 # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
 SET( CMAKE_MODULE_PATH ${LIBZYPP_SOURCE_DIR}/cmake/modules )
-
-cmake_minimum_required(VERSION 2.6)
+INCLUDE(ZyppCommon)
 
 OPTION (ENABLE_BUILD_DOCS "Build documentation by default?" OFF)
 OPTION (ENABLE_BUILD_TRANS "Build translation files by default?" OFF)
@@ -18,8 +18,6 @@ OPTION (EXPORT_NG_API "Export experimental libzypp API" OFF)
 #--------------------------------------------------------------------------------
 SET (have_system x)
 
-set (CMAKE_CXX_STANDARD 14)
-
 IF (DEBIAN)
   MESSAGE (STATUS "Building for Debian")
   SET (ENABLE_BUILD_DOCS ON)
@@ -43,7 +41,6 @@ if(COMMAND cmake_policy)
   cmake_policy(SET CMP0003 NEW)
 endif(COMMAND cmake_policy)
 
-INCLUDE(ZyppCommon)
 find_package(FindPkgConfig)
 INCLUDE( ${LIBZYPP_SOURCE_DIR}/VERSION.cmake )
 
@@ -56,6 +53,7 @@ MATH( EXPR LIBZYPP_SO_FIRST  "${LIBZYPP_CURRENT}-${LIBZYPP_AGE}" )
 SET( VERSION "${LIBZYPP_MAJOR}.${LIBZYPP_MINOR}.${LIBZYPP_PATCH}" )
 CONFIGURE_FILE ( zypp/APIConfig.h.in zypp/APIConfig.h )
 
+SET (CMAKE_CXX_STANDARD ${ZYPPCOMMON_CXX_STANDARD})
 include(CheckCCompilerFlag)
 include(CheckCXXCompilerFlag)
 CHECK_C_COMPILER_FLAG("-Werror=format-security" CC_FORMAT_SECURITY)
index f04cc4f..7da3876 100644 (file)
@@ -61,8 +61,8 @@
 SET(LIBZYPP_MAJOR "17")
 SET(LIBZYPP_COMPATMINOR "22")
 SET(LIBZYPP_MINOR "23")
-SET(LIBZYPP_PATCH "1")
+SET(LIBZYPP_PATCH "2")
 #
-# LAST RELEASED: 17.23.1 (22)
+# LAST RELEASED: 17.23.2 (22)
 # (The number in parenthesis is LIBZYPP_COMPATMINOR)
 #=======
index 8b3ec77..621200d 100644 (file)
@@ -57,10 +57,10 @@ ENDIF( NOT DEFINED DOC_INSTALL_DIR )
 # INCLUDES                                                         #
 ####################################################################
 
+SET( ZYPPCOMMON_CXX_STANDARD 17 )
 #SET (CMAKE_INCLUDE_DIRECTORIES_BEFORE ON)
 INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} SYSTEM )
 
-
 ####################################################################
 # RPM SPEC                                                         #
 ####################################################################
index 6eb36fd..cf444d5 100644 (file)
@@ -50,7 +50,7 @@ Recommends:     logrotate
 # lsof is used for 'zypper ps':
 Recommends:     lsof
 %endif
-BuildRequires:  cmake
+BuildRequires:  cmake >= 3.1
 BuildRequires:  openssl-devel
 BuildRequires:  pkgconfig(libudev)
 %if 0%{?suse_version} >= 1330
@@ -63,7 +63,7 @@ BuildRequires:  boost-devel
 %endif
 BuildRequires:  dejagnu
 BuildRequires:  doxygen
-BuildRequires:  gcc-c++ >= 4.6
+BuildRequires:  gcc-c++ >= 7
 BuildRequires:  gettext-devel
 BuildRequires:  graphviz
 BuildRequires:  libxml2-devel
index 684deee..84e3947 100644 (file)
@@ -1,4 +1,12 @@
 -------------------------------------------------------------------
+Fri Mar 20 12:28:18 CET 2020 - ma@suse.de
+
+- RepoVariables: Add safe guard in case the caller does not own a
+  zypp instance.
+- Enable c++17. Define libyzpp CXX_STANDARD in ZyppCommon.cmake.
+- version 17.23.2 (22)
+
+-------------------------------------------------------------------
 Mon Mar  2 19:53:51 CET 2020 - ma@suse.de
 
 - Fix package status computation regarding unneeded, orphaned, recommended
index f21adc3..63a1ac4 100644 (file)
@@ -60,60 +60,96 @@ int usage( const std::string & msg_r = std::string(), int exit_r = 100 )
 #define COL_WH  "\033[1;37m"
 #define COL_OFF "\033[0m"
 
-std::string colorId( sat::Solvable solv_r )
-{
-  // return solv_r.asString();
-  std::string ret;
-  if ( solv_r )
-  {
-    static str::Format fmt { COL_B "%s" COL_OFF "-" COL_G "%s" COL_OFF ".%s" };
-    ret = fmt % solv_r.name() % solv_r.edition() % solv_r.arch();
-  }
-  else
-  {
-    ret = ( solv_r.id() == sat::detail::systemSolvableId ?  "systemSolvable" : "noSolvable" );
-  }
-  return ret;
-}
-
-void tableOut( const std::string & s1 = std::string(),
-               const std::string & s2 = std::string(),
-               const std::string & s3 = std::string(),
-               const std::string & s4 = std::string(),
-               const std::string & s5 = std::string() )
-{
-  message << "  ";
-#define TABEL(N) static unsigned w##N = 0; if ( ! s##N.empty() ) w##N = std::max( w##N, unsigned(s##N.size()) ); message << str::form( " %-*s ", w##N, s##N.c_str() )
-#define TABER(N) static unsigned w##N = 0; if ( ! s##N.empty() ) w##N = std::max( w##N, unsigned(s##N.size()) ); message << str::form( " %*s ", w##N, s##N.c_str() )
-  TABER( 1 ); TABEL( 2 ); TABEL( 3 ); TABEL( 4 ); TABEL( 5 );
-#undef TABEL
-  message << endl;
-}
-
 struct PQSort
 {
   // std::less semantic
-  bool operator()( const PoolQuery::const_iterator & lhs, const PoolQuery::const_iterator & rhs ) const
+  bool operator()( const sat::Solvable & lhs, const sat::Solvable & rhs ) const
   {
     {
-      bool l = lhs->isSystem();
-      bool r = rhs->isSystem();
+      bool l = lhs.isSystem();
+      bool r = rhs.isSystem();
       if ( l != r )
        return r;
     }
     {
-      std::string l( lhs->ident().asString() );
-      std::string r( rhs->ident().asString() );
+      IdString l { lhs.ident() };
+      IdString r { rhs.ident() };
       if ( l != r )
        return l < r;
     }
-    return avo( PoolItem(*lhs), PoolItem(*rhs) );
-    return lhs->id() > rhs->id();
+    return avo( PoolItem(lhs), PoolItem(rhs) );
+    return lhs.id() > rhs.id();
   }
 
   ui::SelectableTraits::AVOrder avo;
 };
 
+struct Table
+{
+  void row( PoolQuery::const_iterator it_r )
+  {
+    //smax( _maxSID,  );
+    smax( _maxNAME, it_r->ident().size() + it_r->edition().size() + it_r->arch().size() );
+    smax( _maxREPO, it_r->repository().name().size(), it_r->repository().name() );
+    //smax( _maxTIME, );
+    //smax( _maxVEND, it_r->vendor().size() );
+
+    std::vector<std::string> & details { _map[*it_r] };
+    for_( match, it_r.matchesBegin(), it_r.matchesEnd() ) {
+      details.push_back( match->inSolvAttr().asString().substr( 9, 3 )+": " +match->asString() );
+    }
+  }
+
+  std::ostream & dumpOn( std::ostream & str ) const
+  {
+    #define S "  "
+
+    #define fmtSID  "%*d"
+    #define argSID  _maxSID, slv.id()
+
+    #define fmtNAME COL_B "%s" COL_OFF "-" COL_G "%s" COL_OFF ".%-*s"
+    #define argNAME slv.ident().c_str(), slv.edition().c_str(), _maxNAME-slv.ident().size()-slv.edition().size(), slv.arch().c_str()
+
+    #define fmtREPO "(%2d)%-*s"
+    #define argREPO slv.repository().info().priority(), _maxREPO, slv.repository().name().c_str()
+
+    #define fmtTIME "%10ld"
+    #define argTIME time_t( slv.isSystem() ? slv.installtime() : slv.buildtime() )
+
+    #define fmtVEND "%s"
+    #define argVEND slv.vendor().c_str()
+
+    std::string dind( _maxSID + _maxNAME+2/*-.*/ + 2*strlen(S), ' ' );
+
+    for ( const auto & el : _map ) {
+      sat::Solvable slv { el.first };
+      const char * tagCol = slv.isSystem() ? COL_M : ui::Selectable::get(slv)->identicalInstalled(PoolItem(slv)) ? COL_C : "";
+
+      str << str::form( "%s"    fmtSID S fmtNAME S "%s"    fmtREPO S fmtTIME S fmtVEND COL_OFF "\n",
+                       tagCol, argSID,  argNAME,  tagCol, argREPO,  argTIME,  argVEND );
+
+      for ( const auto & d : el.second )
+       str << dind << d << endl;
+    }
+    return str;
+  }
+
+private:
+  static void smax( unsigned & var_r, unsigned val_r, std::string_view n = {} )
+  { if ( val_r > var_r ) var_r = val_r; }
+
+private:
+  unsigned _maxSID  = 7;       // size + indent
+  unsigned _maxNAME = 0;
+  unsigned _maxREPO = 0;
+  //unsigned _maxTIME = 10;
+  //unsigned _maxVEND = 0;
+  std::map<sat::Solvable, std::vector<std::string>, PQSort> _map;
+};
+
+inline std::ostream & operator<<( std::ostream & str, const Table & table_r )
+{ return table_r.dumpOn( str ); }
+
 ///////////////////////////////////////////////////////////////////
 
 void dDump( const std::string & spec_r )
@@ -247,7 +283,6 @@ int main( int argc, char * argv[] )
       }
     }
   }
-
   ///////////////////////////////////////////////////////////////////
 
   bool ignorecase      ( true );
@@ -385,28 +420,14 @@ int main( int argc, char * argv[] )
     << (conflicts?'c':'_') << (obsoletes?'o':'_') << (recommends?'m':'_') << (supplements?'s':'_') << (enhacements?'e':'_')
     << "] {" << endl;
 
-    std::set<PoolQuery::const_iterator,PQSort> qsorted;
+    Table t;
     for_( it, q.begin(), q.end() )
-      qsorted.insert( it );
-
-    for ( auto && it : qsorted )
     {
       if ( it->isKind( ResKind::srcpackage ) && !withSrcPackages )
        continue;
-
-      tableOut( str::numstring( it->id() ), colorId(*it),
-               str::form( "(%d)%s", it->repository().info().priority(), it->repository().name().c_str() ),
-               str::numstring( PoolItem(*it)->buildtime() ) );
-      tableOut( "", "",
-               it->vendor().asString() );
-      if ( ! it.matchesEmpty() )
-      {
-       for_( match, it.matchesBegin(), it.matchesEnd() )
-       {
-         tableOut( "", "", match->inSolvAttr().asString().substr( 9, 3 )+": " +match->asString() );
-       }
-      }
+      t.row( it );
     }
+    message << t << endl;
 
     message << "}" << endl;
   }
index c6bf217..ce2f614 100644 (file)
@@ -55,7 +55,7 @@ namespace zypp
   /** std::set ordering (less semantic) */
   struct SameFetcherIndex
   {
-    bool operator()( const FetcherIndex_Ptr & lhs, const FetcherIndex_Ptr & rhs )
+    bool operator()( const FetcherIndex_Ptr & lhs, const FetcherIndex_Ptr & rhs ) const
     {
       if ( lhs == rhs )
         return false; // incl. NULL == NULL
index 9e52d2e..639bd6c 100644 (file)
@@ -39,7 +39,7 @@ namespace zypp
   //
   //////////////////////////////////////////////////////////////////////
 
-  bool AuthDataComparator::operator()( const AuthData_Ptr & lhs, const AuthData_Ptr & rhs )
+  bool AuthDataComparator::operator()( const AuthData_Ptr & lhs, const AuthData_Ptr & rhs ) const
   {
     static const url::ViewOption vopt = url::ViewOption::DEFAULTS
                                      - url::ViewOption::WITH_USERNAME
index 1a57c64..bd46fab 100644 (file)
@@ -48,7 +48,7 @@ namespace zypp
   // comparator for CredentialSet
   struct AuthDataComparator
   {
-    bool operator()(const AuthData_Ptr & lhs, const AuthData_Ptr & rhs);
+    bool operator()(const AuthData_Ptr & lhs, const AuthData_Ptr & rhs) const;
   };
 
   //////////////////////////////////////////////////////////////////////
index f09417c..cb140a9 100644 (file)
@@ -400,6 +400,11 @@ namespace zypp
       private:
        const std::string * _lookup( const std::string & name_r )
        {
+         // Safe guard in case the caller does not own a zypp instance. In this case
+         // getZYpp()->getTarget() in checkOverride would create a zypp instance which
+         // would clear the variables parsed so far.
+         auto guard { getZYpp() };
+
          if ( empty() )        // at init / after reset
          {
            // load user definitions from vars.d