Patchwork [04/17] grep: Use update-alternatives

login
register
mail settings
Submitter Mark Hatle
Date April 16, 2012, 10:45 p.m.
Message ID <e4178ec1b28712fd0e491f18bed5a3d6eb6ad261.1334616144.git.mark.hatle@windriver.com>
Download mbox | patch
Permalink /patch/25989/
State New
Headers show

Comments

Mark Hatle - April 16, 2012, 10:45 p.m.
Use ALTERNATIVE_LINKS to be sure the links and provide info is setup
properly.

Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
---
 meta/recipes-extended/grep/grep_2.5.1a.bb |   25 +++++++++----------------
 meta/recipes-extended/grep/grep_2.9.bb    |   22 ++++++++--------------
 2 files changed, 17 insertions(+), 30 deletions(-)

Patch

diff --git a/meta/recipes-extended/grep/grep_2.5.1a.bb b/meta/recipes-extended/grep/grep_2.5.1a.bb
index 64064fc..332a4d0 100644
--- a/meta/recipes-extended/grep/grep_2.5.1a.bb
+++ b/meta/recipes-extended/grep/grep_2.5.1a.bb
@@ -5,7 +5,7 @@  SECTION = "console/utils"
 LICENSE = "GPLv2"
 LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3"
 
-PR = "r1"
+PR = "r2"
 
 SRC_URI = "${GNU_MIRROR}/grep/grep-${PV}.tar.bz2 \
            file://uclibc-fix.patch"
@@ -21,23 +21,16 @@  do_configure_prepend () {
 	rm -f ${S}/m4/init.m4
 }
 
+inherit update-alternatives
+
+ALTERNATIVE_LINKS = "${base_bindir}/grep ${base_bindir}/egrep ${base_bindir}/fgrep"
+ALTERNATIVE_PRIORITY = "100"
+
 do_install () {
 	autotools_do_install
 	install -d ${D}${base_bindir}
-	mv ${D}${bindir}/grep ${D}${base_bindir}/grep.${PN}
-	mv ${D}${bindir}/egrep ${D}${base_bindir}/egrep.${PN}
-	mv ${D}${bindir}/fgrep ${D}${base_bindir}/fgrep.${PN}
+	mv ${D}${bindir}/grep ${D}${base_bindir}/grep
+	mv ${D}${bindir}/egrep ${D}${base_bindir}/egrep
+	mv ${D}${bindir}/fgrep ${D}${base_bindir}/fgrep
 	rmdir ${D}${bindir}/
 }
-
-pkg_postinst_${PN} () {
-	update-alternatives --install ${base_bindir}/grep grep grep.${PN} 100
-	update-alternatives --install ${base_bindir}/egrep egrep egrep.${PN} 100
-	update-alternatives --install ${base_bindir}/fgrep fgrep fgrep.${PN} 100
-}
-
-pkg_prerm_${PN} () {
-	update-alternatives --remove grep grep.${PN}
-	update-alternatives --remove egrep egrep.${PN}
-	update-alternatives --remove fgrep fgrep.${PN}
-}
diff --git a/meta/recipes-extended/grep/grep_2.9.bb b/meta/recipes-extended/grep/grep_2.9.bb
index 1bc79f2..7710e65 100644
--- a/meta/recipes-extended/grep/grep_2.9.bb
+++ b/meta/recipes-extended/grep/grep_2.9.bb
@@ -21,23 +21,17 @@  do_configure_prepend () {
 	rm -f ${S}/m4/init.m4
 }
 
+inherit update-alternatives
+
+ALTERNATIVE_LINKS = "${base_bindir}/grep ${base_bindir}/egrep ${base_bindir}/fgrep"
+ALTERNATIVE_PRIORITY = "100"
+
 do_install () {
 	autotools_do_install
 	install -d ${D}${base_bindir}
-	mv ${D}${bindir}/grep ${D}${base_bindir}/grep.${PN}
-	mv ${D}${bindir}/egrep ${D}${base_bindir}/egrep.${PN}
-	mv ${D}${bindir}/fgrep ${D}${base_bindir}/fgrep.${PN}
+	mv ${D}${bindir}/grep ${D}${base_bindir}/grep
+	mv ${D}${bindir}/egrep ${D}${base_bindir}/egrep
+	mv ${D}${bindir}/fgrep ${D}${base_bindir}/fgrep
 	rmdir ${D}${bindir}/
 }
 
-pkg_postinst_${PN} () {
-	update-alternatives --install ${base_bindir}/grep grep grep.${PN} 100
-	update-alternatives --install ${base_bindir}/egrep egrep egrep.${PN} 100
-	update-alternatives --install ${base_bindir}/fgrep fgrep fgrep.${PN} 100
-}
-
-pkg_prerm_${PN} () {
-	update-alternatives --remove grep grep.${PN}
-	update-alternatives --remove egrep egrep.${PN}
-	update-alternatives --remove fgrep fgrep.${PN}
-}