[OE-core] [PATCH 2/2] package_manager.py: ignore failed smart install with --attempt

Hongxu Jia hongxu.jia at windriver.com
Fri Sep 26 11:36:02 UTC 2014


Paul's patch added checking in smart to ignore failed install with --attempt
...
commit e9c1191da4f84c9743b053e7030ab28b48f57c44
Author: Paul Eggleton <paul.eggleton at linux.intel.com>
Date:   Thu Feb 6 13:39:01 2014 +0000

    python-smartpm: really ignore conflicts during install with --attempt
...

But if the failure is generated by rpm which smart doesn't resolve, we check
the output of smart, filter the failed packages, and attempt to install the
rest.

Here is an example, assume there are two packages which have identical file
name but different content, that cause confliction. If we install one without
--attempt, after it installed and install another with --attempt, the rpm
will generate an error which smart does not resolve:
...
|error: file /usr/share/man/man5/passwd.5 from install of
shadow-doc-4.2.1-r0.i586 conflicts with file from package
man-pages-3.71-r0.i586
|error: file /usr/share/man/man3/getspnam.3 from install of
shadow-doc-4.2.1-r0.i586 conflicts with file from package
man-pages-3.71-r0.i586
...

In this situation, remove failed packages, and attempt to install the rest.

[YOCTO #6769]

Signed-off-by: Hongxu Jia <hongxu.jia at windriver.com>
---
 meta/lib/oe/package_manager.py | 38 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 37 insertions(+), 1 deletion(-)

diff --git a/meta/lib/oe/package_manager.py b/meta/lib/oe/package_manager.py
index b3b3b2d..20997d3 100644
--- a/meta/lib/oe/package_manager.py
+++ b/meta/lib/oe/package_manager.py
@@ -955,7 +955,43 @@ class RpmPM(PackageManager):
             output = subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
             bb.note(output)
         except subprocess.CalledProcessError as e:
-            bb.fatal("Unable to install packages. Command '%s' "
+            if not attempt_only:
+                bb.fatal("Unable to install packages. Command '%s' "
+                         "returned %d:\n%s" % (cmd, e.returncode, e.output))
+            else:
+                bb.warn("Unable attempt to install packages. Command '%s' "
+                         "returned %d:\n%s" % (cmd, e.returncode, e.output))
+
+                # Remove failed packages, and attempt to install the rest
+                reinstall_pkgs = pkgs[:]
+                for line in e.output.split("\n"):
+                    if line.strip() == "":
+                        continue
+                    for pkg in pkgs[:]:
+                        name = pkg.split("@")[0]
+                        arch = pkg.split("@")[1]
+                        r = re.compile(r'%s\S+%s' % (name, arch))
+                        if r.search(line):
+                            pkgs.remove(pkg)
+
+                bb.warn("Attempt to install again: %s" % ' '.join(pkgs))
+                self._attempt_install(pkgs)
+
+    '''
+    Attempt to install spkgs, the spkgs is a pkg list with smart format
+    '''
+    def _attempt_install(self, spkgs):
+        if len(spkgs) == 0:
+            return
+
+        bb.note("Attempt to install the following packages: %s" % ' '.join(spkgs))
+        cmd = "%s %s install --attempt -y %s" % \
+              (self.smart_cmd, self.smart_opt, ' '.join(spkgs))
+        try:
+            output = subprocess.check_output(cmd.split(), stderr=subprocess.STDOUT)
+            bb.note(output)
+        except subprocess.CalledProcessError as e:
+            bb.warn("Unable attempt to install packages. Command '%s' "
                      "returned %d:\n%s" % (cmd, e.returncode, e.output))
 
     '''
-- 
1.9.1




More information about the Openembedded-core mailing list