ci: generalize version number handling a bit
This commit is contained in:
parent
1ecb6be009
commit
53f1b51c1a
|
@ -4,6 +4,8 @@
|
|||
src_repo="$(pwd)"
|
||||
tmp_dir=${TMP_DIR:="/tmp"}
|
||||
|
||||
zgrep () { (echo "$2" | grep -e "$1" >/dev/null); }
|
||||
|
||||
parse_version () {
|
||||
local ver="$1" major="" minor="" micro="" rev=""
|
||||
local next=major
|
||||
|
@ -26,38 +28,73 @@ parse_version () {
|
|||
eval $next='${tmp}${x}'
|
||||
fi
|
||||
done
|
||||
# The major version should never be null
|
||||
if [ -z "$major" ]; then
|
||||
echo "WARNING: parse_version was called with '$1' which is missing a major version number" >&2
|
||||
fi
|
||||
# If someone asks for the minor or micro specificially, they
|
||||
# probably expect that it won't be null. Also, vX.Y should never be
|
||||
# different from vX.Y.0 (that would be crazy), so we don't lose
|
||||
# meaningful generality by setting minor or micro to zero on vX or
|
||||
# vX.Y style versions.
|
||||
minor="${minor:-0}"
|
||||
micro="${micro:-0}"
|
||||
# centos-style versions (don't mess with the argument given for now)
|
||||
# TODO: what is the CentOS version number policy?
|
||||
local cmajor cminor cmicro crev cver
|
||||
cmajor=${major:="0"}
|
||||
cminor=${minor:="0"}
|
||||
cmicro=${micro:="0"}
|
||||
cmajor="${major:-0}"
|
||||
cminor="${minor:-0}"
|
||||
cmicro="${micro:-0}"
|
||||
crev="$(echo "$rev" | sed -e 's/[._~-]//')"
|
||||
cver="${cmajor}.${cminor}.${cmicro}"
|
||||
if [ -n "${micro}" ] && echo "$micro" | grep '^\(alpha\|beta\|rc\)' >/dev/null; then
|
||||
rev="~${micro}"
|
||||
[ -n "$crev" ] && cver="${cver}.${crev}"
|
||||
# fix up if the revision was passed in the minor or micro number
|
||||
if zgrep '^\(alpha\|beta\|rc\)' "$minor"; then
|
||||
rev="-${minor}"
|
||||
minor="0"
|
||||
micro="0"
|
||||
ver="${major}${rev}"
|
||||
fi
|
||||
if zgrep '^\(alpha\|beta\|rc\)' "$micro"; then
|
||||
rev="-${micro}"
|
||||
micro="0"
|
||||
ver="${major}.${minor}${rev}"
|
||||
fi
|
||||
# git-style versions
|
||||
local gmajor gminor gmicro grev gver
|
||||
gver="$(echo "$ver" | sed -e 's/[~_]/-/')"
|
||||
grev="$(echo "$rev" | sed -e 's/[~_]/-/')"
|
||||
gmajor="$major"
|
||||
gminor="$minor"
|
||||
gmicro="$micro"
|
||||
[ -n "$crev" ] && cver="${cver}.${crev}"
|
||||
# debian-style versions
|
||||
local dmajor dminor dmicro drev dver
|
||||
dver="$(echo "$ver" | sed -e 's/[-_]/~/')"
|
||||
drev="$(echo "$rev" | sed -e 's/[-_]/~/')"
|
||||
dmajor="$major"
|
||||
dminor="$minor"
|
||||
dmicro="$micro"
|
||||
# return variables
|
||||
echo "ver='$ver'"
|
||||
echo "major='$major'"
|
||||
echo "minor='$minor'"
|
||||
echo "micro='$micro'"
|
||||
echo "rev='$rev'"
|
||||
echo "cver='$cver'"
|
||||
echo "cmajor='$cmajor'"
|
||||
echo "cminor='$cminor'"
|
||||
echo "cmicro='$cmicro'"
|
||||
echo "crev='$crev'"
|
||||
echo "gver='$gver'"
|
||||
echo "gmajor='$gmajor'"
|
||||
echo "gminor='$gminor'"
|
||||
echo "gmicro='$gmicro'"
|
||||
echo "grev='$grev'"
|
||||
echo "dver='$dver'"
|
||||
echo "dmajor='$dmajor'"
|
||||
echo "dminor='$dminor'"
|
||||
echo "dmicro='$dmicro'"
|
||||
echo "drev='$drev'"
|
||||
echo "cver='$cver'"
|
||||
echo "cmajor='$cmajor'"
|
||||
echo "cminor='$cminor'"
|
||||
echo "cmicro='$cmicro'"
|
||||
echo "crev='$crev'"
|
||||
}
|
||||
|
||||
set_fs_ver () {
|
||||
|
|
|
@ -14,7 +14,7 @@ build="b${2-0}"
|
|||
distro="${3-unstable}"
|
||||
codename="${4-sid}"
|
||||
|
||||
fver="${ver}~${nightly}~${build}"
|
||||
fver="${dver}~${nightly}~${build}"
|
||||
fname="freeswitch-$fver"
|
||||
orig="freeswitch_$fver.orig"
|
||||
ddir=$src_repo/debbuild
|
||||
|
@ -23,7 +23,7 @@ bdir=$src_repo/debbuild/$fname
|
|||
mkdir -p $ddir
|
||||
git clone . $bdir
|
||||
cd $bdir
|
||||
set_fs_ver "$ver" "$major" "$minor" "$micro" "$rev"
|
||||
set_fs_ver "$gver" "$gmajor" "$gminor" "$gmicro" "$grev"
|
||||
cd libs
|
||||
getlib () {
|
||||
f="${1##*/}"
|
||||
|
|
Loading…
Reference in New Issue