diff mbox

[PATCHv2,4/8] scripts: cleanup git_hash and use it instead of odp_version.

Message ID 1446238668-15200-5-git-send-email-anders.roxell@linaro.org
State Superseded
Headers show

Commit Message

Anders Roxell Oct. 30, 2015, 8:57 p.m. UTC
This makes the version depend on git describe so there will be new deb
packages names.

Signed-off-by: Anders Roxell <anders.roxell@linaro.org>
---
 configure.ac            |  2 +-
 platform/Makefile.inc   |  2 +-
 scripts/Makefile.am     |  2 +-
 scripts/builddeb        |  9 ++++++++-
 scripts/get_impl_str.sh | 11 +++++++++++
 scripts/git_hash.sh     | 14 +++++++++++---
 scripts/odp_version.sh  | 12 ------------
 7 files changed, 33 insertions(+), 19 deletions(-)
 create mode 100755 scripts/get_impl_str.sh
 delete mode 100755 scripts/odp_version.sh
diff mbox

Patch

diff --git a/configure.ac b/configure.ac
index f7108ff..d698281 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,5 @@ 
 AC_PREREQ([2.5])
-AC_INIT([OpenDataPlane], m4_esyscmd(./scripts/odp_version.sh), [lng-odp@lists.linaro.org])
+AC_INIT([OpenDataPlane], m4_esyscmd(./scripts/git_hash.sh .), [lng-odp@lists.linaro.org])
 AM_INIT_AUTOMAKE([1.9 tar-pax subdir-objects])
 AC_CONFIG_SRCDIR([helper/config.h.in])
 AM_CONFIG_HEADER([helper/config.h])
diff --git a/platform/Makefile.inc b/platform/Makefile.inc
index 8e8e97b..db241f9 100644
--- a/platform/Makefile.inc
+++ b/platform/Makefile.inc
@@ -12,6 +12,6 @@  lib_LTLIBRARIES = $(LIB)/libodp.la
 
 AM_LDFLAGS += -version-number '$(ODP_LIBSO_VERSION)'
 
-GIT_DESC = `$(top_srcdir)/scripts/git_hash.sh $(top_srcdir)`
+GIT_DESC = `$(top_srcdir)/scripts/get_impl_str.sh $(top_srcdir)`
 AM_CFLAGS += "-DGIT_HASH=$(GIT_DESC)"
 AM_CFLAGS += -DPLATFORM=${with_platform}
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
index 617eadc..189b3ef 100644
--- a/scripts/Makefile.am
+++ b/scripts/Makefile.am
@@ -1 +1 @@ 
-EXTRA_DIST = git_hash.sh odp_version.sh
+EXTRA_DIST = get_impl_str.sh git_hash.sh
diff --git a/scripts/builddeb b/scripts/builddeb
index ddca129..8a52044 100755
--- a/scripts/builddeb
+++ b/scripts/builddeb
@@ -3,13 +3,14 @@ 
 set -e
 
 ROOT_DIR=$(readlink -e $(dirname $0) | sed 's|/scripts||')
-version=$(${ROOT_DIR}/scripts/odp_version.sh)
 
 pushd ${ROOT_DIR}
 ./bootstrap
 ./configure
 make dist
 
+version=$(cat ${ROOT_DIR}/.scmversion)
+
 cp opendataplane-${version}.tar.gz opendataplane_${version}.orig.tar.gz
 tar xzf opendataplane_${version}.orig.tar.gz
 
@@ -22,6 +23,12 @@  rename 's,([^-\.]*)(.*),${1}'"${current}"'${2},' debian/*odp*
 sed -i "s:\(.*odp\)\([^\.]\|$\):\1${current}\2:g" debian/control
 sed -i "s:\(.*odp\)\(.*\):\1${current}\2:g" debian/rules
 
+if [ $(egrep "\.([a-z0-9]{8}\>|dirty)" .scmversion |wc -l) -gt 0 ]; then
+	export DEBFULLNAME="Donald Duck"
+	export DEBEMAIL="donald.duck@linaro.org"
+	dch --newversion ${version}-1 --urgency low "not a official release!"
+fi
+
 debuild -us -uc
 popd
 popd
diff --git a/scripts/get_impl_str.sh b/scripts/get_impl_str.sh
new file mode 100755
index 0000000..d765a53
--- /dev/null
+++ b/scripts/get_impl_str.sh
@@ -0,0 +1,11 @@ 
+#!/bin/bash
+
+if [ -z ${1} ]; then
+	echo "should be called with a path"
+	exit
+fi
+ROOTDIR=${1}
+
+CUSTOM_STR=${CUSTOM_STR:-https://git.linaro.org/lng/odp.git}
+
+echo -n "'${CUSTOM_STR}' ($(cat ${ROOTDIR}/.scmversion))"
diff --git a/scripts/git_hash.sh b/scripts/git_hash.sh
index fc0b057..ccd62ab 100755
--- a/scripts/git_hash.sh
+++ b/scripts/git_hash.sh
@@ -6,15 +6,23 @@  if [ -z ${1} ]; then
 fi
 ROOTDIR=${1}
 
-CUSTOM_STR=${CUSTOM_STR:-https://git.linaro.org/lng/odp.git}
 if [ -d ${ROOTDIR}/.git ]; then
 	hash=$(git --git-dir=${ROOTDIR}/.git describe | tr -d "\n")
 	if [[ $(git --git-dir=${ROOTDIR}/.git diff --shortstat 2> /dev/null \
 		| tail -n1) != "" ]]; then
-		dirty=-dirty
+		dirty=.dirty
 	fi
 
-	echo -n "'${CUSTOM_STR}' (${hash}${dirty})">${ROOTDIR}/.scmversion
+	echo -n "${hash}${dirty}">${ROOTDIR}/.scmversion
+
+	sed -i "s|-|.git|" ${ROOTDIR}/.scmversion
+	sed -i "s|-|.|g" ${ROOTDIR}/.scmversion
+	sed -i "s|^v||g" ${ROOTDIR}/.scmversion
+elif [ ! -d ${ROOTDIR}/.git -a ! -f ${ROOTDIR}/.scmversion ]; then
+	echo -n "File ROOTDIR/.scmversion not found, "
+	echo "and not inside a git repository"
+	echo "Bailing out! Not recoverable!"
+	exit 1
 fi
 
 cat ${ROOTDIR}/.scmversion
diff --git a/scripts/odp_version.sh b/scripts/odp_version.sh
deleted file mode 100755
index 2487b7f..0000000
--- a/scripts/odp_version.sh
+++ /dev/null
@@ -1,12 +0,0 @@ 
-#!/bin/bash
-
-VFILE="include/odp/api/version.h"
-
-GEN=`grep "define ODP_VERSION_API_GENERATION"	${VFILE} | cut -d ' ' -f 3`
-MAJ=`grep "define ODP_VERSION_API_MAJOR"	${VFILE} | cut -d ' ' -f 3`
-MIN=`grep "define ODP_VERSION_API_MINOR"	${VFILE} | cut -d ' ' -f 3`
-
-IMPL_FILE="platform/linux-generic/odp_impl.c"
-IMPL=`grep "define ODP_VERSION_IMPL "		${IMPL_FILE} | cut -d ' ' -f 3`
-
-echo -n $GEN.$MAJ.$MIN.$IMPL