[OpenWrt-Devel] package-ipkg.mk: allow to install CC packages on older versions
diff mbox

Message ID 54BF731F.7040308@gmail.com
State Rejected
Headers show

Commit Message

Christian Schoenebeck Jan. 21, 2015, 9:36 a.m. UTC
Packages compiled on CC / trunk could not be installed on BB and before.
Why to block users from using updated packages like ca-certificates,
privoxy or updated luci-apps. Checks if default_postinst/prerm function
exists in /lib/functions.sh then run, otherwise run [xxx]-pkg script
if exists.

Signed-off-by: Christian Schoenebeck <christian.schoenebeck@gmail.com>

---
 include/package-ipkg.mk | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

Comments

Rafał Miłecki Jan. 21, 2015, 9:55 a.m. UTC | #1
On 21 January 2015 at 10:36, Christian Schoenebeck
<christian.schoenebeck@gmail.com> wrote:
> Why to block users from using updated packages like ca-certificates,
> privoxy or updated luci-apps

Because we:
1) Don't want help users breaking their installations if they upgrade
wrong package
2) Don't want to keep a list of packages that could be used from
different releases

The correct way is to provide upgraded package for the stable release
(e.g. update package in BB branch).

Patch
diff mbox

diff --git a/include/package-ipkg.mk b/include/package-ipkg.mk
index 77eaeb8..584ab95 100644
--- a/include/package-ipkg.mk
+++ b/include/package-ipkg.mk
@@ -195,13 +195,25 @@  $(_endef)
 		( \
 			echo "#!/bin/sh"; \
 			echo "[ \"\$$$${IPKG_NO_SCRIPT}\" = \"1\" ] && exit 0"; \
-			echo ". \$$$${IPKG_INSTROOT}/lib/functions.sh"; \
-			echo "default_postinst \$$$$0 \$$$$@"; \
+			echo "grep 'default_postinst' \$$$${IPKG_INSTROOT}/lib/functions.sh >/dev/null 2>&1 && {"; \
+			echo "    . \$$$${IPKG_INSTROOT}/lib/functions.sh"; \
+			echo "    default_postinst \$$$$0 \$$$$@"; \
+			echo "} || {"; \
+			echo "    name=\$$$$(echo \$$$$(basename \$$$$0) | cut -d. -f1)"; \
+			echo "    [ -f \$$$${IPKG_INSTROOT}/usr/lib/opkg/info/\$$$${name}.postinst-pkg ] && \\"; \
+			echo "        . \$$$${IPKG_INSTROOT}/usr/lib/opkg/info/\$$$${name}.postinst-pkg \$$$$@"; \
+			echo "}"; \
 		) > postinst; \
 		( \
 			echo "#!/bin/sh"; \
-			echo ". \$$$${IPKG_INSTROOT}/lib/functions.sh"; \
-			echo "default_prerm \$$$$0 \$$$$@"; \
+			echo "grep 'default_prerm' \$$$${IPKG_INSTROOT}/lib/functions.sh >/dev/null 2>&1 && {"; \
+			echo "    . \$$$${IPKG_INSTROOT}/lib/functions.sh"; \
+			echo "    default_prerm \$$$$0 \$$$$@"; \
+			echo "} || {"; \
+			echo "    name=\$$$$(echo \$$$$(basename \$$$$0) | cut -d. -f1)"; \
+			echo "    [ -f \$$$${IPKG_INSTROOT}/usr/lib/opkg/info/\$$$${name}.prerm-pkg ] && \\"; \
+			echo "        . \$$$${IPKG_INSTROOT}/usr/lib/opkg/info/\$$$${name}.prerm-pkg \$$$$@"; \
+			echo "}"; \
 		) > prerm; \
 		chmod 0755 prerm; \
 		$($(1)_COMMANDS) \