base-files: default_postinst: propagate the real postinst return code
[openwrt/svn-archive/archive.git] / package / base-files / files / lib / functions.sh
index 72d954db3cb7bb6cb215df94e4b24c4c1bd10e8f..2f78d67025d0f52968fb47d6ee60a8b1163b5e6a 100755 (executable)
@@ -165,7 +165,7 @@ insert_modules() {
 
 default_prerm() {
        local name
-       name=$(echo $(basename $1) | cut -d. -f1)
+       name=$(basename ${1%.*})
        [ -f /usr/lib/opkg/info/${name}.prerm-pkg ] && . /usr/lib/opkg/info/${name}.prerm-pkg
        for i in `cat /usr/lib/opkg/info/${name}.list | grep "^/etc/init.d/"`; do
                $i disable
@@ -174,8 +174,9 @@ default_prerm() {
 }
 
 default_postinst() {
-       local pkgname rusers
-       pkgname=$(echo $(basename $1) | cut -d. -f1)
+       local pkgname rusers ret
+       ret=0
+       pkgname=$(basename ${1%.*})
        rusers=$(grep "Require-User:" ${IPKG_INSTROOT}/usr/lib/opkg/info/${pkgname}.control)
        [ -n "$rusers" ] && {
                local user group uid gid
@@ -215,7 +216,10 @@ default_postinst() {
                done
        }
 
-       [ -f ${IPKG_INSTROOT}/usr/lib/opkg/info/${pkgname}.postinst-pkg ] && ( . ${IPKG_INSTROOT}/usr/lib/opkg/info/${pkgname}.postinst-pkg )
+       if [ -f ${IPKG_INSTROOT}/usr/lib/opkg/info/${pkgname}.postinst-pkg ]; then
+               ( . ${IPKG_INSTROOT}/usr/lib/opkg/info/${pkgname}.postinst-pkg )
+               ret=$?
+       fi
        [ -n "${IPKG_INSTROOT}" ] || rm -f /tmp/luci-indexcache 2>/dev/null
 
        [ "$PKG_UPGRADE" = "1" ] || for i in `cat ${IPKG_INSTROOT}/usr/lib/opkg/info/${pkgname}.list | grep "^/etc/init.d/"`; do
@@ -225,7 +229,7 @@ default_postinst() {
                        $i start
                }
        done
-       return 0
+       return $ret
 }
 
 include() {