Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Mark Hatle <mark.hatle@windriver.com>
To: <openembedded-core@lists.openembedded.org>
Subject: [PATCH 6/6 v2] package_rpm: Allow translation of requirement to package name
Date: Tue, 12 Nov 2013 19:59:20 -0600	[thread overview]
Message-ID: <1384307965-10290-2-git-send-email-mark.hatle@windriver.com> (raw)
In-Reply-To: <cover.1384305535.git.mark.hatle@windriver.com>

In the translate oe to smart function, we only translated package names.
However, it's allowed that people can put in a dependency name in the
IMAGE_INSTALL.  So on a failure to translate a package name, we fall back
and attempt to resolve based on a package's provide.

Note: it may be possible to generate an unsolvable install solution.  If the
dependency is provided by one or more things that conflict with something else
set to be installed.  We can't determine this until smart is run.

If this occurs, file a bug and we'll have to identify a way to deal with the
RCONFLICTS and RREPLACES.  As a workaround replace the conflict REQUIRES with
actual package names.

Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
---
 meta/classes/package_rpm.bbclass | 79 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 75 insertions(+), 4 deletions(-)

diff --git a/meta/classes/package_rpm.bbclass b/meta/classes/package_rpm.bbclass
index 31265d9..9fe0e6c 100644
--- a/meta/classes/package_rpm.bbclass
+++ b/meta/classes/package_rpm.bbclass
@@ -166,6 +166,7 @@ translate_oe_to_smart() {
 	[ ! -e ${target_rootfs}/install/tmp/fullpkglist.query ] && smart --data-dir=${target_rootfs}/var/lib/smart query --output ${target_rootfs}/install/tmp/fullpkglist.query
 
 	pkgs_to_install=""
+	not_found=""
 	for pkg in "$@" ; do
 		new_pkg="$pkg"
 		if [ -z "$sdk_mode" ]; then
@@ -184,7 +185,6 @@ translate_oe_to_smart() {
 				fi
 				subst=${pkg#${mlib}-}
 				if [ "$subst" != "$pkg" ]; then
-					feeds=$@
 					while [ -n "$1" ]; do
 						arch="$1"
 						arch=`echo "$arch" | tr - _`
@@ -197,6 +197,76 @@ translate_oe_to_smart() {
 					done
 					if [ "$pkg" = "$new_pkg" ]; then
 						# Failed to translate, package not found!
+						not_found="$not_found $pkg"
+						continue
+					fi
+				fi
+			done
+		fi
+		# Apparently not a multilib package...
+		if [ "$pkg" = "$new_pkg" ]; then
+			default_archs_fixed=`echo "$default_archs" | tr - _`
+			for arch in $default_archs_fixed ; do
+				if grep -q '^'$pkg'-[^-]*-[^-]*@'$arch'$' ${target_rootfs}/install/tmp/fullpkglist.query ; then
+					new_pkg="$pkg@$arch"
+					# First found is best match
+					break
+				fi
+			done
+			if [ "$pkg" = "$new_pkg" ]; then
+				# Failed to translate, package not found!
+				not_found="$not_found $pkg"
+				continue
+			fi
+		fi
+		#echo "$pkg -> $new_pkg" >&2
+		pkgs_to_install="${pkgs_to_install} ${new_pkg}"
+	done
+
+	# Parse the not_found items and see if they were dependencies (RPROVIDES)
+	# Follow the parsing example above...
+	for pkg in $not_found ; do
+		new_pkg="$pkg"
+		smart --data-dir=${target_rootfs}/var/lib/smart query --provides=$pkg --output ${target_rootfs}/install/tmp/provide.query
+		grep '^[^@ ]*@[^@]*$' ${target_rootfs}/install/tmp/provide.query | sed -e 's,\(.*\)-[^-]*-[^-]*\(@[^@]*\)$,\1\2,' > ${target_rootfs}/install/tmp/provide.query.list || :
+		prov=`echo $pkgs_to_install | xargs -n 1 echo | grep -f ${target_rootfs}/install/tmp/provide.query.list || :`
+		if [ -n "$prov" ]; then
+			# Nothing to do, already in the list
+			#echo "Skipping $pkg -> $prov, already in install set" >&2
+			continue
+		fi
+		if [ -z "$sdk_mode" ]; then
+			for i in ${MULTILIB_PREFIX_LIST} ; do
+				old_IFS="$IFS"
+				IFS=":"
+				set $i
+				IFS="$old_IFS"
+				mlib="$1"
+				shift
+				if [ "$mlib" = "default" ]; then
+					if [ -z "$default_archs" ]; then
+						default_archs=$@
+					fi
+					continue
+				fi
+				subst=${pkg#${mlib}-}
+				if [ "$subst" != "$pkg" ]; then
+					feeds=$@
+					smart --data-dir=${target_rootfs}/var/lib/smart query --provides=$subst --output ${target_rootfs}/install/tmp/provide.query
+					grep '^[^@ ]*@[^@]*$' ${target_rootfs}/install/tmp/provide.query | sed -e 's,\(.*\)-[^-]*-[^-]*\(@[^@]*\)$,\1\2,' > ${target_rootfs}/install/tmp/provide.query.list || :
+					while [ -n "$1" ]; do
+						arch="$1"
+						arch=`echo "$arch" | tr - _`
+						shift
+						# Select first found, we don't know if one is better then another...
+						prov=`grep '^[^@ ]*@'$arch'$' ${target_rootfs}/install/tmp/provide.query.list | head -n 1`
+						if [ -n "$prov" ]; then
+							new_pkg=$prov
+							break
+						fi
+					done
+					if [ "$pkg" = "$new_pkg" ]; then
+						# Failed to translate, package not found!
 						echo "$attemptonly: $pkg not found in the $mlib feeds ($feeds)." >&2
 						if [ "$attemptonly" = "Error" ]; then
 							exit 1
@@ -210,9 +280,10 @@ translate_oe_to_smart() {
 		if [ "$pkg" = "$new_pkg" ]; then
 			default_archs_fixed=`echo "$default_archs" | tr - _`
 			for arch in $default_archs_fixed ; do
-				if grep -q '^'$pkg'-[^-]*-[^-]*@'$arch'$' ${target_rootfs}/install/tmp/fullpkglist.query ; then
-					new_pkg="$pkg@$arch"
-					# First found is best match
+				# Select first found, we don't know if one is better then another...
+				prov=`grep '^[^@ ]*@'$arch'$' ${target_rootfs}/install/tmp/provide.query.list | head -n 1`
+				if [ -n "$prov" ]; then
+					new_pkg=$prov
 					break
 				fi
 			done
-- 
1.8.1.2.545.g2f19ada



  parent reply	other threads:[~2013-11-13  1:59 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-13  1:23 [PATCH 0/6] Misc changes relating to toolchain and image gen Mark Hatle
2013-11-13  1:23 ` [PATCH 1/6] gcc: Use alternatives for the *-symlinks packages Mark Hatle
2013-11-13  2:24   ` Otavio Salvador
2013-11-13  2:27     ` Mark Hatle
2013-11-13  2:28       ` Otavio Salvador
2013-11-13  1:23 ` [PATCH 2/6] gcc: Drop *-symlinks Mark Hatle
2013-11-13  1:23 ` [PATCH 3/6] binutils: Ensure old -symlinks packages get removed Mark Hatle
2013-11-13  8:12   ` Martin Jansa
2013-11-13 11:14     ` Phil Blundell
2013-11-13 13:39       ` Mark Hatle
2013-11-13 13:44         ` Phil Blundell
2013-11-13  1:23 ` [PATCH 4/6] packagegroups: Remove toolchain *-symlinks packages Mark Hatle
2013-11-13  1:23 ` [PATCH 5/6] packagegroup-self-hosted: Use packagegroup-core-buildessentials Mark Hatle
2013-11-13  1:23 ` [PATCH 6/6] package_rpm: Allow translation of requirement to package name Mark Hatle
2013-11-13  1:33 ` [PATCH 0/6] Misc changes relating to toolchain and image gen Otavio Salvador
2013-11-13  2:01   ` Mark Hatle
2013-11-13  3:42     ` Mark Hatle
2013-11-13  1:59 ` [PATCH 5/6 v2] packagegroup-self-hosted: Use packagegroup-core-buildessential Mark Hatle
2013-11-13  1:59 ` Mark Hatle [this message]
2013-11-13 10:33   ` [PATCH 6/6 v2] package_rpm: Allow translation of requirement to package name Paul Eggleton
2013-11-13 12:31     ` Otavio Salvador
2013-11-13 13:12     ` Mark Hatle
2013-11-15 14:02   ` Richard Purdie
2013-11-15 17:15     ` Mark Hatle
2013-11-13 14:19 ` [PATCH 2/6 v3] gcc: Drop *-symlinks Mark Hatle
2013-11-13 14:19 ` [PATCH 3/6 v3] binutils: Ensure old -symlinks packages get removed Mark Hatle
2013-11-19  0:40 ` [PATCH 0/6] Misc changes relating to toolchain and image gen Saul Wold

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1384307965-10290-2-git-send-email-mark.hatle@windriver.com \
    --to=mark.hatle@windriver.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox