From 758da30df2ca3abbdad24c972f590eaa40e70930 Mon Sep 17 00:00:00 2001 From: Martin Jansa Date: Wed, 18 Nov 2009 03:53:23 +0000 Subject: update-alternatives-cworth: use latest installed alternative * if there is more alternatives with higest priority, use the one last in alternatives file (latest installed) * if target exists and its directory, remove link, otherwise new alternative link is created inside that direstory Signed-off-by: Martin Jansa --- .../update-alternatives-cworth-native_0.99.154.bb | 2 ++ .../update-alternatives-cworth.inc | 5 ++-- .../update-alternatives.use.last.patch | 34 ++++++++++++++++++++++ .../update-alternatives-cworth_0.99.154.bb | 2 ++ 4 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 recipes/update-alternatives/update-alternatives-cworth/update-alternatives.use.last.patch (limited to 'recipes/update-alternatives') diff --git a/recipes/update-alternatives/update-alternatives-cworth-native_0.99.154.bb b/recipes/update-alternatives/update-alternatives-cworth-native_0.99.154.bb index 40534b4bb4..455831cf1f 100644 --- a/recipes/update-alternatives/update-alternatives-cworth-native_0.99.154.bb +++ b/recipes/update-alternatives/update-alternatives-cworth-native_0.99.154.bb @@ -3,6 +3,8 @@ inherit native PROVIDES += "virtual/update-alternatives-native" +PR = "${INC_PR}.0" + do_stage () { install -d ${sbindir} \ ${libdir}/opkg/alternatives diff --git a/recipes/update-alternatives/update-alternatives-cworth.inc b/recipes/update-alternatives/update-alternatives-cworth.inc index f23bfe8bb4..2d8fd42c0c 100644 --- a/recipes/update-alternatives/update-alternatives-cworth.inc +++ b/recipes/update-alternatives/update-alternatives-cworth.inc @@ -1,7 +1,8 @@ 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" -PR = "r1" +INC_PR = "r3" 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 0000000000..7bd5bd268b --- /dev/null +++ b/recipes/update-alternatives/update-alternatives-cworth/update-alternatives.use.last.patch @@ -0,0 +1,34 @@ +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,11 +107,19 @@ + 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 + mkdir -p $link_dir + fi ++ if [ -h $link -a -d $link ]; then ++ # if $link exists and the target is directory, than ln -sf $path $link, doesn't replace link to that directory, but creates new link inside ++ echo "update-alternatives: Removing $link" ++ rm -f $link ++ fi + ln -sf $path $link + echo "update-alternatives: Linking $link to $path" + else 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 6cab1e55ec..b95d6d5ff2 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="${INC_PR}.0" + do_install () { install -d ${D}${sbindir} \ ${D}${sysconfdir}/alternatives \ -- cgit v1.2.3