ci: add support for more flexible version numbers

This commit is contained in:
Travis Cross 2012-05-06 01:12:08 +00:00
parent 02c0637c0c
commit 2769fc6585
4 changed files with 43 additions and 12 deletions

View File

@ -5,16 +5,44 @@ src_repo="$(pwd)"
tmp_dir=${TMP_DIR:="/tmp"}
parse_version () {
local ver="$1"
local major=$(echo "$ver" | cut -d. -f1)
local minor=$(echo "$ver" | cut -d. -f2)
local micro=$(echo "$ver" | cut -d. -f3)
local rev=$(echo "$ver" | cut -d. -f4)
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
local cmajor cminor cmicro crev cver
cmajor=${major:="0"}
cminor=${minor:="0"}
cmicro=${micro:="0"}
crev="$(echo "$rev" | sed -e 's/[._~-]//')"
cver="${cmajor}.${cminor}.${cmicro}"
[ -n "$crev" ] && cver="${cver}.${crev}"
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'"
}
if [ ! -d .git ]; then
@ -23,7 +51,7 @@ if [ ! -d .git ]; then
fi
if [ -z "$1" ]; then
echo "usage: $0 MAJOR.MINOR.MICRO[.REVISION] BUILD_NUMBER" 1>&2
echo "usage: $0 <version> <build-number>" 1>&2
exit 1;
fi

View File

@ -12,7 +12,7 @@ build="b$2"
input_distro=$3
distro=${input_distro:="unstable"}
dst_version="$major.$minor.$micro"
dst_version="$ver"
dst_name="freeswitch-${dst_version}"
dst_parent="/tmp/"
dst_dir="/tmp/${dst_name}"

View File

@ -8,7 +8,7 @@ sdir="."
eval $(parse_version "$1")
build="$2"
dst_name="freeswitch-$major.$minor.$micro"
dst_name="freeswitch-$cmajor.$cminor.$cmicro"
dst_parent="/tmp/"
dst_dir="/tmp/$dst_name"
@ -16,7 +16,7 @@ mkdir -p $src_repo/rpmbuild/{SOURCES,BUILD,BUILDROOT,i386,x86_64,SPECS}
cd $src_repo
rpmbuild --define "VERSION_NUMBER $ver" \
rpmbuild --define "VERSION_NUMBER $cver" \
--define "BUILD_NUMBER $build" \
--define "_topdir %(pwd)/rpmbuild" \
--define "_rpmdir %{_topdir}" \
@ -33,7 +33,7 @@ mv $src_repo/rpmbuild/*/*.rpm $src_repo/RPMS/.
cat 1>&2 <<EOF
----------------------------------------------------------------------
The v$ver-$build RPMs have been rolled, now we
The v$cver-$build RPMs have been rolled, now we
just need to push them to the YUM Repo
----------------------------------------------------------------------
EOF

View File

@ -7,7 +7,8 @@ sdir="."
eval $(parse_version "$1")
dst_name="freeswitch-$major.$minor.$micro"
dst_name="freeswitch-$ver"
dst_cname="freeswitch-$cmajor.$cminor.$cmicro"
dst_parent="${tmp_dir}/jenkis.$$/"
dst_dir="${tmp_dir}/jenkins.$$/$dst_name"
@ -24,7 +25,7 @@ cd $dst_dir
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$major.$minor.$micro\2|" \
-e "s|\(AC_INIT(\[freeswitch\], \[\).*\(\], BUG-REPORT-ADDRESS)\)|\1$ver\2|" \
-i configure.in
if [ -n "$rev" ]; then
@ -49,12 +50,14 @@ tar -cvf ${dst_name}.tar $dst_name
# gzip -9 -c ${dst_name}.tar > $dst_name.tar.gz || echo "gzip not available"
bzip2 -z -k ${dst_name}.tar || echo "bzip2 not available"
cp -al ${dst_name}.tar.bz2 ${dst_cname}.tar.bz2
# xz -z -9 -k ${dst_name}.tar || echo "xz / xz-utils not available"
rm -rf ${dst_name}.tar $dst_dir
mkdir -p ${src_repo}/src_dist
mv -f ${dst_name}.tar.* ${src_repo}/src_dist
mv -f ${dst_cname}.tar.* ${src_repo}/src_dist
cat 1>&2 <<EOF
----------------------------------------------------------------------