aboutsummaryrefslogtreecommitdiffstats
path: root/package/base-files/files/lib/functions.sh
diff options
context:
space:
mode:
authorTony Ambardar <itugrok@yahoo.com>2018-03-02 20:04:36 -0800
committerJo-Philipp Wich <jo@mein.io>2018-11-29 11:52:56 +0100
commit8806da86f5da3b1b1e4d24259d168e2219c01a26 (patch)
treedba723153edc00e2725d28144b67c8a89524c705 /package/base-files/files/lib/functions.sh
parent5c9ad4fa6e57de5618952c89a2eb65436d7d0f85 (diff)
downloadupstream-8806da86f5da3b1b1e4d24259d168e2219c01a26.tar.gz
upstream-8806da86f5da3b1b1e4d24259d168e2219c01a26.tar.bz2
upstream-8806da86f5da3b1b1e4d24259d168e2219c01a26.zip
base-files: fix prerm return value, align with postinst code
The return value of a package prerm script is discarded and not returned correctly by default_prerm(). This allows other operations like service shutdown to "leak" their return value, prompting workarounds like commit 48cfc826 which do not address the root cause. Preserve a package prerm script return value for use by default_prerm(), sharing the corresponding code from default_postinst() for consistency. Also use consistent code for handling of /etc/init.d/ scripts. Run Tested on: LEDE 17.01.4 running ar71xx. Signed-off-by: Tony Ambardar <itugrok@yahoo.com>
Diffstat (limited to 'package/base-files/files/lib/functions.sh')
-rwxr-xr-xpackage/base-files/files/lib/functions.sh15
1 files changed, 10 insertions, 5 deletions
diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh
index 23598f9c74..50a7b40869 100755
--- a/package/base-files/files/lib/functions.sh
+++ b/package/base-files/files/lib/functions.sh
@@ -152,22 +152,27 @@ config_list_foreach() {
default_prerm() {
local root="${IPKG_INSTROOT}"
- local name
+ local pkgname="$(basename ${1%.*})"
+ local ret=0
- name=$(basename ${1%.*})
- [ -f "$root/usr/lib/opkg/info/${name}.prerm-pkg" ] && . "$root/usr/lib/opkg/info/${name}.prerm-pkg"
+ if [ -f "$root/usr/lib/opkg/info/${pkgname}.prerm-pkg" ]; then
+ ( . "$root/usr/lib/opkg/info/${pkgname}.prerm-pkg" )
+ ret=$?
+ fi
local shell="$(which bash)"
- for i in `cat "$root/usr/lib/opkg/info/${name}.list" | grep "^/etc/init.d/"`; do
+ for i in $(grep -s "^/etc/init.d/" "$root/usr/lib/opkg/info/${pkgname}.list"); do
if [ -n "$root" ]; then
${shell:-/bin/sh} "$root/etc/rc.common" "$root$i" disable
else
if [ "$PKG_UPGRADE" != "1" ]; then
"$i" disable
fi
- "$i" stop || /bin/true
+ "$i" stop
fi
done
+
+ return $ret
}
add_group_and_user() {