Imported Upstream version 17.5.2 upstream/17.5.2
authorDongHun Kwak <dh0128.kwak@samsung.com>
Mon, 2 Sep 2019 07:15:52 +0000 (16:15 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Mon, 2 Sep 2019 07:15:52 +0000 (16:15 +0900)
VERSION.cmake
package/libzypp.changes
zypp/CMakeLists.txt
zypp/ExternalProgram.cc
zypp/ExternalProgram.h
zypp/RepoManager.cc
zypp/ShutdownLock.cc [new file with mode: 0644]
zypp/ShutdownLock_p.h [new file with mode: 0644]
zypp/target/TargetImpl.cc
zypp/ui/Selectable.cc

index c33ce82..7fb4ad1 100644 (file)
@@ -61,8 +61,8 @@
 SET(LIBZYPP_MAJOR "17")
 SET(LIBZYPP_COMPATMINOR "2")
 SET(LIBZYPP_MINOR "5")
-SET(LIBZYPP_PATCH "1")
+SET(LIBZYPP_PATCH "2")
 #
-# LAST RELEASED: 17.5.1 (2)
+# LAST RELEASED: 17.5.2 (2)
 # (The number in parenthesis is LIBZYPP_COMPATMINOR)
 #=======
index 9783a12..315cea9 100644 (file)
@@ -1,4 +1,13 @@
 -------------------------------------------------------------------
+Thu Jul 19 12:57:21 CEST 2018 - ma@suse.de
+
+- Prevent the system from sleeping during a commit
+  (fixes openSUSE/zypper#135)
+- RepoManager: Explicitly request repo2solv to generate application
+  pseudo packages.
+- version 17.5.2 (2)
+
+-------------------------------------------------------------------
 Wed Jul 18 10:55:49 CEST 2018 - ma@suse.de
 
 - libzypp-devel should not require cmake (bsc#1101349)
index 559289f..34d1ebd 100644 (file)
@@ -72,6 +72,7 @@ SET( zypp_SRCS
   ServiceInfo.cc
   Signature.cc
   SrcPackage.cc
+  ShutdownLock.cc
   SysContent.cc
   Target.cc
   TmpPath.cc
index 54a5f2d..d5f1460 100644 (file)
@@ -178,12 +178,12 @@ namespace zypp {
 
 
 
-    void ExternalProgram::start_program( const char *const *argv,
+    void ExternalProgram::start_program(const char *const *argv,
                                         const Environment & environment,
                                         Stderr_Disposition stderr_disp,
                                         int stderr_fd,
                                         bool default_locale,
-                                        const char * root )
+                                        const char * root , bool switch_pgid)
     {
       pid = -1;
       _exitStatus = 0;
@@ -307,6 +307,8 @@ namespace zypp {
        }
        else
        {
+            if ( switch_pgid )
+              setpgid( 0, 0);
            renumber_fd (to_external[0], 0); // set new stdin
            ::close(from_external[0]);    // Belongs to father process
 
index 76ec38e..f3e67a0 100644 (file)
@@ -19,6 +19,7 @@
 #include <string>
 #include <vector>
 
+#include "zypp/APIConfig.h"
 #include "zypp/base/ExternalDataSource.h"
 #include "zypp/Pathname.h"
 
@@ -225,10 +226,12 @@ namespace zypp {
       /** Remember execution errors like failed fork/exec. */
       std::string _execError;
 
+    protected:
+
       void start_program (const char *const *argv, const Environment & environment,
                        Stderr_Disposition stderr_disp = Normal_Stderr,
                        int stderr_fd = -1, bool default_locale = false,
-                       const char* root = NULL);
+                       const char* root = NULL, bool switch_pgid = false);
 
     };
 
@@ -299,6 +302,22 @@ namespace zypp {
       std::string _buffer;
   };
 
+  /** ExternalProgram extended to change the progress group ID after forking.
+   * \see \ref ExternalProgram
+   */
+  class ZYPP_LOCAL ExternalProgramWithSeperatePgid : public ExternalProgram
+  {
+    public:
+      ExternalProgramWithSeperatePgid (const char *const *argv,
+                   Stderr_Disposition stderr_disp = Normal_Stderr,
+                   int stderr_fd = -1, bool default_locale = false,
+                   const Pathname& root = "") : ExternalProgram()
+      {
+        start_program( argv, Environment(), stderr_disp, stderr_fd, default_locale, root.c_str(), true );
+      }
+
+  };
+
 } // namespace zypp
 
 #endif // ZYPP_EXTERNALPROGRAM_H
index fa022e0..3256d2e 100644 (file)
@@ -1348,6 +1348,7 @@ namespace zypp
         cmd.push_back( "-o" );
         cmd.push_back( solvfile.asString() );
        cmd.push_back( "-X" );  // autogenerate pattern from pattern-package
+        cmd.push_back( "-A" ); // autogenerate application pseudo packages
 
         if ( repokind == RepoType::RPMPLAINDIR )
         {
diff --git a/zypp/ShutdownLock.cc b/zypp/ShutdownLock.cc
new file mode 100644 (file)
index 0000000..4715fe0
--- /dev/null
@@ -0,0 +1,32 @@
+#include "ShutdownLock_p.h"
+
+#include "zypp/ExternalProgram.h"
+#include <iostream>
+
+zypp::ShutdownLock::ShutdownLock(const std::string &reason)
+{
+  try {
+
+    std::string whyStr = str::form("--why=%s", reason.c_str());
+
+    const char* argv[] =
+    {
+      "/usr/bin/systemd-inhibit",
+      "--what=sleep:shutdown:idle",
+      "--who=zypp",
+      "--mode=block",
+      whyStr.c_str(),
+      "/usr/bin/cat",
+      NULL
+    };
+    _prog = shared_ptr<ExternalProgramWithSeperatePgid>( new ExternalProgramWithSeperatePgid( argv, ExternalProgram::Discard_Stderr ) );
+  } catch (...) {
+  }
+}
+
+zypp::ShutdownLock::~ShutdownLock()
+{
+  if (_prog) {
+    _prog->kill();
+  }
+}
diff --git a/zypp/ShutdownLock_p.h b/zypp/ShutdownLock_p.h
new file mode 100644 (file)
index 0000000..ade9985
--- /dev/null
@@ -0,0 +1,45 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/ShutdownLock_p.h
+ *
+*/
+
+#ifndef ZYPP_SHUTDOWNLOCK_P_H_INCLUDED
+#define ZYPP_SHUTDOWNLOCK_P_H_INCLUDED
+
+#include <string>
+
+#include "zypp/APIConfig.h"
+#include "zypp/base/PtrTypes.h"
+
+namespace zypp
+{
+
+class ExternalProgramWithSeperatePgid;
+
+/**
+ * Attempts to create a lock to prevent the system
+ * from going into hibernate/shutdown. The lock is automatically
+ * released when the object is destroyed.
+ */
+class ZYPP_LOCAL ShutdownLock
+{
+public:
+   ShutdownLock( const std::string &reason );
+   ~ShutdownLock();
+
+private:
+   shared_ptr<ExternalProgramWithSeperatePgid> _prog;
+
+};
+
+}
+
+
+#endif
index 4b98ff7..f4596f6 100644 (file)
@@ -38,6 +38,7 @@
 #include "zypp/RepoStatus.h"
 #include "zypp/ExternalProgram.h"
 #include "zypp/Repository.h"
+#include "zypp/ShutdownLock_p.h"
 
 #include "zypp/ResFilters.h"
 #include "zypp/HistoryLog.h"
@@ -1095,6 +1096,7 @@ namespace zypp
     {
       // ----------------------------------------------------------------- //
       ZYppCommitPolicy policy_r( policy_rX );
+      ShutdownLock lck("Zypp commit running.");
 
       // Fake outstanding YCP fix: Honour restriction to media 1
       // at installation, but install all remaining packages if post-boot.
index b7549e5..1d41383 100644 (file)
@@ -160,11 +160,12 @@ namespace zypp
 
     Selectable::picklist_size_type Selectable::picklistPos( const sat::Solvable & solv_r ) const
     {
-      picklist_size_type idx = picklist_size_type(-1);
+      picklist_size_type idx = picklist_size_type(0);
       for ( const auto & pi : picklist() )
       {
        if ( pi == solv_r )
-         return ++idx;
+         return idx;
+       ++idx;
       }
       return picklistNoPos;
     }