This fixes a problem that's causing an early return of
default_prerm() when the package prerm script has an
exit statement at the end, which is implemented as
"exit 0" by most of the packages that use prerm

With the new behavior, the execution of default_prerm()
will continue only if the prerm script returns 0,
otherwise the function will return the error code

Additionally, this makes the execution consistent with
the postinst script

Signed-off-by: Luis Araneda <[email protected]>
---
Compile and run tested on ipq40xx

---
 package/base-files/files/lib/functions.sh | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/package/base-files/files/lib/functions.sh 
b/package/base-files/files/lib/functions.sh
index 318e91856b..579aa93dca 100755
--- a/package/base-files/files/lib/functions.sh
+++ b/package/base-files/files/lib/functions.sh
@@ -153,9 +153,14 @@ config_list_foreach() {
 default_prerm() {
        local root="${IPKG_INSTROOT}"
        local name
+       local ret
 
        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/${name}.prerm-pkg" ]; then
+               ( . "$root/usr/lib/opkg/info/${name}.prerm-pkg" )
+               ret=$?
+               [ $ret -ne 0 ] && return $ret
+       fi
 
        local shell="$(which bash)"
        for i in `cat "$root/usr/lib/opkg/info/${name}.list" | grep 
"^/etc/init.d/"`; do
-- 
2.18.0


_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to