[poky,meta] package_manager.py: handle renamed packages for PACKAGE_EXCLUDE with opkg

Submitted by Aditya Tayade on June 3, 2019, 4:42 p.m. | Patch ID: 161945

Details

Message ID 1559580099-29530-1-git-send-email-Aditya.Tayade@kpit.com
State New
Headers show

Commit Message

Aditya Tayade June 3, 2019, 4:42 p.m.
From: Michael Ho <Michael.Ho@bmw.de>

The PACKAGE_EXCLUDE variable is used to pass a list of packages to be
forbidden from installation with opkg. This list however does not account
normally for the renaming of packages which can occur (for example when the
debian bbclass is enabled, packages with libs are renamed from xxx to libxxx)
and so expected excluded packages are not blocked.

Rather than tediously maintaining the PACKAGE_EXCLUDE variable to handle
renamed packages that can dynamically change, move the expansion of the
variable from parsing time to run time so it can use the pkgdata dictionaries
to add automatically any renamed packages.

Upstream-Status: Pending

Signed-off-by: Michael Ho <Michael.Ho@bmw.de>
Signed-off-by: Aditya.Tayade <Aditya.Tayade@kpit.com>
---
 meta/classes/package_ipk.bbclass |  1 -
 meta/lib/oe/package_manager.py   | 15 +++++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

--
2.7.4

This message contains information that may be privileged or confidential and is the property of the KPIT Technologies Ltd. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message. KPIT Technologies Ltd. does not accept any liability for virus infected mails.

Patch hide | download patch | download mbox

diff --git a/meta/classes/package_ipk.bbclass b/meta/classes/package_ipk.bbclass
index d1b317b..fa71869 100644
--- a/meta/classes/package_ipk.bbclass
+++ b/meta/classes/package_ipk.bbclass
@@ -12,7 +12,6 @@  OPKGBUILDCMD ??= 'opkg-build -Z xz -a "${XZ_DEFAULTS}"'

 OPKG_ARGS += "--force_postinstall --prefer-arch-to-version"
 OPKG_ARGS += "${@['', '--no-install-recommends'][d.getVar("NO_RECOMMENDATIONS") == "1"]}"
-OPKG_ARGS += "${@['', '--add-exclude ' + ' --add-exclude '.join((d.getVar('PACKAGE_EXCLUDE') or "").split())][(d.getVar("PACKAGE_EXCLUDE") or "").strip() != ""]}"

 OPKGLIBDIR = "${localstatedir}/lib"

diff --git a/meta/lib/oe/package_manager.py b/meta/lib/oe/package_manager.py
index 06feb4d..ca66bdf 100644
--- a/meta/lib/oe/package_manager.py
+++ b/meta/lib/oe/package_manager.py
@@ -1160,6 +1160,21 @@  class OpkgPM(OpkgDpkgPM):
         self.deploy_lock_file = os.path.join(self.deploy_dir, "deploy.lock")
         self.opkg_cmd = bb.utils.which(os.getenv('PATH'), "opkg")
         self.opkg_args = "--volatile-cache -f %s -t %s -o %s " % (self.config_file, self.d.expand('${T}/ipktemp/') ,target_rootfs)
+
+        # Handle excluded packages here rather than at parsing time so we can expand out the
+        # PACKAGE_EXCLUDES at the runtime moment when pkgdata is available
+        def opkg_exclude_args(pkg_excludes):
+            remapped_pkg_excludes = []
+            for pkg in pkg_excludes:
+                pkg_data = oe.packagedata.read_subpkgdata(pkg, d)
+                rename_key = "PKG_{}".format(pkg)
+                if pkg_data and rename_key in pkg_data and pkg_data[rename_key] != pkg:
+                    remapped_pkg_excludes.append(pkg_data[rename_key])
+            pkg_excludes.extend(remapped_pkg_excludes)
+            pkg_excludes.sort()
+            return " --add-exclude " + " --add-exclude ".join(pkg_excludes)
+
+        self.opkg_args += opkg_exclude_args((d.getVar("PACKAGE_EXCLUDE") or "").split())
         self.opkg_args += self.d.getVar("OPKG_ARGS")

         if prepare_index:

Comments

Richard Purdie June 4, 2019, 4:27 p.m.
On Mon, 2019-06-03 at 16:42 +0000, Aditya Tayade wrote:
> From: Michael Ho <Michael.Ho@bmw.de>
> 
> The PACKAGE_EXCLUDE variable is used to pass a list of packages to be
> forbidden from installation with opkg. This list however does not
> account
> normally for the renaming of packages which can occur (for example
> when the
> debian bbclass is enabled, packages with libs are renamed from xxx to
> libxxx)
> and so expected excluded packages are not blocked.
> 
> Rather than tediously maintaining the PACKAGE_EXCLUDE variable to
> handle
> renamed packages that can dynamically change, move the expansion of
> the
> variable from parsing time to run time so it can use the pkgdata
> dictionaries
> to add automatically any renamed packages.
> 
> Upstream-Status: Pending
> 
> Signed-off-by: Michael Ho <Michael.Ho@bmw.de>
> Signed-off-by: Aditya.Tayade <Aditya.Tayade@kpit.com>

This seems to cause test failures:

https://autobuilder.yoctoproject.org/typhoon/#/builders/83/builds/197

(see the selftest failures).

Cheers,

Richard