luci.mk: fix length of abbreviated hash in version
authorHannu Nyman <hannu.nyman@iki.fi>
Sun, 23 Apr 2017 06:36:29 +0000 (09:36 +0300)
committerHannu Nyman <hannu.nyman@iki.fi>
Sun, 23 Apr 2017 06:59:20 +0000 (09:59 +0300)
Fix the length of the abbreviated commit hash used in
the LuCI version string used in the package names.
Use the old standard of seven characters in hash.

New git versions vary the length of the abbreviated
commit hash based on the number of objects in repo. That
may lead into different hash lengths with e.g. having
full/shallow git history, having all/single branch or
having different git versions in different build hosts.

Different hash lengths in package name may lead to
sneaky opkg install errors, as opkg apparently preserves
info for removed packages and may prefer that.
Example:
$ opkg install http://downloads...luci-app-statistics_git-17.073.42825-b47a21f-1_all.ipk
Downloading http://downloads...luci-app-statistics_git-17.073.42825-b47a21f-1_all.ipk
Installing luci-app-statistics (git-17.073.42825-b47a21fbb-1) to root...
Collected errors:
 * opkg_download_pkg: Package luci-app-statistics is not available from any configured src.

The error above is ultimately in opkg, but mitigate
the problem by fixing the hash length when building LuCI.

Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
luci.mk

diff --git a/luci.mk b/luci.mk
index 137886f1b322c75655a0276c03cfd63ed86b1aa7..7674825b499b524809286258541ef0ff44add856 100644 (file)
--- a/luci.mk
+++ b/luci.mk
@@ -56,7 +56,7 @@ PKG_VERSION?=$(if $(DUMP),x,$(strip $(shell \
        elif git log -1 >/dev/null 2>/dev/null; then \
                revision="svn-r$$(LC_ALL=C git log -1 | sed -ne 's/.*git-svn-id: .*@\([0-9]\+\) .*/\1/p')"; \
                if [ "$$revision" = "svn-r" ]; then \
-                       set -- $$(git log -1 --format="%ct %h"); \
+                       set -- $$(git log -1 --format="%ct %h" --abbrev=7); \
                        secs="$$(($$1 % 86400))"; \
                        yday="$$(date --utc --date="@$$1" "+%y.%j")"; \
                        revision="$$(printf 'git-%s.%05d-%s' "$$yday" "$$secs" "$$2")"; \