I would like to add the last "git commit id" to my rpms to have a foolproof way to track back the sources used to build a package.
I could use the rpm release
tag, but this is already used for release numbers and dates in case of snapshots. I don't want to overload this any further.
Is there another tag or mechanism to store the last commit-id in an rpm?
To find a git commit id (or hash), you can simply use the git log command. This would show you the commit history, listing the commits in chronological order, with the latest commit first.
The commit ID is the 40 character long string after the word commit, you really can't miss it.
The most basic and powerful tool to do this is the git log command. By default, with no arguments, git log lists the commits made in that repository in reverse chronological order; that is, the most recent commits show up first.
I'm not aware of anything in the Spec format specifically designed for this, but I do see a couple of options:
version
tag
release
tag in your question, but this is for the package version, not the software version. A Git revision is much more like a software version than a package version.1.0
if you want, but I'd advise you to make sure that this corresponds to a Git tag with the same name so your version will always be meaningful to Git.serial
tag, so RPM can figure out how to order versions. (This may not be necessary if you tag properly and use the method below for determining your version.)url
tag like http://example.com/software/software-abcd123.zip
.
In the first case case (and possibly the second), it may be worthwhile to use git describe
to determine your Git-aware version number, e.g.
$ git describe HEAD
1.0.0-3-gabcd123
'-.-' | |'--.--'
| | | `---- Short Git hash
| | `-------- Indicates that a Git hash follows
| `---------- Three commits ahead of the previous tag name
`-------------- The name of the base tag
Note that your RPM version
cannot contain hyphens, so this version may have to be transcribed to something like 1.0.0_3_gabcd123
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With