functions.sh: fix default_postinst function

When we run "opkg install" on a package that installs an uci-defaults
script, functions.sh will fail to evaluate that script in its
default_postinst function.

This happens because there is no "./" present and it searches for the
file in paths specified by the PATH variable. This would work on bash,
but it will not work on ash and some other shells like sh, zsh. This
applys to the ". filename" directive used in this case.

This patch will make the path relative to the /etc/uci-defaults
directory.

Fixes: FS#1021

Signed-off-by: Marko Ratkaj <marko.ratkaj@sartura.hr>
lede-17.01
Marko Ratkaj 2017-11-07 06:48:09 +01:00 committed by Mathias Kresin
parent 6b6578feec
commit a0ef1c478a
1 changed files with 1 additions and 1 deletions

View File

@ -240,7 +240,7 @@ default_postinst() {
[ -d /tmp/.uci ] || mkdir -p /tmp/.uci [ -d /tmp/.uci ] || mkdir -p /tmp/.uci
for i in $(sed -ne 's!^/etc/uci-defaults/!!p' "/usr/lib/opkg/info/${pkgname}.list"); do ( for i in $(sed -ne 's!^/etc/uci-defaults/!!p' "/usr/lib/opkg/info/${pkgname}.list"); do (
cd /etc/uci-defaults cd /etc/uci-defaults
[ -f "$i" ] && . "$i" && rm -f "$i" [ -f "$i" ] && . ./"$i" && rm -f "$i"
) done ) done
uci commit uci commit
fi fi