All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Klauer, Daniel" <Daniel.Klauer@gin.de>
To: "Burton, Ross" <ross.burton@intel.com>
Cc: "poky@yoctoproject.org" <poky@yoctoproject.org>
Subject: Re: [PATCH] smartpm: Don't ignore error if RPM transaction fails without problems
Date: Wed, 25 May 2016 09:55:56 +0000	[thread overview]
Message-ID: <1464170156000.4828@gin.de> (raw)
In-Reply-To: <CAJTo0LYURNP+KnHrKMCqZvQdgpM94_tOS7DBL+1MtUCd3m0pEA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 6453 bytes --]

Hello,


thanks for the hint, I've sent this (and 2 more smartpm patches) to oe-core.


Best regards,

Daniel


________________________________
From: Burton, Ross <ross.burton@intel.com>
Sent: Tuesday, May 17, 2016 12:47
To: Klauer, Daniel
Cc: poky@yoctoproject.org
Subject: Re: [poky] [PATCH] smartpm: Don't ignore error if RPM transaction fails without problems

Good catch but patches that are actually for openembedded-core should go to openembedded-core@lists.openembedded.org<mailto:openembedded-core@lists.openembedded.org>, can you resend it?

Cheers,
Ross

On 12 May 2016 at 09:01, Klauer, Daniel <Daniel.Klauer@gin.de<mailto:Daniel.Klauer@gin.de>> wrote:
SmartPM could misinterpret RPM transaction error as success,
if ts.run() (RPM Python API) returns an empty problems list.

This could happen for example if the RPM database is partially corrupted
such that the transaction does not have any problems like conflicts or
missing dependencies, but still can't be committed.

The added patch fixes the problem in the upstream sources;
one of the existing patches has to be adjusted to still apply.

Signed-off-by: Daniel Klauer <daniel.klauer@gin.de<mailto:daniel.klauer@gin.de>>
---
 ...gnore-transaction-error-with-empty-proble.patch | 57 ++++++++++++++++++++++
 .../python/python-smartpm/smart-attempt.patch      |  6 +--
 meta/recipes-devtools/python/python-smartpm_git.bb<http://python-smartpm_git.bb> |  1 +
 3 files changed, 61 insertions(+), 3 deletions(-)
 create mode 100644 meta/recipes-devtools/python/python-smartpm/0001-rpm-Don-t-ignore-transaction-error-with-empty-proble.patch

diff --git a/meta/recipes-devtools/python/python-smartpm/0001-rpm-Don-t-ignore-transaction-error-with-empty-proble.patch b/meta/recipes-devtools/python/python-smartpm/0001-rpm-Don-t-ignore-transaction-error-with-empty-proble.patch
new file mode 100644
index 0000000..a740ddd
--- /dev/null
+++ b/meta/recipes-devtools/python/python-smartpm/0001-rpm-Don-t-ignore-transaction-error-with-empty-proble.patch
@@ -0,0 +1,57 @@
+From 0c55d7e18f40465e95e8e4bf22af01f5d4477d3c Mon Sep 17 00:00:00 2001
+From: Daniel Klauer <daniel.klauer@gin.de<mailto:daniel.klauer@gin.de>>
+Date: Wed, 11 May 2016 17:22:49 +0200
+Subject: [PATCH] rpm: Don't ignore transaction error with empty problems list
+
+SmartPM could misinterpret RPM transaction error as success,
+if ts.run() (RPM Python API) returns an empty problems list,
+because of incorrect check for None which treated empty list
+to be the same as None when it has different meaning.
+
+ts.run() returns:
+* None in case of success
+* problems list in case of error, may be empty
+(look at rpmts_Run() in rpm-5.4.14/python/rpmts-py.c [1])
+
+"if mylist" is not good enough to check for error here, because it will
+treat an empty list as "false" because its len() == 0 [2].
+
+ts.check() seems to be different (it's ok for it to return an empty list),
+but for consistency it should be made clear that it can return either None,
+an empty list or a non-empty list.
+
+[1] http://rpm5.org/cvs/fileview?f=rpm/python/rpmts-py.c&v=1.111.2.3
+[2] https://docs.python.org/2/library/stdtypes.html#truth-value-testing
+
+Upstream-Status: Pending
+
+Signed-off-by: Daniel Klauer <daniel.klauer@gin.de<mailto:daniel.klauer@gin.de>>
+---
+ smart/backends/rpm/pm.py | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/smart/backends/rpm/pm.py b/smart/backends/rpm/pm.py
+index 9bbd952..635f726 100644
+--- a/smart/backends/rpm/pm.py
++++ b/smart/backends/rpm/pm.py
+@@ -208,7 +208,7 @@ class RPMPackageManager(PackageManager):
+         force = sysconf.get("rpm-force", False)
+         if not force:
+             probs = ts.check()
+-            if probs:
++            if (probs is not None) and (len(probs) != 0):
+                 problines = []
+                 for prob in probs:
+                     name1 = "%s-%s-%s" % prob[0]
+@@ -247,7 +247,7 @@ class RPMPackageManager(PackageManager):
+             del getTS.ts
+             cb.grabOutput(False)
+             prog.setDone()
+-            if probs:
++            if probs is not None:
+                 raise Error, "\n".join([x[0] for x in probs])
+             prog.stop()
+
+--
+1.9.1
+
diff --git a/meta/recipes-devtools/python/python-smartpm/smart-attempt.patch b/meta/recipes-devtools/python/python-smartpm/smart-attempt.patch
index ec98e03..5aedc88 100644
--- a/meta/recipes-devtools/python/python-smartpm/smart-attempt.patch
+++ b/meta/recipes-devtools/python/python-smartpm/smart-attempt.patch
@@ -36,7 +36,7 @@ index 9bbd952..ba6405a 100644
          finally:
              del getTS.ts
              cb.grabOutput(False)
-+            if probs and sysconf.has("attempt-install", soft=True):
++            if (probs is not None) and sysconf.has("attempt-install", soft=True):
 +                def remove_conflict(pkgNEVR):
 +                    for key in changeset.keys():
 +                        if pkgNEVR == str(key):
@@ -67,8 +67,8 @@ index 9bbd952..ba6405a 100644
 +                        retry = 0
 +
              prog.setDone()
--            if probs:
-+            if probs and (not retry):
+-            if probs is not None:
++            if (probs is not None) and (not retry):
                  raise Error, "\n".join([x[0] for x in probs])
              prog.stop()
 +            if retry and len(changeset):
diff --git a/meta/recipes-devtools/python/python-smartpm_git.bb<http://python-smartpm_git.bb> b/meta/recipes-devtools/python/python-smartpm_git.bb<http://python-smartpm_git.bb>
index d6c378b..95b7e09 100644
--- a/meta/recipes-devtools/python/python-smartpm_git.bb<http://python-smartpm_git.bb>
+++ b/meta/recipes-devtools/python/python-smartpm_git.bb<http://python-smartpm_git.bb>
@@ -17,6 +17,7 @@ SRC_URI = "\
           file://smart-recommends.patch \
           file://smart-improve-error-reporting.patch \
           file://smart-channelsdir.patch \
+          file://0001-rpm-Don-t-ignore-transaction-error-with-empty-proble.patch \
           file://smart-attempt.patch \
           file://smart-attempt-fix.patch \
           file://smart-rpm4-fixes.patch \
--
1.9.1
--
_______________________________________________
poky mailing list
poky@yoctoproject.org<mailto:poky@yoctoproject.org>
https://lists.yoctoproject.org/listinfo/poky


[-- Attachment #2: Type: text/html, Size: 10638 bytes --]

  reply	other threads:[~2016-05-25  9:56 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-12  8:01 [PATCH] smartpm: Don't ignore error if RPM transaction fails without problems Klauer, Daniel
2016-05-17 10:47 ` Burton, Ross
2016-05-25  9:55   ` Klauer, Daniel [this message]
  -- strict thread matches above, loose matches on Subject: below --
2016-05-17 12:54 Klauer, Daniel
2016-05-17 12:58 ` [PATCH] " Klauer, Daniel
2016-06-07 13:17   ` Herve Jourdain
2016-06-08 11:35     ` Klauer, Daniel
     [not found]     ` <1465381435600.39214@gin.de>
2016-06-08 12:52       ` Herve Jourdain
2016-06-08 15:43         ` Klauer, Daniel
2016-06-08 16:00           ` Herve Jourdain
2016-06-08 16:05           ` Mark Hatle
2016-06-08 16:17             ` Herve Jourdain
2016-06-08 16:47               ` Mark Hatle
2016-06-09  8:19                 ` Klauer, Daniel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1464170156000.4828@gin.de \
    --to=daniel.klauer@gin.de \
    --cc=poky@yoctoproject.org \
    --cc=ross.burton@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.