luci.mk: more APK version compatibility changes
authorPaul Spooren <mail@aparcar.org>
Tue, 26 Mar 2024 09:44:33 +0000 (10:44 +0100)
committerPaul Spooren <mail@aparcar.org>
Sun, 7 Apr 2024 11:17:01 +0000 (13:17 +0200)
The initial commit did not take care of corner cases which could happen
if building under build conditions other than using Git.

There are three cases for the `findrev` function:

- git -> 24.079.58964~7943616 (remove prefixed `git-`)

APK can't handle `git-` as prefix, it could be `0_git<integer>` but this
seems rather confusing.

- date -> 0.240326.34906 ( add leading 0)

Add a leading zero so the version is always lower compared to using
Git. This makes it easier to distinguish from a Git based version.

- unknown -> 0 (instead of `unknown`)

APK can't handle `unknown` so set it to a simple zero instead.

Signed-off-by: Paul Spooren <mail@aparcar.org>
luci.mk

diff --git a/luci.mk b/luci.mk
index 12cdd6de901cfa5dbda1f119afd8f715018f6de2..7e965a06fb01db2b56992b5361b20120c421da48 100644 (file)
--- a/luci.mk
+++ b/luci.mk
@@ -85,18 +85,18 @@ define findrev
       if [ -n "$$1" ]; then
         secs="$$(($$1 % 86400))"; \
         yday="$$(date --utc --date="@$$1" "+%y.%j")"; \
-        printf 'git-%s.%05d~%s' "$$yday" "$$secs" "$$2"; \
+        printf '%s.%05d~%s' "$$yday" "$$secs" "$$2"; \
       else \
-        echo "unknown"; \
+        echo "0"; \
       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 \
         secs="$$(($$ts % 86400))"; \
         date="$$(date --utc --date="@$$ts" "+%y%m%d")"; \
-        printf '%s.%05d' "$$date" "$$secs"; \
+        printf '0.%s.%05d' "$$date" "$$secs"; \
       else \
-        echo "unknown"; \
+        echo "0"; \
       fi; \
     fi \
   )