[LEDE-DEV] [PATCH 10/12] base-files: add update-alternatives call to default_{postinst, prerm}
Yousong Zhou
yszhou4tech at gmail.com
Sun Mar 5 01:31:41 PST 2017
Signed-off-by: Yousong Zhou <yszhou4tech at gmail.com>
---
package/base-files/Makefile | 2 +-
package/base-files/files/lib/functions.sh | 18 ++++++++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/package/base-files/Makefile b/package/base-files/Makefile
index 99a10ff..7dde9e1 100644
--- a/package/base-files/Makefile
+++ b/package/base-files/Makefile
@@ -11,7 +11,7 @@ include $(INCLUDE_DIR)/kernel.mk
include $(INCLUDE_DIR)/version.mk
PKG_NAME:=base-files
-PKG_RELEASE:=172
+PKG_RELEASE:=173
PKG_FLAGS:=nonshared
PKG_FILE_DEPENDS:=$(PLATFORM_DIR)/ $(GENERIC_PLATFORM_DIR)/base-files/
diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh
index de3fa96..42c4f6c 100755
--- a/package/base-files/files/lib/functions.sh
+++ b/package/base-files/files/lib/functions.sh
@@ -168,6 +168,7 @@ default_prerm() {
name=$(basename ${1%.*})
[ -f "$root/usr/lib/opkg/info/${name}.prerm-pkg" ] && . "$root/usr/lib/opkg/info/${name}.prerm-pkg"
+ check_update_alternatives remove "${name}"
local shell="$(which bash)"
for i in `cat "$root/usr/lib/opkg/info/${name}.list" | grep "^/etc/init.d/"`; do
@@ -217,12 +218,29 @@ add_group_and_user() {
fi
}
+check_update_alternatives() {
+ local cmd="$1"
+ local pkgname="$2"
+ local altspecs="$(sed -ne 's/^Alternatives: *//p' $root/usr/lib/opkg/info/${pkgname}.control 2>/dev/null)"
+ local spec
+ local oIFS
+ local shell="$(which bash)"
+
+ shell="${shell:-/bin/sh}"
+ oIFS="$IFS"; IFS=", "
+ for spec in $altspecs; do
+ $shell ${IPKG_INSTROOT}/usr/sbin/update-alternatives "$cmd" --spec "$spec"
+ done
+ IFS="$oIFS"
+}
+
default_postinst() {
local root="${IPKG_INSTROOT}"
local pkgname="$(basename ${1%.*})"
local ret=0
add_group_and_user "${pkgname}"
+ check_update_alternatives update "${pkgname}"
if [ -f "$root/usr/lib/opkg/info/${pkgname}.postinst-pkg" ]; then
( . "$root/usr/lib/opkg/info/${pkgname}.postinst-pkg" )
--
2.6.4
More information about the Lede-dev
mailing list