Browse Source

package_manager: handle remove() with no packages

If remove() is called with an empty package list, ensure we do nothing instead
of calling the underlying package manager with an invalid command line.

[ YOCTO #12900 ]

(From OE-Core rev: 715ec20c433cb4ed5fde938c33a42b2a296e4e56)

Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Ross Burton 6 years ago
parent
commit
1de82d5fc0
1 changed files with 8 additions and 1 deletions
  1. 8 1
      meta/lib/oe/package_manager.py

+ 8 - 1
meta/lib/oe/package_manager.py

@@ -864,8 +864,9 @@ class RpmPM(PackageManager):
             failed_postinsts_abort(list(failed_scriptlets_pkgnames.keys()), self.d.expand("${T}/log.do_${BB_CURRENTTASK}"))
 
     def remove(self, pkgs, with_dependencies = True):
-        if len(pkgs) == 0:
+        if not pkgs:
             return
+
         self._prepare_pkg_transaction()
 
         if with_dependencies:
@@ -1353,6 +1354,9 @@ class OpkgPM(OpkgDpkgPM):
                                               (cmd, e.returncode, e.output.decode("utf-8")))
 
     def remove(self, pkgs, with_dependencies=True):
+        if not pkgs:
+            return
+
         if with_dependencies:
             cmd = "%s %s --force-remove --force-removal-of-dependent-packages remove %s" % \
                 (self.opkg_cmd, self.opkg_args, ' '.join(pkgs))
@@ -1663,6 +1667,9 @@ class DpkgPM(OpkgDpkgPM):
 
 
     def remove(self, pkgs, with_dependencies=True):
+        if not pkgs:
+            return
+
         if with_dependencies:
             os.environ['APT_CONFIG'] = self.apt_conf_file
             cmd = "%s purge %s" % (self.apt_get_cmd, ' '.join(pkgs))