From 02c0637c0c22e8b1e4d7e94ccfeda2f4b9ff15b4 Mon Sep 17 00:00:00 2001 From: Travis Cross Date: Sun, 6 May 2012 02:58:16 +0000 Subject: [PATCH] ci: factor out common code --- scripts/ci/common.sh | 29 +++++++++++++++++++++++++++++ scripts/ci/debsrcbuilder.sh | 21 ++++----------------- scripts/ci/rpmbuilder.sh | 21 ++++----------------- scripts/ci/sounds-en-us-callie.sh | 20 ++++---------------- scripts/ci/src_tarball.sh | 22 ++++------------------ 5 files changed, 45 insertions(+), 68 deletions(-) create mode 100755 scripts/ci/common.sh diff --git a/scripts/ci/common.sh b/scripts/ci/common.sh new file mode 100755 index 0000000000..61f8549d6f --- /dev/null +++ b/scripts/ci/common.sh @@ -0,0 +1,29 @@ +#!/bin/bash +##### -*- mode:shell-script; indent-tabs-mode:nil; sh-basic-offset:2 -*- + +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) + echo "ver='$ver'" + echo "major='$major'" + echo "minor='$minor'" + echo "micro='$micro'" + echo "rev='$rev'" +} + +if [ ! -d .git ]; then + echo "error: must be run from within the top level of a FreeSWITCH git tree." 1>&2 + exit 1; +fi + +if [ -z "$1" ]; then + echo "usage: $0 MAJOR.MINOR.MICRO[.REVISION] BUILD_NUMBER" 1>&2 + exit 1; +fi + diff --git a/scripts/ci/debsrcbuilder.sh b/scripts/ci/debsrcbuilder.sh index 4d9175c4ac..3551f3fc49 100755 --- a/scripts/ci/debsrcbuilder.sh +++ b/scripts/ci/debsrcbuilder.sh @@ -1,24 +1,11 @@ #!/bin/bash ##### -*- mode:shell-script; indent-tabs-mode:nil; sh-basic-offset:2 -*- -src_repo="$(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 - -if [ -z "$1" ]; then - echo "usage: ./scripts/ci/debbuilder.sh MAJOR.MINOR.MICRO[.REVISION] BUILD_NUMBER" 1>&2 - exit 1; -fi - -ver="$1" -major=$(echo "$ver" | cut -d. -f1) -minor=$(echo "$ver" | cut -d. -f2) -micro=$(echo "$ver" | cut -d. -f3) -rev=$(echo "$ver" | cut -d. -f4) +sdir="." +[ -n "${0%/*}" ] && sdir="${0%/*}" +. $sdir/common.sh +eval $(parse_version "$1") datestamp="$(date +%Y%m%dT%H%M%SZ)" nightly="n${datestamp}" build="b$2" diff --git a/scripts/ci/rpmbuilder.sh b/scripts/ci/rpmbuilder.sh index 55e484d014..5f2dd20ec6 100755 --- a/scripts/ci/rpmbuilder.sh +++ b/scripts/ci/rpmbuilder.sh @@ -1,24 +1,11 @@ #!/bin/bash ##### -*- mode:shell-script; indent-tabs-mode:nil; sh-basic-offset:2 -*- -src_repo="$(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 - -if [ -z "$1" ]; then - echo "usage: ./scripts/ci/rpmbuilder.sh MAJOR.MINOR.MICRO[.REVISION] BUILD_NUMBER" 1>&2 - exit 1; -fi - -ver="$1" -major=$(echo "$ver" | cut -d. -f1) -minor=$(echo "$ver" | cut -d. -f2) -micro=$(echo "$ver" | cut -d. -f3) -rev=$(echo "$ver" | cut -d. -f4) +sdir="." +[ -n "${0%/*}" ] && sdir="${0%/*}" +. $sdir/common.sh +eval $(parse_version "$1") build="$2" dst_name="freeswitch-$major.$minor.$micro" diff --git a/scripts/ci/sounds-en-us-callie.sh b/scripts/ci/sounds-en-us-callie.sh index 1e7ec20c38..fbcf1ea422 100755 --- a/scripts/ci/sounds-en-us-callie.sh +++ b/scripts/ci/sounds-en-us-callie.sh @@ -1,23 +1,11 @@ #!/bin/bash ##### -*- mode:shell-script; indent-tabs-mode:nil; sh-basic-offset:2 -*- -src_repo="$(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 - -if [ -z "$1" ]; then - echo "usage: ./scripts/ci/rpmbuilder.sh MAJOR.MINOR.MICRO[.REVISION] BUILD_NUMBER" 1>&2 - exit 1; -fi - -ver="$1" -major=$(echo "$ver" | cut -d. -f1) -minor=$(echo "$ver" | cut -d. -f2) -micro=$(echo "$ver" | cut -d. -f3) +sdir="." +[ -n "${0%/*}" ] && sdir="${0%/*}" +. $sdir/common.sh +eval $(parse_version "$1") build="$2" cd rpmbuild/SOURCES diff --git a/scripts/ci/src_tarball.sh b/scripts/ci/src_tarball.sh index 926ef6ec89..27c9c77a8a 100755 --- a/scripts/ci/src_tarball.sh +++ b/scripts/ci/src_tarball.sh @@ -1,25 +1,11 @@ #!/bin/bash ##### -*- mode:shell-script; indent-tabs-mode:nil; sh-basic-offset:2 -*- -src_repo="$(pwd)" +sdir="." +[ -n "${0%/*}" ] && sdir="${0%/*}" +. $sdir/common.sh -if [ ! -d .git ]; then - echo "error: must be run from within the top level of a FreeSWITCH git tree." 1>&2 - exit 1; -fi - -if [ -z "$1" ]; then - echo "usage: ./scripts/dailys.sh MAJOR.MINOR.MICRO[.REVISION] BUILD_NUMBER" 1>&2 - exit 1; -fi - -ver="$1" -major=$(echo "$ver" | cut -d. -f1) -minor=$(echo "$ver" | cut -d. -f2) -micro=$(echo "$ver" | cut -d. -f3) -rev=$(echo "$ver" | cut -d. -f4) - -tmp_dir=${TMP_DIR:="/tmp"} +eval $(parse_version "$1") dst_name="freeswitch-$major.$minor.$micro" dst_parent="${tmp_dir}/jenkis.$$/"