base-files: add support for overlaying rootfs content
[openwrt/staging/chunkeey.git] / package / base-files / files / lib / functions.sh
index 232a1c4ed250a71ffe7a78f3864d415a49b94550..b68db6b6bd7e419627b8330f5bf31a780f817561 100755 (executable)
@@ -175,8 +175,10 @@ default_prerm() {
                if [ -n "$root" ]; then
                        ${shell:-/bin/sh} "$root/etc/rc.common" "$root$i" disable
                else
-                       "$i" disable
-                       "$i" stop
+                       if [ "$PKG_UPGRADE" != "1" ]; then
+                               "$i" disable
+                       fi
+                       "$i" stop || /bin/true
                fi
        done
 }
@@ -228,6 +230,11 @@ default_postinst() {
                ret=$?
        fi
 
+       if [ -d "$root/rootfs-overlay" ]; then
+               cp -R $root/rootfs-overlay/. $root/
+               rm -fR $root/rootfs-overlay/
+       fi
+
        if [ -z "$root" ] && grep -q -s "^/etc/uci-defaults/" "/usr/lib/opkg/info/${pkgname}.list"; then
                . /lib/functions/system.sh
                [ -d /tmp/.uci ] || mkdir -p /tmp/.uci
@@ -240,17 +247,17 @@ default_postinst() {
 
        [ -n "$root" ] || rm -f /tmp/luci-indexcache 2>/dev/null
 
-       if [ "$PKG_UPGRADE" != "1" ]; then
-               local shell="$(which bash)"
-               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" enable
-                       else
+       local shell="$(which bash)"
+       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" enable
+               else
+                       if [ "$PKG_UPGRADE" != "1" ]; then
                                "$i" enable
-                               "$i" start
                        fi
-               done
-       fi
+                       "$i" start
+               fi
+       done
 
        return $ret
 }