]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
make-dist: set version number only once
authorNathan Cutler <ncutler@suse.com>
Tue, 5 Feb 2019 15:46:52 +0000 (16:46 +0100)
committerNathan Cutler <ncutler@suse.com>
Wed, 8 May 2019 09:28:19 +0000 (11:28 +0200)
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 <ncutler@suse.com>
make-dist
src/CMakeLists.txt

index db62562402158e89141d870c4f57cbbe9cc946fc..64280dd7eb8e29faf02b342ccab48b704ce66406 100755 (executable)
--- 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<shortsha1>.  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 |
index ecd5e26ba670e726c6bfb7294623c444787574e6..35b2aeb0f2aabbfb5a3c77294d4a6f1d5f269fb7 100644 (file)
@@ -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")