[OE-core] [PATCH] package_manager: rpm: remove update-alternatives correctly

Mikko Ylinen mikko.ylinen at linux.intel.com
Tue Sep 26 12:03:28 UTC 2017


With "read-only-rootfs" in IMAGE_FEATURES, packages in ROOTFS_RO_UNNEEDED
are removed when building the rootfs.

rootfs.py has a note about some of the assumptions to that removal:

 "Make sure update-alternatives is last on the command line, so
  that it is removed last. This makes sure that its database is
  available while uninstalling packages, allowing alternative
  symlinks of packages to be uninstalled to be managed correctly."

However, it turns out rpm does not care about "last on the command
line" and update-alternatives provider is removed before other the
packages get to run their %preun scripts for update-alternatives.

This leaves broken alternative symlinks in rootfs.

The fix is to remove packages one by one (reversed command line
list did not work either) and process update-alternatives provider
last.

And while we're at it, make logging more verbose to better see
what's happening (and to get it consistent with opkg's remove() logging).

Signed-off-by: Mikko Ylinen <mikko.ylinen at linux.intel.com>
---
 meta/lib/oe/package_manager.py | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/meta/lib/oe/package_manager.py b/meta/lib/oe/package_manager.py
index 994e462..c122902 100644
--- a/meta/lib/oe/package_manager.py
+++ b/meta/lib/oe/package_manager.py
@@ -614,13 +614,16 @@ class RpmPM(PackageManager):
             self._invoke_dnf(["remove"] + pkgs)
         else:
             cmd = bb.utils.which(os.getenv('PATH'), "rpm")
-            args = ["-e", "--nodeps", "--root=%s" %self.target_rootfs]
+            args = ["-e", "-v", "--nodeps", "--root=%s" %self.target_rootfs]
 
-            try:
-                output = subprocess.check_output([cmd] + args + pkgs, stderr=subprocess.STDOUT).decode("utf-8")
-            except subprocess.CalledProcessError as e:
-                bb.fatal("Could not invoke rpm. Command "
-                     "'%s' returned %d:\n%s" % (' '.join([cmd] + args + pkgs), e.returncode, e.output.decode("utf-8")))
+            for pkg in pkgs:
+                try:
+                    bb.note("Running %s" % ' '.join([cmd] + args + [pkg]))
+                    output = subprocess.check_output([cmd] + args + [pkg], stderr=subprocess.STDOUT).decode("utf-8")
+                    bb.note(output)
+                except subprocess.CalledProcessError as e:
+                    bb.fatal("Could not invoke rpm. Command "
+                         "'%s' returned %d:\n%s" % (' '.join([cmd] + args + [pkg]), e.returncode, e.output.decode("utf-8")))
 
     def upgrade(self):
         self._prepare_pkg_transaction()
-- 
2.1.4




More information about the Openembedded-core mailing list