-
Notifications
You must be signed in to change notification settings - Fork 145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[20.10 backport] [deb] fixes for version generating #831
Merged
thaJeztah
merged 5 commits into
docker:20.10
from
thaJeztah:20.10_backport_gen_version_fixes
Jan 19, 2023
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a0535af
static: make gen-static-ver work natively on macOS
thaJeztah 27ccbed
fix generating pre-release deb/rpm versions when using '.'
thaJeztah bfcd8fc
unify code for pseudo-versions (nightly), and fix for macOS
thaJeztah 8a720b2
deb, rpm: generate versions without special numbers for pre-releases
thaJeztah 1d6143e
[20.10] rpm, deb: continue using "3" as package version
thaJeztah File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,48 +13,26 @@ GIT_COMMAND="git -C $REPO_DIR" | |
origVersion="$VERSION" | ||
debVersion="${VERSION#v}" | ||
|
||
gen_deb_version() { | ||
# Adds an increment to the deb version to get proper order | ||
# 18.01.0-tp1 -> 18.01.0-0.1-tp1 | ||
# 18.01.0-beta1 -> 18.01.0-1.1-beta1 | ||
# 18.01.0-rc1 -> 18.01.0-2.1-rc1 | ||
# 18.01.0 -> 18.01.0-3 | ||
fullVersion="$1" | ||
pattern="$2" | ||
increment="$3" | ||
testVersion="${fullVersion#*-$pattern}" | ||
baseVersion="${fullVersion%-"$pattern"*}" | ||
echo "$baseVersion-$increment.$testVersion.$pattern$testVersion" | ||
} | ||
# deb packages require a tilde (~) instead of a hyphen (-) as separator between | ||
# the version # and pre-release suffixes, otherwise pre-releases are sorted AFTER | ||
# non-pre-release versions, which would prevent users from updating from a pre- | ||
# release version to the "ga" version. | ||
# | ||
# For details, see this thread on the Debian mailing list: | ||
# https://lists.debian.org/debian-policy/1998/06/msg00099.html | ||
# | ||
# The code below replaces hyphens with tildes. Note that an intermediate $tilde | ||
# variable is needed to make this work on all versions of Bash. In some versions | ||
# of Bash, the tilde would be substituted with $HOME (even when escaped (\~) or | ||
# quoted ('~'). | ||
tilde='~' | ||
debVersion="${debVersion//-/$tilde}" | ||
|
||
case "$debVersion" in | ||
*-dev) | ||
;; | ||
*-tp[0-9]*) | ||
debVersion="$(gen_deb_version "$debVersion" tp 0)" | ||
;; | ||
*-beta[0-9]*) | ||
debVersion="$(gen_deb_version "$debVersion" beta 1)" | ||
;; | ||
*-rc[0-9]*) | ||
debVersion="$(gen_deb_version "$debVersion" rc 2)" | ||
;; | ||
*) | ||
debVersion="$debVersion-3" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Need to make some changes to preserve this |
||
;; | ||
esac | ||
|
||
tilde='~' # ouch Bash 4.2 vs 4.3, you keel me | ||
debVersion="${debVersion//-/$tilde}" # using \~ or '~' here works in 4.3, but not 4.2; just ~ causes $HOME to be inserted, hence the $tilde | ||
# if we have a "-dev" suffix or have change in Git, let's make this package version more complex so it works better | ||
if [[ "$VERSION" == *-dev ]]; then | ||
# if we have a "-dev" suffix or have change in Git, this is a nightly build, and | ||
# we'll create a pseudo version based on commit-date and -sha. | ||
if [[ "$VERSION" == *-dev ]] || [ -n "$($GIT_COMMAND status --porcelain)" ]; then | ||
export TZ=UTC | ||
|
||
DATE_COMMAND="date" | ||
if [[ $(uname) == "Darwin" ]]; then | ||
DATE_COMMAND="docker run --rm alpine date" | ||
fi | ||
|
||
# based on golang's pseudo-version: https://groups.google.com/forum/#!topic/golang-dev/a5PqQuBljF4 | ||
# | ||
# using a "pseudo-version" of the form v0.0.0-yyyymmddhhmmss-abcdefabcdef, | ||
|
@@ -65,11 +43,20 @@ if [[ "$VERSION" == *-dev ]]; then | |
# as a pre-release before version v0.0.0, so that the go command prefers any | ||
# tagged release over any pseudo-version. | ||
gitUnix="$($GIT_COMMAND log -1 --pretty='%ct')" | ||
gitDate="$($DATE_COMMAND --utc --date "@$gitUnix" +'%Y%m%d%H%M%S')" | ||
|
||
if [ "$(uname)" = "Darwin" ]; then | ||
# Using BSD date (macOS), which doesn't support the --date option | ||
# date -jf "<input format>" "<input value>" +"<output format>" (https://unix.stackexchange.com/a/86510) | ||
gitDate="$(TZ=UTC date -u -jf "%s" "$gitUnix" +'%Y%m%d%H%M%S')" | ||
else | ||
# Using GNU date (Linux) | ||
gitDate="$(TZ=UTC date -u --date "@$gitUnix" +'%Y%m%d%H%M%S')" | ||
fi | ||
|
||
gitCommit="$($GIT_COMMAND log -1 --pretty='%h')" | ||
# generated version is now something like '0.0.0-20180719213702-cd5e2db' | ||
debVersion="0.0.0-${gitDate}-${gitCommit}" | ||
origVersion=$debVersion | ||
origVersion="0.0.0-${gitDate}-${gitCommit}" # (using hyphens) | ||
debVersion="0.0.0~${gitDate}.${gitCommit}" # (using tilde and periods) | ||
|
||
# verify that nightly builds are always < actual releases | ||
# | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Revert the changes from 8a720b2 for the docker-ce packages (but continue using the new format for the plugins, so that we don't push the same version of a plugin twice (once through the 23.0 release, once through the 20.10 release).
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.
Wait, what's the
~3
here for? (Sorry, I'm missing some context 🙈)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 was used in 20.10 (and before) to.. make sure "stable" releases ranked higher than "pre-releases" (
:lolsob:
). I removed that code from master, but the same generation code is used for all deb versions, so I backported removing that ugly hack in this PR (see 8a720b2). However, as 20.10 is reaching its end, I didn't want to introduce changing the versioning scheme for it, so I added it back here. As we're not planning to do-beta
releases for 20.10 patch releases, I hardcoded it to~3
(which was used to designate "stable releases').