Skip to content

Commit

Permalink
build: gracefully handle non-Git source trees
Browse files Browse the repository at this point in the history
Fixes: #3911
Fixes: 59fe408 ("build: luci.mk: drop support for non-Git SCMs")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
  • Loading branch information
jow- committed Apr 14, 2020
1 parent 5c22340 commit 9d8e99f
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions luci.mk
Expand Up @@ -59,19 +59,30 @@ LUCI_LC_ALIAS.zh_Hant=zh-tw

PKG_NAME?=$(LUCI_NAME)

PKG_PO_VERSION?=$(if $(DUMP),x,$(strip $(shell \
set -- $$(git log -1 --format="%ct %h" --abbrev=7 -- po); \
secs="$$(($$1 % 86400))"; \
yday="$$(date --utc --date="@$$1" "+%y.%j")"; \
printf 'git-%s.%05d-%s' "$$yday" "$$secs" "$$2" \
)))

PKG_SRC_VERSION?=$(if $(DUMP),x,$(strip $(shell \
set -- $$(git log -1 --format="%ct %h" --abbrev=7 -- . ':(exclude)po'); \
secs="$$(($$1 % 86400))"; \
yday="$$(date --utc --date="@$$1" "+%y.%j")"; \
printf 'git-%s.%05d-%s' "$$yday" "$$secs" "$$2" \
)))
# 1: everything expect po subdir or only po subdir
define findrev
$(shell \
if git log -1 >/dev/null 2>/dev/null; then \
set -- $$(git log -1 --format="%ct %h" --abbrev=7 -- '$(if $(1),:(exclude))po'); \
secs="$$(($$1 % 86400))"; \
yday="$$(date --utc --date="@$$1" "+%y.%j")"; \
printf 'git-%s.%05d-%s' "$$yday" "$$secs" "$$2"; \
else \
ts=$$(find . -type f $(if $(1),-not) -path './po/*' -printf '%T@\n' 2>/dev/null | sort -rn | head -n1 | cut -d. -f1); \
if [ -n "$$ts" ]; then \
secs="$$(($$ts % 86400))"; \
date="$$(date --utc --date="@$$ts" "+%y%m%d")"; \
printf '%s.%05d' "$$date" "$$secs"; \
else \
echo "unknown"; \
fi; \
fi \
)
endef

PKG_PO_VERSION?=$(if $(DUMP),x,$(strip $(call findrev)))
PKG_SRC_VERSION?=$(if $(DUMP),x,$(strip $(call findrev,1)))

PKG_GITBRANCH?=$(if $(DUMP),x,$(strip $(shell \
variant="LuCI"; \
Expand Down

1 comment on commit 9d8e99f

@snakwu
Copy link

@snakwu snakwu commented on 9d8e99f Apr 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem has not been solved!
make[3]: Entering directory '/home/snakwu/openwrt-master/openwrt/package/lean/luci-app-accesscontrol'
bash: % 86400: syntax error: operand expected (error token is "% 86400")
/home/snakwu/openwrt-master/openwrt/feeds/luci/luci.mk:288: *** Package/luci-i18n-accesscontrol-zh-cn is missing the VERSION field. Stop.
make[3]: Leaving directory '/home/snakwu/openwrt-master/openwrt/package/lean/luci-app-accesscontrol'
time: package/lean/luci-app-accesscontrol/compile#0.83#0.14#1.74
package/Makefile:111: recipe for target 'package/lean/luci-app-accesscontrol/compile' failed
make[2]: *** [package/lean/luci-app-accesscontrol/compile] Error 2
make[2]: Leaving directory '/home/snakwu/openwrt-master/openwrt'
package/Makefile:107: recipe for target '/home/snakwu/openwrt-master/openwrt/staging_dir/target-x86_64_musl/stamp/.package_compile' failed
make[1]: *** [/home/snakwu/openwrt-master/openwrt/staging_dir/target-x86_64_musl/stamp/.package_compile] Error 2
make[1]: Leaving directory '/home/snakwu/openwrt-master/openwrt'
/home/snakwu/openwrt-master/openwrt/include/toplevel.mk:218: recipe for target 'world' failed
make: *** [world] Error 2

Please sign in to comment.