diff --git a/genversion.sh b/genversion.sh index af2edca9cfd..50fe3fad983 100755 --- a/genversion.sh +++ b/genversion.sh @@ -80,9 +80,10 @@ function getVersionFromLog() function printHelp() { echo "Usage:" 1>&2 - echo "${0} [--help|--print-only] [SOURCEPATH]" 1>&2 + echo "${0} [--help|--print-only|--version] [SOURCEPATH]" 1>&2 echo " --help prints this message" 1>&2 echo " --print-only prints the version to stdout and quits" 1>&2 + echo " --version VERSION sets the version manually" 1>&2 } #------------------------------------------------------------------------------- @@ -93,6 +94,13 @@ while test ${#} -ne 0; do PRINTHELP=1 elif test x${1} = x--print-only; then PRINTONLY=1 + elif test x${1} = x--version; then + if test ${#} -lt 2; then + echo "--version parameter needs an argument" 1>&2 + exit 1 + fi + USER_VERSION=${2} + shift else SOURCEPATH=${1} fi @@ -143,6 +151,12 @@ if test ! -d ${SOURCEPATH}.git; then fi fi +#------------------------------------------------------------------------------- +# Check if the version has been specified by the user +#------------------------------------------------------------------------------- +elif test x$USER_VERSION != x; then + VERSION=$USER_VERSION + #------------------------------------------------------------------------------- # We're in a git repo so we can try to determine the version using that #------------------------------------------------------------------------------- @@ -184,7 +198,7 @@ fi #------------------------------------------------------------------------------- # Make sure the version string is not longer than 25 characters #------------------------------------------------------------------------------- -if test ${#VERSION} -gt 25; then +if test ${#VERSION} -gt 25 and x$USER_VERSION = x; then VERSION="${VERSION:0:19}...${VERSION: -3}" fi diff --git a/packaging/makesrpm.sh b/packaging/makesrpm.sh index e391c46bb1a..3bd40b6bf76 100755 --- a/packaging/makesrpm.sh +++ b/packaging/makesrpm.sh @@ -32,6 +32,7 @@ function printHelp() echo " defaults to ../" 1>&2 echo " --output PATH the directory where the source rpm" 1>&2 echo " should be stored, defaulting to ." 1>&2 + echo " --version VERSION the version provided by user" 1>&2 } #------------------------------------------------------------------------------- @@ -58,6 +59,13 @@ while test ${#} -ne 0; do fi OUTPUTPATH=${2} shift + elif test x${1} = x--version; then + if test ${#} -lt 2; then + echo "--version parameter needs an argument" 1>&2 + exit 1 + fi + USER_VERSION="--version ${2}" + shift fi shift done @@ -112,7 +120,7 @@ if test ! -x $SOURCEPATH/genversion.sh; then exit 3 fi -VERSION=`$SOURCEPATH/genversion.sh --print-only $SOURCEPATH 2>/dev/null` +VERSION=`$SOURCEPATH/genversion.sh --print-only $USER_VERSION $SOURCEPATH 2>/dev/null` if test $? -ne 0; then echo "[!] Unable to figure out the version number" 1>&2 exit 4 @@ -141,6 +149,17 @@ if test x`echo $VERSION | egrep $CERNEXP` != x; then VERSION=`echo $VERSION | sed 's/-.*\.CERN//'` fi +#------------------------------------------------------------------------------- +# In case of user version check if the release number has been provided +#------------------------------------------------------------------------------- +if test x"$USER_VERSION" != x; then + TMP=`echo $VERSION | sed 's#.*-##g'` + if test $TMP != $VERSION; then + RELEASE=$TMP + VERSION=`echo $VERSION | sed 's#-[^-]*$##'` + fi +fi + VERSION=`echo $VERSION | sed 's/-/./g'` echo "[i] RPM compliant version: $VERSION-$RELEASE"