Message ID | 20210110092400.144356-1-mail@aparcar.org |
---|---|
State | Superseded |
Delegated to: | Paul Spooren |
Headers | show |
Series | [v3,1/3] rules: add commitcount function | expand |
diff --git a/rules.mk b/rules.mk index f79340b124..ac406983b9 100644 --- a/rules.mk +++ b/rules.mk @@ -408,6 +408,24 @@ 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 \ + printf '%s' $$(git rev-list --count HEAD .); \ + 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
`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 <mail@aparcar.org> --- v2: - reproducible versions via SOURCE_DATE_EPOCH - wrap function in ifndef DUMP v3: - don't use tabs in `commitcount` to remove stripping in VERSION:= definition rules.mk | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)