luci.mk: refactor install recipe

Detect the presence of directories using Make $(wildcard ...) and emit
plain install commands depending on the outcome instead of relying on
shell conditionals which impose syntax constraints on code outside of
the scope of the LuCI repo.

Fixes: #5936
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
Jo-Philipp Wich 2022-09-28 09:17:06 +02:00
parent 25f75e08f1
commit 3393e15815

43
luci.mk
View file

@ -184,27 +184,28 @@ else
endif endif
define Package/$(PKG_NAME)/install define Package/$(PKG_NAME)/install
if [ -d $(PKG_BUILD_DIR)/luasrc ]; then \
$(INSTALL_DIR) $(1)$(LUCI_LIBRARYDIR); \ ifneq ($(wildcard ${CURDIR}/luasrc),)
cp -pR $(PKG_BUILD_DIR)/luasrc/* $(1)$(LUCI_LIBRARYDIR)/; \ $(INSTALL_DIR) $(1)$(LUCI_LIBRARYDIR)
$(FIND) $(1)$(LUCI_LIBRARYDIR)/ -type f -name '*.luadoc' | $(XARGS) rm; \ cp -pR $(PKG_BUILD_DIR)/luasrc/* $(1)$(LUCI_LIBRARYDIR)/
$(if $(CONFIG_LUCI_SRCDIET),$(call SrcDiet,$(1)$(LUCI_LIBRARYDIR)/),true); \ $(FIND) $(1)$(LUCI_LIBRARYDIR)/ -type f -name '*.luadoc' | $(XARGS) rm
$(call SubstituteVersion,$(1)$(LUCI_LIBRARYDIR)/); \ $(if $(CONFIG_LUCI_SRCDIET),$(call SrcDiet,$(1)$(LUCI_LIBRARYDIR)/),true)
else true; fi $(call SubstituteVersion,$(1)$(LUCI_LIBRARYDIR)/)
if [ -d $(PKG_BUILD_DIR)/htdocs ]; then \ endif
$(INSTALL_DIR) $(1)$(HTDOCS); \ ifneq ($(wildcard ${CURDIR}/htdocs),)
cp -pR $(PKG_BUILD_DIR)/htdocs/* $(1)$(HTDOCS)/; \ $(INSTALL_DIR) $(1)$(HTDOCS)
$(if $(CONFIG_LUCI_JSMIN),$(call JsMin,$(1)$(HTDOCS)/),true); \ cp -pR $(PKG_BUILD_DIR)/htdocs/* $(1)$(HTDOCS)/
$(if $(CONFIG_LUCI_CSSTIDY),$(call CssTidy,$(1)$(HTDOCS)/),true); \ $(if $(CONFIG_LUCI_JSMIN),$(call JsMin,$(1)$(HTDOCS)/),true)
else true; fi $(if $(CONFIG_LUCI_CSSTIDY),$(call CssTidy,$(1)$(HTDOCS)/),true)
if [ -d $(PKG_BUILD_DIR)/root ]; then \ endif
$(INSTALL_DIR) $(1)/; \ ifneq ($(wildcard ${CURDIR}/root),)
cp -pR $(PKG_BUILD_DIR)/root/* $(1)/; \ $(INSTALL_DIR) $(1)/
else true; fi cp -pR $(PKG_BUILD_DIR)/root/* $(1)/
if [ -d $(PKG_BUILD_DIR)/src ]; then \ endif
$(call Build/Install/Default) \ ifneq ($(wildcard ${CURDIR}/src),)
$(CP) $(PKG_INSTALL_DIR)/* $(1)/; \ $(call Build/Install/Default)
else true; fi $(CP) $(PKG_INSTALL_DIR)/* $(1)/
endif
endef endef
ifndef Package/$(PKG_NAME)/postinst ifndef Package/$(PKG_NAME)/postinst