`commitcount` returns the number of commits affecting the current folder. The newly added function can be used for packages that do not follow a traditional versioning schema, most prominent `base-files` which requires tedious `PKG_RELEASE` bumps.
Below a naming example: base-files_1399-r15385+75-c5d033a34d_x86_64.ipk In cases where no Git system is used, the timestamp of SOURCE_DATE_EPOCH is used instead, allowing reproducible builds. base-files_210107.30634-r1538581-c5d033a34d_x86_64.ipk Signed-off-by: Paul Spooren <m...@aparcar.org> --- v2: - reproducible versions via SOURCE_DATE_EPOCH - wrap function in ifndef DUMP rules.mk | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/rules.mk b/rules.mk index f79340b124..eeaadfecea 100644 --- a/rules.mk +++ b/rules.mk @@ -408,6 +408,30 @@ endef # file extension ext=$(word $(words $(subst ., ,$(1))),$(subst ., ,$(1))) + +ifndef DUMP +define commitcount + $(shell \ + if git log -1 >/dev/null 2>/dev/null; then \ + set -- $$(git rev-list --count HEAD .); \ + if [ -n "$$1" ]; then + echo "$$1"; \ + else \ + echo "unknown"; \ + fi; \ + else \ + secs="$$(($(SOURCE_DATE_EPOCH) % 86400))"; \ + date="$$(date --utc --date="@$(SOURCE_DATE_EPOCH)" "+%y%m%d")"; \ + printf '%s.%05d' "$$date" "$$secs"; \ + fi \ + ) +endef +else +define commitcount + 1 +endef +endif + all: FORCE: ; .PHONY: FORCE -- 2.29.2 _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel