From: Yousong Zhou Date: Sat, 4 Mar 2017 11:36:53 +0000 (+0800) Subject: base-files: add update-alternatives call to default_{postinst,prerm} X-Git-Url: http://git.openwrt.org/?p=openwrt%2Fstaging%2Fyousong.git;a=commitdiff_plain;h=c33adedccde70b045570f214cb639bdc4ad7a075 base-files: add update-alternatives call to default_{postinst,prerm} Signed-off-by: Yousong Zhou --- diff --git a/package/base-files/Makefile b/package/base-files/Makefile index 99a10ffba6..7dde9e19d9 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 de3fa96730..42c4f6c085 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" )