Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rules: add AUTORELEASE and COMMITCOUNT variables
The lack of bumped PKG_RELEASE variables is a recurring theme on the mailing list and in GitHub comments. This costs precious review time, a rare good within the OpenWrt project. Instead of relying on a manually set PKG_RELEASE this commit adds a `commitcount` function that uses the number of Git commits to determine the release. The function is called via the variables `$(AUTORELEASE)` or `$(COMMITCOUNT)`. The `PKG_RELEASE` variable can be set to either of the two. - $(AUTORELEASE): Release is automagically set to the number of commits since the last commit containing either ": update to " or ": bump to ". Example below: $ git log packages/foobar/ foobar: fixup file location foobar: disable docs foobar: bump to 5.3.2 foobar: fixup copyright Resulting package name: foobar_5.3.2-3_all.ipk, two package changes since the last upstream version change, using a 1 based counter. - $(COMMITCOUNT): For non-traditional versioning (x.y.z), most prominent `base-files`, this variable contains the total number of package commits. The new functionality can also be used by other feeds like packages.git. In case no build information is available, e.g. when using release tarballs, the SOURCE_DATE_EPOCH is used to have a reproducible release identifier. Suggested-by: Daniel Golle <daniel@makrotopia.org> Signed-off-by: Paul Spooren <mail@aparcar.org>
- Loading branch information
9ae3c6f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not work as expected for feeds.
script/feeds/update
usesgit clone --depth 1
when cloning and thegit log
is truncated and odes not have the needed linesJust an example. in case I do
git clone https://git.openwrt.org/feed/packages.git
the output of git log is (truncated) for dbus package isIn case I clone with scripts/feeds it is
This will give AUTORELEASE value 2 for dbus (and other packages).
9ae3c6f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The buildbots use the full git history so upstream packages always have the correct release. Without the full git log you won't be able to set correct "last modified" dates within packages, see here for further information on package reproducibility.
In short, use full history clones if you need upstream release numbers and have reproducible packages. To do so edit your
feeds.config
and replacesrc-git
withsrc-git-full
.9ae3c6f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should just default to full then ?
9ae3c6f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine with me
9ae3c6f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if a feed is clone by
git clone --depth 1
, AUTORELEASE will get wrong result, when usinggit rev-list --count
. And repo more huge, git rev-list will more slow.git log -1 --format=%ct Makefile
as AUTORELEASE is enough, and uniq.9ae3c6f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But files of the package may change which do not touch the Makefile
9ae3c6f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, how about
git log -1 --format=%ct -- ./
, if ./ is the directory where Makefile at.9ae3c6f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll look into that, thank you
9ae3c6f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this is faster the numbers are not really "human readable", what do you think?
9ae3c6f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may using YYYYMMDDThhmmss format, it will longer but human easy to read than C time.
such as vim-8.2-20210720T162259_x86_64.ipk, 20210720T162259 is ISO time string of the last git commit time.
9ae3c6f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
like this, or you can find only one git command method.
git log -1 --date=format:%Y%m%dT%H%M%S -- ./ | grep -Po '\d{8}T\d{6}'
20210723T204843
9ae3c6f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or you can give the option to the user, provide 3 AUTORELEASE Macros
AUTORELEASE_123 # Number of releases, not support git clone --depth 1, it will become slower when repo grows
AUTORELEASE_CTIME # faster but not human readable
AUTORELEASE_ISOTIME # faster, readable but longer filename
and define one of them as default AUTORELEASE.
9ae3c6f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a simply speed test
9ae3c6f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll have the git clone --depth 1 issue for all your other solution too, unless you coincidentally updated often enough so that every package has at least one affecting commit. Running your commands on a fresh copy with a depth of one results in every package having the same date.
Is the speed impact very relevant? I see how this could become an issue for millions of packages but the point was after all to save human time by using computer time.
9ae3c6f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thats different, when using rev-list --count on repo depth 1, you got small release number than expect, that will cause problem. But git log -1 --date you will got the latest time string, that is OK.
One pass full package compile will slower more than 20 seconds if there are 100 packages Makefile using AUTORELEASE_123. After 5 years, maybe 200+ seconds if repos grows and packages grows.
9ae3c6f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are there any objections if we also support the past tense for this too?
e.g. ": Updated to x.x.x"
9ae3c6f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The general practice is to write commit titles (and message where appropriate) in imperative form. I do not see a reason to deviate from that, particularly since this feature will only be relevant for present and future commit titles, and does not care about the past (mostly).
9ae3c6f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds fair to me, for similar motivations to this feature. It might be nice to error or warn if a different tense is detected then 🤔
9ae3c6f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That’s CI stuff