]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
package_manager/deb: implement BAD_RECOMMENDATIONS
authorAndreas Oberritter <obi@opendreambox.org>
Mon, 25 Aug 2014 23:59:03 +0000 (01:59 +0200)
committerAndreas Oberritter <obi@opendreambox.org>
Tue, 17 Oct 2017 02:38:26 +0000 (04:38 +0200)
Signed-off-by: Andreas Oberritter <obi@opendreambox.org>
meta/classes/rootfs_deb.bbclass
meta/lib/oe/package_manager.py
meta/lib/oe/rootfs.py

index f79fca608e3523430786983fd4734655b02608a8..18d0b83b1b507783e8794a348ade9115bdbf4063 100644 (file)
@@ -13,12 +13,6 @@ do_rootfs[vardeps] += "PACKAGE_FEED_URIS"
 do_rootfs[lockfiles] += "${DEPLOY_DIR_DEB}/deb.lock"
 do_populate_sdk[lockfiles] += "${DEPLOY_DIR_DEB}/deb.lock"
 
-python rootfs_deb_bad_recommendations() {
-    if d.getVar("BAD_RECOMMENDATIONS", True):
-        bb.warn("Debian package install does not support BAD_RECOMMENDATIONS")
-}
-do_rootfs[prefuncs] += "rootfs_deb_bad_recommendations"
-
 DEB_POSTPROCESS_COMMANDS = ""
 
 opkglibdir = "${localstatedir}/lib/opkg"
index 3733bd7ff7442993c35c4ba4b2b6aacec5603643..eef25491d954c7bedd8d1f6025e62ccc31ec50e5 100644 (file)
@@ -1966,6 +1966,32 @@ class DpkgPM(PackageManager):
     def list_installed(self):
         return DpkgPkgsList(self.d, self.target_rootfs).list_pkgs()
 
+    def handle_bad_recommendations(self):
+        bad_recommendations = (self.d.getVar("BAD_RECOMMENDATIONS", True) or "").strip()
+        if not bad_recommendations:
+            return
+
+        status_file = self.target_rootfs + "/var/lib/dpkg/status"
+
+        with open(status_file + ".tmp", "w") as status:
+            for pkg in bad_recommendations.split():
+                pkg_info = ('apt-cache', 'show', pkg)
+
+                try:
+                    output = subprocess.check_output(pkg_info, stderr=subprocess.STDOUT)
+                except subprocess.CalledProcessError as e:
+                    bb.fatal("Cannot get package info. Command '%s' "
+                             "returned %d:\n%s" % (' '.join(pkg_info), e.returncode, e.output))
+
+                for line in output.splitlines():
+                    if not line:
+                        status.write("Status: hold ok not-installed\n\n")
+                        break
+
+                    if line.startswith(' ') or line.split(': ', 1)[0] not in ('Filename', 'Size', 'MD5sum', 'MSDOS-Filename'):
+                        status.write(line + "\n")
+
+        os.rename(status_file + ".tmp", status_file)
 
 def generate_index_files(d):
     classes = d.getVar('PACKAGE_CLASSES', True).replace("package_", "").split()
index 19eef900ae1c9a52492a2e576cc5813530fa8543..9c3e30a2d8c290e6ba94612071787ff9d23ac6d7 100644 (file)
@@ -652,6 +652,8 @@ class DpkgRootfs(DpkgOpkgRootfs):
 
         self.pm.update()
 
+        self.pm.handle_bad_recommendations()
+
         for pkg_type in self.install_order:
             if pkg_type in pkgs_to_install:
                 self.pm.install(pkgs_to_install[pkg_type],