build: luci.mk: gracefully handle missing or unversioned po subdirectories
authorJo-Philipp Wich <jo@mein.io>
Tue, 14 Apr 2020 16:42:59 +0000 (18:42 +0200)
committerJo-Philipp Wich <jo@mein.io>
Tue, 14 Apr 2020 16:42:59 +0000 (18:42 +0200)
Fixes: #3911
Fixes: 9d8e99f9b build: gracefully handle non-Git source trees
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
luci.mk

diff --git a/luci.mk b/luci.mk
index 621008aa8743876a7d08aacc16844dbf1b098373..0b3a66e3b5b8d3005003af0c84ebe6cdd5901036 100644 (file)
--- a/luci.mk
+++ b/luci.mk
@@ -65,9 +65,13 @@ 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"; \
+      if [ -n "$$1" ]; then
+        secs="$$(($$1 % 86400))"; \
+        yday="$$(date --utc --date="@$$1" "+%y.%j")"; \
+        printf 'git-%s.%05d-%s' "$$yday" "$$secs" "$$2"; \
+      else \
+        echo "unknown"; \
+      fi; \
     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 \