I'm not aware of anything in the Spec format specifically designed for this, but I do see a couple of options:
- Use the
version
tag
- You mentioned the
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.
- For stable releases you can still use numeric tags like
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.
- Doing this means that you should probably also use the
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.)
- This will include the revision in the name of your package, or at least in the file name, and it sounds like you don't want that.
- Name your source archive with the Git hash and then use a
url
tag like http://example.com/software/software-abcd123.zip
.
- You will not need to include the revision in your package file name using this method.
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
.
rpm
oryum
commands, or do you simply want a way for packagers to know what sources they used? – Hypogealrpm
oryum
commands, but as a tag. Encoding it in the rpm name would be ugly imho. – Ambulance