[oe-commits] Martin Jansa : Use most recently added alternative if there is more alternatives with the same highest priority

git version control git at git.openembedded.org
Fri Sep 18 08:50:41 UTC 2009


Module: openembedded.git
Branch: shr/import
Commit: 9e889404cce6d62866c625b02f3da6bcc71aa0ef
URL:    http://gitweb.openembedded.net/?p=openembedded.git&a=commit;h=9e889404cce6d62866c625b02f3da6bcc71aa0ef

Author: Martin Jansa <martin.jansa at gmail.com>
Date:   Thu Sep 17 14:02:15 2009 +0000

Use most recently added alternative if there is more alternatives with the same highest priority

Signed-off-by: Klaus Kurzmann <mok at fluxnetz.de>

---

 .../update-alternatives-cworth.inc                 |    3 +-
 .../update-alternatives.use.last.patch             |   24 ++++++++++++++++++++
 .../update-alternatives-cworth_0.99.154.bb         |    2 +
 3 files changed, 28 insertions(+), 1 deletions(-)

diff --git a/recipes/update-alternatives/update-alternatives-cworth.inc b/recipes/update-alternatives/update-alternatives-cworth.inc
index f23bfe8..3c1b2e6 100644
--- a/recipes/update-alternatives/update-alternatives-cworth.inc
+++ b/recipes/update-alternatives/update-alternatives-cworth.inc
@@ -1,6 +1,7 @@
 LICENSE = "GPL"
 SECTION = "base"
-SRC_URI = "${HANDHELDS_CVS};module=familiar/dist/ipkg;tag=${@'V' + bb.data.getVar('PV',d,1).replace('.', '-')}"
+SRC_URI = "${HANDHELDS_CVS};module=familiar/dist/ipkg;tag=${@'V' + bb.data.getVar('PV',d,1).replace('.', '-')} \
+           file://update-alternatives.use.last.patch;patch=1"
 S = "${WORKDIR}/ipkg/C"
 PACKAGE_ARCH = "all"
 
diff --git a/recipes/update-alternatives/update-alternatives-cworth/update-alternatives.use.last.patch b/recipes/update-alternatives/update-alternatives-cworth/update-alternatives.use.last.patch
new file mode 100644
index 0000000..1c1fbea
--- /dev/null
+++ b/recipes/update-alternatives/update-alternatives-cworth/update-alternatives.use.last.patch
@@ -0,0 +1,24 @@
+diff -uNr C.orig/update-alternatives C/update-alternatives
+--- C.orig/update-alternatives	2003-03-28 17:39:45.000000000 +0100
++++ C/update-alternatives	2009-09-17 16:46:59.000000000 +0200
+@@ -97,8 +97,8 @@
+ 
+ ##	path=`sed -ne "1!p" $ad/$name | sort -nr -k2 | head -1 | sed 's/ .*//'`
+ ## busybox safe:
+-	path=`sed -ne "1!p" $ad/$name | sed -e "s/\(.*\) \(.*\)/\2 \1/g" | sort -nr | head -n 1 | sed 's/[^ ]* //'`
+-	if [ -z "$path" ]; then
++	prio=`sed -ne "1!p" $ad/$name | sed -e "s/\(.*\) \(.*\)/\2 \1/g" | sort -nr | head -n 1 | sed 's/ [^ ]*$//'`
++	if [ -z "$prio" ]; then
+ 		echo "update-alternatives: removing $link as no more alternatives exist for it"
+ 		rm $ad/$name
+ 		if [ -L $link ]; then
+@@ -107,6 +107,9 @@
+ 		return 0
+ 	fi
+ 
++	## find last line with highest priority
++	path=`grep "${prio}$" $ad/$name | tail -n 1 | sed 's/ [^ ]*$//'`
++
+ 	if [ ! -e $link -o -L $link ]; then
+ 		local link_dir=`dirname $link`
+ 		if [ ! -d $link_dir ]; then
diff --git a/recipes/update-alternatives/update-alternatives-cworth_0.99.154.bb b/recipes/update-alternatives/update-alternatives-cworth_0.99.154.bb
index 6cab1e5..c260e40 100644
--- a/recipes/update-alternatives/update-alternatives-cworth_0.99.154.bb
+++ b/recipes/update-alternatives/update-alternatives-cworth_0.99.154.bb
@@ -2,6 +2,8 @@ require update-alternatives-cworth.inc
 
 RPROVIDES_${PN} = "update-alternatives"
 
+PR="r2"
+
 do_install () {
     install -d ${D}${sbindir} \
                ${D}${sysconfdir}/alternatives \





More information about the Openembedded-commits mailing list