Skip to content

Commit

Permalink
Merge pull request #13654 from stevekuznetsov/skuznets/rpm-version
Browse files Browse the repository at this point in the history
Merged by openshift-bot
  • Loading branch information
OpenShift Bot committed Apr 7, 2017
2 parents c92000c + 5b8152f commit 42c3bfa
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions hack/lib/build/rpm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,34 @@ function os::build::rpm::get_nvra_vars() {

# we can generate the package release from the git version metadata
# OS_GIT_VERSION will always have metadata, but either contain
# pre-release information _and_ build metadata, or only the latter
# pre-release information _and_ build metadata, or only the latter.
# Build metadata may or may not contain the number of commits past
# the last tag. If no commit number exists, we are on a tag and use 0.
# ex.
# -alpha.0+shasums-123-dirty
# -alpha.0+shasums-123
# -alpha.0+shasums-dirty
# -alpha.0+shasums
# +shasums-123-dirty
# +shasums-123
# +shasums-dirty
# +shasums
if [[ "${metadata:0:1}" == "+" ]]; then
# we only have build metadata, but need to massage it so
# we can generate a valid RPM release from it
if [[ "${metadata}" =~ ^\+([a-z0-9]{7})-([0-9]+)(-dirty)?$ ]]; then
if [[ "${metadata}" =~ ^\+([a-z0-9]{7})(-([0-9]+))?(-dirty)?$ ]]; then
build_sha="${BASH_REMATCH[1]}"
build_num="${BASH_REMATCH[2]}"
build_num="${BASH_REMATCH[3]:-0}"
else
os::log::fatal "Malformed git version metadata: ${metadata}"
fi
OS_RPM_RELEASE="1.${build_num}.${build_sha}"
elif [[ "${metadata:0:1}" == "-" ]]; then
# we have both build metadata and pre-release info
if [[ "${metadata}" =~ ^-([^\+]+)\+([a-z0-9]{7})-([0-9]+)(-dirty)?$ ]]; then
if [[ "${metadata}" =~ ^-([^\+]+)\+([a-z0-9]{7})(-([0-9]+))?(-dirty)?$ ]]; then
pre_release="${BASH_REMATCH[1]}"
build_sha="${BASH_REMATCH[2]}"
build_num="${BASH_REMATCH[3]}"
build_num="${BASH_REMATCH[4]:-0}"
else
os::log::fatal "Malformed git version metadata: ${metadata}"
fi
Expand Down

0 comments on commit 42c3bfa

Please sign in to comment.