summaryrefslogtreecommitdiffhomepage
path: root/luci.mk
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2020-04-14 17:43:08 +0200
committerJo-Philipp Wich <jo@mein.io>2020-04-14 17:43:08 +0200
commit9d8e99f9bed1402543e128c2543fdbd5e2f9c338 (patch)
tree273c2bb587ba07305445ced3c4f45078c3b6f73e /luci.mk
parent5c22340f43e1b4a0d25b59c5adbc2ebd0ea5facf (diff)
build: gracefully handle non-Git source trees
Fixes: #3911 Fixes: 59fe4086f ("build: luci.mk: drop support for non-Git SCMs") Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'luci.mk')
-rw-r--r--luci.mk35
1 files changed, 23 insertions, 12 deletions
diff --git a/luci.mk b/luci.mk
index 0f9f35daf..621008aa8 100644
--- a/luci.mk
+++ b/luci.mk
@@ -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"; \