Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package libstorage-ng for openSUSE:Factory 
checked in at 2024-02-28 19:44:43
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/libstorage-ng (Old)
 and      /work/SRC/openSUSE:Factory/.libstorage-ng.new.1770 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "libstorage-ng"

Wed Feb 28 19:44:43 2024 rev:263 rq:1152909 version:4.5.193

Changes:
--------
--- /work/SRC/openSUSE:Factory/libstorage-ng/libstorage-ng.changes      
2024-02-23 16:41:24.890822975 +0100
+++ /work/SRC/openSUSE:Factory/.libstorage-ng.new.1770/libstorage-ng.changes    
2024-02-28 19:44:55.081015974 +0100
@@ -1,0 +2,14 @@
+Wed Feb 28 11:13:01 UTC 2024 - aschn...@suse.com
+
+- merge gh#openSUSE/libstorage-ng#988
+- allow more control of environment in SystemCmd class
+- 4.5.193
+
+--------------------------------------------------------------------
+Tue Feb 27 16:05:37 UTC 2024 - aschn...@suse.com
+
+- merge gh#openSUSE/libstorage-ng#987
+- fixed check in testsuite
+- 4.5.192
+
+--------------------------------------------------------------------

Old:
----
  libstorage-ng-4.5.191.tar.xz

New:
----
  libstorage-ng-4.5.193.tar.xz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ libstorage-ng.spec ++++++
--- /var/tmp/diff_new_pack.72jpAh/_old  2024-02-28 19:44:56.049050917 +0100
+++ /var/tmp/diff_new_pack.72jpAh/_new  2024-02-28 19:44:56.053051062 +0100
@@ -18,7 +18,7 @@
 
 %define libname %{name}1
 Name:           libstorage-ng
-Version:        4.5.191
+Version:        4.5.193
 Release:        0
 Summary:        Library for storage management
 License:        GPL-2.0-only

++++++ libstorage-ng-4.5.191.tar.xz -> libstorage-ng-4.5.193.tar.xz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libstorage-ng-4.5.191/VERSION 
new/libstorage-ng-4.5.193/VERSION
--- old/libstorage-ng-4.5.191/VERSION   2024-02-22 12:42:46.000000000 +0100
+++ new/libstorage-ng-4.5.193/VERSION   2024-02-28 12:13:01.000000000 +0100
@@ -1 +1 @@
-4.5.191
+4.5.193
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/libstorage-ng-4.5.191/storage/SystemInfo/CmdParted.cc 
new/libstorage-ng-4.5.193/storage/SystemInfo/CmdParted.cc
--- old/libstorage-ng-4.5.191/storage/SystemInfo/CmdParted.cc   2024-02-22 
12:42:46.000000000 +0100
+++ new/libstorage-ng-4.5.193/storage/SystemInfo/CmdParted.cc   2024-02-28 
12:13:01.000000000 +0100
@@ -51,7 +51,7 @@
                "unit", "s", "print" }, SystemCmd::DoThrow);
        options.verify = [](int) { return true; };
        if (!json)
-           options.env.push_back("PARTED_PRINT_NUMBER_OF_PARTITION_SLOTS=1");
+           options.setenv("PARTED_PRINT_NUMBER_OF_PARTITION_SLOTS", "1");
 
        SystemCmd cmd(options);
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/libstorage-ng-4.5.191/storage/SystemInfo/CmdUdevadm.cc 
new/libstorage-ng-4.5.193/storage/SystemInfo/CmdUdevadm.cc
--- old/libstorage-ng-4.5.191/storage/SystemInfo/CmdUdevadm.cc  2024-02-22 
12:42:46.000000000 +0100
+++ new/libstorage-ng-4.5.193/storage/SystemInfo/CmdUdevadm.cc  2024-02-28 
12:13:01.000000000 +0100
@@ -52,7 +52,8 @@
        udevadm.settle();
 
        SystemCmd::Options options({ UDEVADM_BIN, "info", file }, 
SystemCmd::DoThrow);
-       options.env.push_back("SYSTEMD_COLORS=false");
+       options.unsetenv("SYSTEMD_COLORS");
+
        SystemCmd cmd(options);
 
        parse(cmd.stdout());
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libstorage-ng-4.5.191/storage/Utils/FileUtils.cc 
new/libstorage-ng-4.5.193/storage/Utils/FileUtils.cc
--- old/libstorage-ng-4.5.191/storage/Utils/FileUtils.cc        2024-02-22 
12:42:46.000000000 +0100
+++ new/libstorage-ng-4.5.193/storage/Utils/FileUtils.cc        2024-02-28 
12:13:01.000000000 +0100
@@ -41,10 +41,7 @@
        : path(path), name(name_template)
     {
        char* t = strdup(get_fullname().c_str());
-       if (!t)
-       {
-           ST_THROW(Exception("strdup failed"));
-       }
+       ST_CHECK_PTR(t);
 
        if (mkdtemp(t) == NULL)
        {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libstorage-ng-4.5.191/storage/Utils/SystemCmd.cc 
new/libstorage-ng-4.5.193/storage/Utils/SystemCmd.cc
--- old/libstorage-ng-4.5.191/storage/Utils/SystemCmd.cc        2024-02-22 
12:42:46.000000000 +0100
+++ new/libstorage-ng-4.5.193/storage/Utils/SystemCmd.cc        2024-02-28 
12:13:01.000000000 +0100
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) [2004-2015] Novell, Inc.
- * Copyright (c) [2016-2023] SUSE LLC
+ * Copyright (c) [2016-2024] SUSE LLC
  *
  * All Rights Reserved.
  *
@@ -62,35 +62,66 @@
     SystemCmd::Options::Options(const string& command, ThrowBehaviour 
throw_behaviour)
        : command(command), throw_behaviour(throw_behaviour)
     {
-       init_env();
+       init_envs();
     }
 
 
     SystemCmd::Options::Options(const Args& args, ThrowBehaviour 
throw_behaviour)
        : args(args.get_values()), throw_behaviour(throw_behaviour)
     {
-       init_env();
+       init_envs();
     }
 
 
     SystemCmd::Options::Options(std::initializer_list<string> init, 
ThrowBehaviour throw_behaviour)
        : args(init), throw_behaviour(throw_behaviour)
     {
-       init_env();
+       init_envs();
     }
 
 
     void
-    SystemCmd::Options::init_env()
+    SystemCmd::Options::setenv(const char* name, const char* value)
     {
+       // Environment variables should be present only once in the environment.
+       // 
https://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html
+
+       unsetenv(name);
+
+       envs.emplace_back(string(name) + "=" + value);
+    }
+
+
+    void
+    SystemCmd::Options::unsetenv(const char* name)
+    {
+       erase_if(envs, [name](const string& env) {
+           string::size_type pos = env.find("=");
+           return env.substr(0, pos) == name;
+       });
+    }
+
+
+    void
+    SystemCmd::Options::init_envs()
+    {
+       for (char** v = environ; *v != NULL; ++v)
+           envs.push_back(*v);
+
        // parted needs UTF-8 to decode partition names with non-ASCII 
characters. Might
        // be the case for other programs as well. Running in non-UTF-8 is not 
really
        // supported.
 
        if (strcmp(nl_langinfo(CODESET), "UTF-8") == 0)
-           env = { "LC_ALL=C.UTF-8", "LANGUAGE=C.UTF-8" };
+       {
+           setenv("LC_ALL", "C.UTF-8");
+           setenv("LANGUAGE", "C.UTF-8");
+       }
        else
-           env = { "LC_ALL=C", "LANGUAGE=C" };
+       {
+           setenv("LC_ALL", "C");
+           setenv("LANGUAGE", "C");
+       }
     }
 
 
@@ -713,7 +744,9 @@
 
        for (const string& v : system_cmd.options.args)
        {
-           args.push_back(strdup(v.c_str()));
+           char* p = strdup(v.c_str());
+           ST_CHECK_NEW(p);
+           args.push_back(p);
        }
 
        args.push_back(nullptr);
@@ -725,33 +758,18 @@
     TmpForExec
     SystemCmd::Executor::make_env() const
     {
-       // Environment variables should be present only once in the environment.
-       // 
https://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html
+       vector<char*> envs;
 
-       vector<char*> env;
-
-       for (char** v = environ; *v != NULL; ++v)
-           env.push_back(strdup(*v));
-
-       for (const string& v : system_cmd.options.env)
+       for (const string& v : system_cmd.options.envs)
        {
-           string::size_type pos = v.find("=");
-           if (pos == string::npos)
-               continue;
-
-           string key = v.substr(0, pos + 1); // key including '=' sign
-
-           vector<char*>::iterator it = find_if(env.begin(), env.end(),
-               [&key](const char* tmp) { return boost::starts_with(tmp, key); 
});
-           if (it != env.end())
-               *it = strdup(v.c_str());
-           else
-               env.push_back(strdup(v.c_str()));
+           char* p = strdup(v.c_str());
+           ST_CHECK_NEW(p);
+           envs.push_back(p);
        }
 
-       env.push_back(nullptr);
+       envs.push_back(nullptr);
 
-       return env;
+       return envs;
     }
 
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libstorage-ng-4.5.191/storage/Utils/SystemCmd.h 
new/libstorage-ng-4.5.193/storage/Utils/SystemCmd.h
--- old/libstorage-ng-4.5.191/storage/Utils/SystemCmd.h 2024-02-22 
12:42:46.000000000 +0100
+++ new/libstorage-ng-4.5.193/storage/Utils/SystemCmd.h 2024-02-28 
12:13:01.000000000 +0100
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) [2004-2015] Novell, Inc.
- * Copyright (c) [2016-2023] SUSE LLC
+ * Copyright (c) [2016-2024] SUSE LLC
  *
  * All Rights Reserved.
  *
@@ -122,14 +122,17 @@
            std::function<bool(int)> verify = [](int exit_code) { return 
exit_code == 0; };
 
            /**
-            * Environment variables to override existing environment 
variables. Per
-            * default this includes LC_ALL=C[.UTF-8] and LANGUAGE=C[.UTF-8].
+            * Environment variables for child. Per default this includes the 
original
+            * environment and LC_ALL=C[.UTF-8] and LANGUAGE=C[.UTF-8].
             */
-           vector<string> env;
+           vector<string> envs;
+
+           void setenv(const char* name, const char* value);
+           void unsetenv(const char* name);
 
        private:
 
-           void init_env();
+           void init_envs();
 
        };
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/libstorage-ng-4.5.191/testsuite/Utils/systemcmd.cc 
new/libstorage-ng-4.5.193/testsuite/Utils/systemcmd.cc
--- old/libstorage-ng-4.5.191/testsuite/Utils/systemcmd.cc      2024-02-22 
12:42:46.000000000 +0100
+++ new/libstorage-ng-4.5.193/testsuite/Utils/systemcmd.cc      2024-02-28 
12:13:01.000000000 +0100
@@ -9,9 +9,9 @@
 #include <iostream>
 #include <string>
 #include <vector>
+#include <algorithm>
 
 #include "storage/Utils/Exception.h"
-#include "storage/Utils/Mockup.h"
 #include "storage/Utils/SystemCmd.h"
 #include "storage/Utils/StorageDefines.h"
 
@@ -252,7 +252,40 @@
 }
 
 
-BOOST_AUTO_TEST_CASE(env)
+BOOST_AUTO_TEST_CASE(env1)
+{
+    setenv("TWO", "2", 1);
+
+    SystemCmd::Options options("env");
+
+    BOOST_CHECK(find(options.envs.begin(), options.envs.end(), "TWO=2") != 
options.envs.end());
+
+    options.setenv("ONE", "1");
+
+    BOOST_CHECK(find(options.envs.begin(), options.envs.end(), "ONE=1") != 
options.envs.end());
+
+    options.setenv("ONE", "");
+
+    BOOST_CHECK(find(options.envs.begin(), options.envs.end(), "ONE=") != 
options.envs.end());
+
+    options.unsetenv("ONE");
+
+    BOOST_CHECK(find(options.envs.begin(), options.envs.end(), "ONE") == 
options.envs.end());
+    BOOST_CHECK(find(options.envs.begin(), options.envs.end(), "ONE=") == 
options.envs.end());
+    BOOST_CHECK(find(options.envs.begin(), options.envs.end(), "ONE=1") == 
options.envs.end());
+
+    // AFAIS an empty environment variable is always stored with a trailing 
'='. Even if
+    // that is not the case unsetenv works.
+
+    options.envs.push_back("ONE");
+    options.unsetenv("ONE");
+
+    BOOST_CHECK(find(options.envs.begin(), options.envs.end(), "ONE") == 
options.envs.end());
+    BOOST_CHECK(find(options.envs.begin(), options.envs.end(), "ONE=") == 
options.envs.end());
+}
+
+
+BOOST_AUTO_TEST_CASE(env2)
 {
     vector<string> stdout = {
        "C ++ sure"
@@ -264,7 +297,7 @@
 
     SystemCmd::Options options("echo $LC_ALL $FUNNY $AMUSING");
 
-    options.env.push_back("AMUSING=sure");
+    options.setenv("AMUSING", "sure");
 
     SystemCmd cmd(options);
 
@@ -281,7 +314,7 @@
     int n = 0;
 
     for (int fd = 0; fd < max_fd; ++fd)
-        if (fcntl(fd, F_GETFD) == 0)
+        if (fcntl(fd, F_GETFD) != -1)
          ++n;
 
     return n;

Reply via email to