From cad431cd9ef28241fb14454063bb802a878ec96a Mon Sep 17 00:00:00 2001 From: Nathan Cutler Date: Tue, 5 Feb 2019 16:46:52 +0100 Subject: [PATCH] make-dist: set version number only once Before this commit, "git describe" was being run *twice* - once at the beginning to initialize the version variable, and another time further down to populate the .git_version file. Refactor so the command is run only once, and include the --long option to eliminate the undesirable behavior of producing just the tag when HEAD points to a tag. Also, since .git_version is now populated without the leading "v", the cmake code for stripping off that leading "v" is no longer needed. Signed-off-by: Nathan Cutler --- make-dist | 28 +++++++++++----------------- src/CMakeLists.txt | 2 -- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/make-dist b/make-dist index db625624021..64280dd7eb8 100755 --- a/make-dist +++ b/make-dist @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/bash -e if [ ! -d .git ]; then echo "no .git present. run this from the base dir of the git checkout." @@ -6,9 +6,16 @@ if [ ! -d .git ]; then fi version=$1 -[ -z "$version" ] && version=`git describe --match 'v*' | sed 's/^v//'` -outfile="ceph-$version" +[ -z "$version" ] && version=$(git describe --long --match 'v*' | sed 's/^v//') +if expr index $version '-' > /dev/null; then + rpm_version=$(echo $version | cut -d - -f 1-1) + rpm_release=$(echo $version | cut -d - -f 2- | sed 's/-/./') +else + rpm_version=$version + rpm_release=0 +fi +outfile="ceph-$version" echo "version $version" # update submodules @@ -105,20 +112,7 @@ bin/git-archive-all.sh --prefix ceph-$version/ \ # populate files with version strings echo "including src/.git_version, ceph.spec" -(git rev-parse HEAD ; git describe) 2> /dev/null > src/.git_version - -# if the version has '-' in it, it has a 'release' part, -# like vX.Y.Z-N-g. If it doesn't, it's just -# vX.Y.Z. Handle both, and translate - to . for rpm -# naming rules (the - separates version and release). - -if expr index $version '-' > /dev/null; then - rpm_version=`echo $version | cut -d - -f 1-1` - rpm_release=`echo $version | cut -d - -f 2- | sed 's/-/./'` -else - rpm_version=$version - rpm_release=0 -fi +(git rev-parse HEAD ; echo $version) 2> /dev/null > src/.git_version for spec in ceph.spec.in alpine/APKBUILD.in; do cat $spec | diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ecd5e26ba67..35b2aeb0f2a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -188,8 +188,6 @@ if(${ENABLE_GIT_VERSION}) list(GET CEPH_GIT_SHA_AND_TAG 0 CEPH_GIT_VER) list(GET CEPH_GIT_SHA_AND_TAG 1 CEPH_GIT_NICE_VER) endif(${CEPH_GIT_VER} STREQUAL "GITDIR-NOTFOUND") - # remove 'v' prefix from raw git version - string(SUBSTRING ${CEPH_GIT_NICE_VER} 1 -1 CEPH_GIT_NICE_VER) else(${ENABLE_GIT_VERSION}) set(CEPH_GIT_VER "no_version") set(CEPH_GIT_NICE_VER "Development") -- 2.39.5