Imported Upstream version 17.14.1
[platform/upstream/libzypp.git] / zypp / target / rpm / RpmDb.cc
index 298f272..7203d79 100644 (file)
@@ -59,6 +59,9 @@ using namespace zypp::filesystem;
 
 #define WORKAROUNDRPMPWDBUG
 
+#undef ZYPP_BASE_LOGGER_LOGGROUP
+#define ZYPP_BASE_LOGGER_LOGGROUP "librpmDb"
+
 namespace zypp
 {
   namespace zypp_readonly_hack
@@ -331,6 +334,14 @@ void RpmDb::initDatabase( Pathname root_r, Pathname dbPath_r, bool doRebuild_r )
     ZYPP_THROW(RpmInvalidRootException(root_r, dbPath_r));
   }
 
+  if ( dbPath_r == "/var/lib/rpm"
+    && ! PathInfo( root_r/"/var/lib/rpm" ).isExist()
+    && PathInfo( root_r/"/usr/lib/sysimage/rpm" ).isDir() )
+  {
+    WAR << "Rpm package was deleted? Injecting missing rpmdb compat symlink." << endl;
+    filesystem::symlink( "../../usr/lib/sysimage/rpm", root_r/"/var/lib/rpm" );
+  }
+
   MIL << "Calling initDatabase: " << stringPath( root_r, dbPath_r )
       << ( doRebuild_r ? " (rebuilddb)" : "" )
       << ( quickinit ? " (quickinit)" : "" ) << endl;
@@ -1019,9 +1030,10 @@ void RpmDb::syncTrustedKeys( SyncTrustedKeyBits mode_r )
       if ( ! missingKeys.empty() )
         callback::SendReport<KeyRingReport>()->reportNonImportedKeys(missingKeys);
     }
-    catch (Exception &e)
+    catch ( const Exception & excpt )
     {
-      ERR << "Could not import keys into zypp keyring" << endl;
+      ZYPP_CAUGHT( excpt );
+      ERR << "Could not import keys into zypp keyring: " << endl;
     }
   }
 
@@ -1547,8 +1559,13 @@ namespace
 
     rpmQVKArguments_s qva;
     memset( &qva, 0, sizeof(rpmQVKArguments_s) );
+#ifdef HAVE_NO_RPMTSSETVFYFLAGS
+    // Legacy: In rpm >= 4.15 qva_flags symbols don't exist
+    // and qva_flags is not used in signature checking at all.
     qva.qva_flags = (VERIFY_DIGEST|VERIFY_SIGNATURE);
-
+#else
+    ::rpmtsSetVfyFlags( ts, RPMVSF_DEFAULT );
+#endif
     RpmlogCapture vresult;
     LocaleGuard guard( LC_ALL, "C" );  // bsc#1076415: rpm log output is localized, but we need to parse it :(
     int res = ::rpmVerifySignatures( &qva, ts, fd, path_r.basename().c_str() );