generate-version.sh breaks builds & un-reproducible
Issue
generate-version.sh
is doing a couple of bad things:
-
VERSION_FROM_DIR_NAME
makes little sense and will happily end up with a version likeservice.bst
since it just chops off everything up to a-
(my distro's package name for accountsservice ispkgs/accounts-service.bst
-> the .pc file bizarrely containsversion: service.bst
). Frankly, the name of the directory that stores the git checkout should have absolutely no bearing on any of the final package. - Using the current date to determine version breaks reproducible builds. Two people building the exact same package definition for my OS a day apart can end up with different output. I can't even force a date because that'll mean that every single version of accountsservice will have the same version number
This all leads to build failures across my distro. Anything that depends on accountsservice is failing because "service.bst" is an unexpected version number.
Proposed alternative:
- Use git to determine if the current checkout is a tag. If it is a tag, just return the tag's name as the accountsservice version
- If the checkout isn't a tag, do whatever you want. Suggestions:
- use the last tag + the number of commits since the last tag (i.e. 22.05.32 means tag=22.05 and there have been 32 commits since)
- use the last tag + the current commit hash. Basically just
git describe
. This will handle the "current checkout is a tag" case for you too - use the current date like you're doing now. This'll still break reproducible builds for any distro unfortunate enough to not be using a tag
Workaround:
I'm just doing this in my distro's package for now: echo -e '#!/bin/sh\ngit describe' > generate-version.sh
. This fixes the version number for me