Patchwork rootfs_ipkg: fix BAD_RECOMMENDATIONS handling

login
register
mail settings
Submitter Ross Burton
Date Feb. 19, 2013, 9:31 p.m.
Message ID <1361309512-4367-1-git-send-email-ross.burton@intel.com>
Download mbox | patch
Permalink /patch/44873/
State Accepted
Commit 6bf55c6e67b371c0467ae1be4d7f713d6a3dcf3b
Headers show

Comments

Ross Burton - Feb. 19, 2013, 9:31 p.m.
If multiple versions of the same package are in the package feed then the
generate status file would only contains a "deinstall" status for the last one,
which meant that BAD_RECOMMENDATIONS wouldn't actually work.

Use awk instead of grep and stop reading when we reach a newline, so we only
ever output a single stanza.

Signed-off-by: Ross Burton <ross.burton@intel.com>
---
 meta/classes/rootfs_ipk.bbclass |   10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Patch

diff --git a/meta/classes/rootfs_ipk.bbclass b/meta/classes/rootfs_ipk.bbclass
index 135bb60..a609944 100644
--- a/meta/classes/rootfs_ipk.bbclass
+++ b/meta/classes/rootfs_ipk.bbclass
@@ -46,9 +46,13 @@  fakeroot rootfs_ipk_do_rootfs () {
 	for i in ${BAD_RECOMMENDATIONS}; do
 		pkginfo="`opkg-cl ${OPKG_ARGS} info $i`"
 		if [ ! -z "$pkginfo" ]; then
-			echo "$pkginfo" | grep -e '^Package:' -e '^Architecture:' -e '^Version:' >> $STATUS
-			echo "Status: deinstall hold not-installed" >> $STATUS
-			echo >> $STATUS
+			# Take just the first package stanza as otherwise only
+			# the last one will have the right Status line.
+			echo "$pkginfo" | awk "/^Package:/ { print } \
+                        		       /^Architecture:/ { print } \
+                        		       /^Version:/ { print } \
+                        		       /^$/ { exit } \
+                        		       END { print \"Status: deinstall hold not-installed\n\" }" - >> $STATUS
 		else
 			echo "Requested ignored recommendation $i is not a package"
 		fi