mirror of https://github.com/openwrt/openwrt.git
include/package-pack: add missing apk package lifecycle events
- pre-install calls preinst - pre-upgrade calls preinst with PKG_UPGRADE=1 - post-upgrade calls postinst with PKG_UPGRADE=1 - prerm and postrm from the previous version of a package are NOT executed on upgrade, so packages are expected to handle their own migrations in the new versions Link: https://wiki.alpinelinux.org/wiki/Creating_an_Alpine_package Fixes: #18527 Reported-by: Dobroslaw Kijowski <dobo90@gmail.com> Suggested-by: Eric Fahlgren <ericfahlgren@gmail.com> Suggested-by: Jonas Gorski <jonas.gorski@gmail.com> Suggested-by: Thomas Richard <thomas.richard@bootlin.com> Signed-off-by: George Sapkin <george@sapk.in> Link: https://github.com/openwrt/openwrt/pull/18531 Signed-off-by: Robert Marko <robimarko@gmail.com>pull/18531/head
parent
aefdbf0edc
commit
03880e2551
|
@ -110,12 +110,22 @@ endif
|
||||||
IDIR_$(1):=$(PKG_BUILD_DIR)/ipkg-$(PKGARCH)/$(1)
|
IDIR_$(1):=$(PKG_BUILD_DIR)/ipkg-$(PKGARCH)/$(1)
|
||||||
ADIR_$(1):=$(PKG_BUILD_DIR)/apk-$(PKGARCH)/$(1)
|
ADIR_$(1):=$(PKG_BUILD_DIR)/apk-$(PKGARCH)/$(1)
|
||||||
KEEP_$(1):=$(strip $(call Package/$(1)/conffiles))
|
KEEP_$(1):=$(strip $(call Package/$(1)/conffiles))
|
||||||
APK_SCRIPTS_$(1):=\
|
|
||||||
--script "post-install:$$(ADIR_$(1))/post-install" \
|
|
||||||
--script "pre-deinstall:$$(ADIR_$(1))/pre-deinstall"
|
|
||||||
|
|
||||||
|
APK_SCRIPTS_$(1):=
|
||||||
|
|
||||||
|
ifdef Package/$(1)/preinst
|
||||||
|
APK_SCRIPTS_$(1)+=--script "pre-install:$$(ADIR_$(1))/preinst"
|
||||||
|
endif
|
||||||
|
APK_SCRIPTS_$(1)+=--script "post-install:$$(ADIR_$(1))/post-install"
|
||||||
|
|
||||||
|
ifdef Package/$(1)/preinst
|
||||||
|
APK_SCRIPTS_$(1)+=--script "pre-upgrade:$$(ADIR_$(1))/pre-upgrade"
|
||||||
|
endif
|
||||||
|
APK_SCRIPTS_$(1)+=--script "post-upgrade:$$(ADIR_$(1))/post-upgrade"
|
||||||
|
|
||||||
|
APK_SCRIPTS_$(1)+=--script "pre-deinstall:$$(ADIR_$(1))/pre-deinstall"
|
||||||
ifdef Package/$(1)/postrm
|
ifdef Package/$(1)/postrm
|
||||||
APK_SCRIPTS_$(1)+=--script "post-deinstall:$$(ADIR_$(1))/postrm"
|
APK_SCRIPTS_$(1)+=--script "post-deinstall:$$(ADIR_$(1))/postrm"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
TARGET_VARIANT:=$$(if $(ALL_VARIANTS),$$(if $$(VARIANT),$$(filter-out *,$$(VARIANT)),$(firstword $(ALL_VARIANTS))))
|
TARGET_VARIANT:=$$(if $(ALL_VARIANTS),$$(if $$(VARIANT),$$(filter-out *,$$(VARIANT)),$(firstword $(ALL_VARIANTS))))
|
||||||
|
@ -305,6 +315,20 @@ else
|
||||||
[ ! -f $$(ADIR_$(1))/postinst-pkg ] || sed -z 's/^\s*#!/#!/' "$$(ADIR_$(1))/postinst-pkg"; \
|
[ ! -f $$(ADIR_$(1))/postinst-pkg ] || sed -z 's/^\s*#!/#!/' "$$(ADIR_$(1))/postinst-pkg"; \
|
||||||
) > $$(ADIR_$(1))/post-install;
|
) > $$(ADIR_$(1))/post-install;
|
||||||
|
|
||||||
|
ifdef Package/$(1)/preinst
|
||||||
|
( \
|
||||||
|
echo "#!/bin/sh"; \
|
||||||
|
echo 'export PKG_UPGRADE=1'; \
|
||||||
|
[ ! -f $$(ADIR_$(1))/preinst ] || sed -z 's/^\s*#!/#!/' "$$(ADIR_$(1))/preinst"; \
|
||||||
|
) > $$(ADIR_$(1))/pre-upgrade;
|
||||||
|
endif
|
||||||
|
|
||||||
|
( \
|
||||||
|
echo "#!/bin/sh"; \
|
||||||
|
echo 'export PKG_UPGRADE=1'; \
|
||||||
|
[ ! -f $$(ADIR_$(1))/post-install ] || sed -z 's/^\s*#!/#!/' "$$(ADIR_$(1))/post-install"; \
|
||||||
|
) > $$(ADIR_$(1))/post-upgrade;
|
||||||
|
|
||||||
( \
|
( \
|
||||||
echo "#!/bin/sh"; \
|
echo "#!/bin/sh"; \
|
||||||
echo "[ -s "\$$$${IPKG_INSTROOT}/lib/functions.sh" ] || exit 0"; \
|
echo "[ -s "\$$$${IPKG_INSTROOT}/lib/functions.sh" ] || exit 0"; \
|
||||||
|
|
Loading…
Reference in New Issue