rootfs: fail on errors in postinst scripts

The Gluon firmware framework [1] uses postinst scripts for sanity checks.
Make the build fail when a postinst script exits with an error to make
these sanity checks effective.

All postinst scripts in packages from the LEDE core and the packages feed
seem to work correctly with this change and will always return 0 unless
something is very broken.

[1] https://github.com/freifunk-gluon/gluon

Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
This commit is contained in:
Matthias Schiffer 2016-09-26 15:25:38 +02:00
parent 021b96d7c5
commit 5b99693832
No known key found for this signature in database
GPG key ID: 16EF3F64CB201D9C

View file

@ -60,6 +60,11 @@ define prepare_rootfs
cd $(1); \ cd $(1); \
for script in ./usr/lib/opkg/info/*.postinst; do \ for script in ./usr/lib/opkg/info/*.postinst; do \
IPKG_INSTROOT=$(1) $$(which bash) $$script; \ IPKG_INSTROOT=$(1) $$(which bash) $$script; \
ret=$$?; \
if [ $$ret -ne 0 ]; then \
echo "postinst script $$script has failed with exit code $$ret" >&2; \
exit 1; \
fi; \
done; \ done; \
for script in ./etc/init.d/*; do \ for script in ./etc/init.d/*; do \
grep '#!/bin/sh /etc/rc.common' $$script >/dev/null || continue; \ grep '#!/bin/sh /etc/rc.common' $$script >/dev/null || continue; \