openwrtv3/package
Tony Ambardar 4097ab6a97 base-files: fix postinstall uci-defaults removal
Commit 7f694582 introduced a bug where default_postinst() often fails to
remove a uci-defaults script after application, leaving it to run again
after a reboot.
(Note: commit 7f694582 also introduced FS#1021, now fixed by 73c745f6)

The subtle problem arises from the shell logical chain:
[ -f "$i" ] && . "$i" && rm -f "$i"

Most uci-defaults scripts contain a terminal 'exit 0' statement which,
when sourced, results in the logic chain exiting before executing 'rm -f'.
This was observed while testing upgrades of 'luci-app-sqm'.

The solution is to wrap the shell sourcing in a subshell relative to the
command 'rm -f':
( [ -f "$i" ] && . "$i" ) && rm -f "$i"

Revert to using 'grep' to prefilter the list of entries from the control
file, which yields the full path of uci-defaults scripts. This allows
keeping the existence check, directory change and script sourcing inside
the subshell, with the script removal correctly outside.

This approach avoids adding a second subshell only around the "." (source)
command. The change also preserves the fix FS#1021, since the full path is
used to source the script, which is POSIX-portable irrespective of PATH
variable or reference to the CWD.

Run Tested on: LEDE 17.01.4 running ar71xx, while tracing installation of
package luci-app-sqm with its associated /etc/uci-defaults/luci-sqm file.

Signed-off-by: Tony Ambardar <itugrok@yahoo.com>
2018-09-24 18:58:00 +02:00
..
base-files base-files: fix postinstall uci-defaults removal 2018-09-24 18:58:00 +02:00
boot layerscape: add ls1012afrwy support and drop ls1012afrdm 2018-09-22 21:20:57 +02:00
devel gdb: bump to 8.2 2018-09-07 17:21:24 +02:00
firmware layerscape: build ls-dpl package with linux dtc tool 2018-09-22 21:20:58 +02:00
kernel kernel: add Si7020 relative humidity/temperature sensor driver 2018-09-22 21:20:55 +02:00
libs mbedtls: update to 2.13.0 2018-09-22 19:26:25 +02:00
network lldpd: inhibit linking of libbsd on !GLIBC 2018-09-24 08:36:10 +02:00
system fstools: Install mount.hotplug and 10-fstab.defaults as 600 2018-09-19 09:41:28 +01:00
utils busybox: fix dependency for IPV6 2018-09-23 17:45:08 +02:00
Makefile imagebuilder: reuse rootfs preparation from rootfs.mk 2018-03-07 09:59:08 +01:00