diff mbox

[OpenWrt-Devel,include] Support postinst on old OS

Message ID 20160321133019.GI16629@workbook.ipv6.hrusecky.net
State Changes Requested
Headers show

Commit Message

Michal Hrusecky March 21, 2016, 1:30 p.m. UTC
Currently all package postinst scripts are saved as postinst-pkg and interpreted
by script in base-files. Thus those don't work if you have old base-files.
Updating generating script to make it work even with old base-files.

Signed-off-by: Michal Hrusecky <Michal.Hrusecky@nic.cz>
---
 include/package-ipkg.mk | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/include/package-ipkg.mk b/include/package-ipkg.mk
index eb4c874..124e228 100644
--- a/include/package-ipkg.mk
+++ b/include/package-ipkg.mk
@@ -196,8 +196,13 @@  $(_endef)
 		( \
 			echo "#!/bin/sh"; \
 			echo "[ \"\$$$${IPKG_NO_SCRIPT}\" = \"1\" ] && exit 0"; \
+			echo "pkgname=\"\$$$$(basename \$$$${0%.*})\""; \
 			echo ". \$$$${IPKG_INSTROOT}/lib/functions.sh"; \
-			echo "default_postinst \$$$$0 \$$$$@"; \
+			echo "if type default_postinst > /dev/null; then"; \
+			echo "	default_postinst \$$$$0 \$$$$@ || true"; \
+			echo "elif [ -f \"\$$$${IPKG_INSTROOT}/usr/lib/opkg/info/\$$$${pkgname}.postinst-pkg\" ]; then"; \
+			echo "	. \"\$$$${IPKG_INSTROOT}/usr/lib/opkg/info/\$$$${pkgname}.postinst-pkg\""; \
+			echo "fi"; \
 		) > postinst; \
 		( \
 			echo "#!/bin/sh"; \