2012-05-05 23:24:46 -04:00
|
|
|
#!/bin/sh
|
2012-05-05 22:58:16 -04:00
|
|
|
##### -*- mode:shell-script; indent-tabs-mode:nil; sh-basic-offset:2 -*-
|
|
|
|
|
|
|
|
src_repo="$(pwd)"
|
|
|
|
tmp_dir=${TMP_DIR:="/tmp"}
|
|
|
|
|
2012-05-08 11:53:45 -04:00
|
|
|
zgrep () { (echo "$2" | grep -e "$1" >/dev/null); }
|
|
|
|
|
2012-05-05 22:58:16 -04:00
|
|
|
parse_version () {
|
2012-05-05 21:12:08 -04:00
|
|
|
local ver="$1" major="" minor="" micro="" rev=""
|
|
|
|
local next=major
|
|
|
|
for x in $(echo "$1" | sed -e 's/\([._~-]\)/ \1 /g'); do
|
|
|
|
if [ $next = rev ]; then
|
|
|
|
rev="${rev}${x}"
|
|
|
|
elif [ "$x" = "." ] || [ "$x" = "_" ] || [ "$x" = "~" ] || [ "$x" = "-" ]; then
|
|
|
|
if [ "$x" = "_" ] || [ "$x" = "~" ] || [ "$x" = "-" ]; then
|
|
|
|
next=rev
|
|
|
|
eval $next='$x'
|
|
|
|
else
|
|
|
|
case $next in
|
|
|
|
major) next=minor;;
|
|
|
|
minor) next=micro;;
|
|
|
|
micro) next=rev;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
local tmp="$(eval echo \$$next)"
|
|
|
|
eval $next='${tmp}${x}'
|
|
|
|
fi
|
|
|
|
done
|
2012-05-08 11:53:45 -04:00
|
|
|
# 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?
|
2012-05-05 21:12:08 -04:00
|
|
|
local cmajor cminor cmicro crev cver
|
2012-05-08 11:53:45 -04:00
|
|
|
cmajor="${major:-0}"
|
|
|
|
cminor="${minor:-0}"
|
|
|
|
cmicro="${micro:-0}"
|
2012-05-05 21:12:08 -04:00
|
|
|
crev="$(echo "$rev" | sed -e 's/[._~-]//')"
|
|
|
|
cver="${cmajor}.${cminor}.${cmicro}"
|
2012-05-08 11:53:45 -04:00
|
|
|
[ -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}"
|
2012-05-06 00:51:15 -04:00
|
|
|
micro="0"
|
|
|
|
ver="${major}.${minor}${rev}"
|
|
|
|
fi
|
2012-05-08 11:53:45 -04:00
|
|
|
# git-style versions
|
|
|
|
local gmajor gminor gmicro grev gver
|
2012-05-07 17:34:08 -04:00
|
|
|
gver="$(echo "$ver" | sed -e 's/[~_]/-/')"
|
|
|
|
grev="$(echo "$rev" | sed -e 's/[~_]/-/')"
|
|
|
|
gmajor="$major"
|
|
|
|
gminor="$minor"
|
|
|
|
gmicro="$micro"
|
2012-05-08 11:53:45 -04:00
|
|
|
# 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
|
2012-05-05 22:58:16 -04:00
|
|
|
echo "ver='$ver'"
|
|
|
|
echo "major='$major'"
|
|
|
|
echo "minor='$minor'"
|
|
|
|
echo "micro='$micro'"
|
|
|
|
echo "rev='$rev'"
|
2012-05-07 17:34:08 -04:00
|
|
|
echo "gver='$gver'"
|
|
|
|
echo "gmajor='$gmajor'"
|
|
|
|
echo "gminor='$gminor'"
|
|
|
|
echo "gmicro='$gmicro'"
|
|
|
|
echo "grev='$grev'"
|
2012-05-08 11:53:45 -04:00
|
|
|
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'"
|
2012-05-05 22:58:16 -04:00
|
|
|
}
|
|
|
|
|
2012-05-06 01:26:56 -04:00
|
|
|
set_fs_ver () {
|
2012-07-20 03:33:40 -04:00
|
|
|
local ver="$1" major="$2" minor="$3" micro="$4" rev="$5" hrev="$6"
|
2012-05-06 01:26:56 -04:00
|
|
|
sed -e "s|\(AC_SUBST(SWITCH_VERSION_MAJOR, \[\).*\(\])\)|\1$major\2|" \
|
|
|
|
-e "s|\(AC_SUBST(SWITCH_VERSION_MINOR, \[\).*\(\])\)|\1$minor\2|" \
|
|
|
|
-e "s|\(AC_SUBST(SWITCH_VERSION_MICRO, \[\).*\(\])\)|\1$micro\2|" \
|
|
|
|
-e "s|\(AC_INIT(\[freeswitch\], \[\).*\(\], BUG-REPORT-ADDRESS)\)|\1$ver\2|" \
|
|
|
|
-i configure.in
|
|
|
|
if [ -n "$rev" ]; then
|
2012-07-20 03:33:40 -04:00
|
|
|
[ -n "$hrev" ] || hrev="$rev"
|
2012-05-06 01:26:56 -04:00
|
|
|
sed -e "s|\(AC_SUBST(SWITCH_VERSION_REVISION, \[\).*\(\])\)|\1$rev\2|" \
|
2012-07-20 03:33:40 -04:00
|
|
|
-e "s|\(AC_SUBST(SWITCH_VERSION_REVISION_HUMAN, \[\).*\(\])\)|\1$hrev\2|" \
|
2012-05-06 01:26:56 -04:00
|
|
|
-e "s|#\(AC_SUBST(SWITCH_VERSION_REVISION\)|\1|" \
|
2012-07-20 03:33:40 -04:00
|
|
|
-e "s|#\(AC_SUBST(SWITCH_VERSION_REVISION_HUMAN\)|\1|" \
|
2012-05-06 01:26:56 -04:00
|
|
|
-i configure.in
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
gnuize () {
|
2012-05-08 14:55:44 -04:00
|
|
|
./bootstrap.sh
|
2012-05-06 01:26:56 -04:00
|
|
|
mv bootstrap.sh rebootstrap.sh
|
|
|
|
rm -f docs/AUTHORS
|
|
|
|
rm -f docs/COPYING
|
|
|
|
rm -f docs/ChangeLog
|
|
|
|
rm -rf .git
|
|
|
|
}
|
|
|
|
|
2012-05-07 16:56:45 -04:00
|
|
|
check_pwd () {
|
|
|
|
if [ ! -d .git ]; then
|
|
|
|
echo "error: must be run from within the top level of a FreeSWITCH git tree." 1>&2
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
}
|
2012-05-05 22:58:16 -04:00
|
|
|
|
2012-05-07 16:56:45 -04:00
|
|
|
check_input_ver_build () {
|
|
|
|
if [ -z "$1" ]; then
|
|
|
|
echo "usage: $0 <version> <build-number>" 1>&2
|
|
|
|
exit 1;
|
|
|
|
fi
|
|
|
|
}
|
2012-05-05 22:58:16 -04:00
|
|
|
|