build: generate strictly increasing git revisions (#225)
Instead of simply emitting a "git-$hash" revision, take the commit time into account to generate strictly increasing revisions to preserve opkg upgrade capabilities. The format is "git-YY.DDD.SSSSS-HHHHHHH" with the following defined fields: - YY year number (00..99) - DDD day of year (001..366) - SSSSSS second of day (00000..86399) - HHHHHHH abbreviated git commit hash An example revision is "git-14.283.50202-bb388f0". Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
This commit is contained in:
parent
7f86a80be2
commit
0856030c79
1 changed files with 4 additions and 1 deletions
|
@ -14,7 +14,10 @@ TOPDIR="${0%mkrevision.sh}"
|
||||||
elif git log -1 >/dev/null 2>/dev/null; then
|
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')"
|
revision="svn-r$(LC_ALL=C git log -1 | sed -ne 's/.*git-svn-id: .*@\([0-9]\+\) .*/\1/p')"
|
||||||
if [ "$revision" = "svn-r" ]; then
|
if [ "$revision" = "svn-r" ]; then
|
||||||
revision="git-$(LC_ALL=C git log -1 --pretty=%h)"
|
set -- $(git log -1 --format="%ct %h")
|
||||||
|
secs="$(($1 % 86400))"
|
||||||
|
yday="$(date --utc --date="@$1" "+%y.%j")"
|
||||||
|
revision="$(printf 'git-%s.%05d-%s' "$yday" "$secs" "$2")"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
revision="unknown"
|
revision="unknown"
|
||||||
|
|
Loading…
Reference in a new issue