[Asterisk-code-review] build tools: Update for codec migration to git (repotools[master])
George Joseph
asteriskteam at digium.com
Tue Jul 19 16:06:28 CDT 2016
George Joseph has uploaded a new change for review.
https://gerrit.asterisk.org/3255
Change subject: build_tools: Update for codec migration to git
......................................................................
build_tools: Update for codec migration to git
Change-Id: I41c298d17529cc281d4454825272793d31c7e75a
---
A build_tools/Makefile.product_rules
M build_tools/Makefile.version
A build_tools/buildfuncs
A build_tools/make_product
A build_tools/make_tag
A build_tools/make_tags
M build_tools/make_version
7 files changed, 701 insertions(+), 163 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/repotools refs/changes/55/3255/1
diff --git a/build_tools/Makefile.product_rules b/build_tools/Makefile.product_rules
new file mode 100644
index 0000000..ab8491b
--- /dev/null
+++ b/build_tools/Makefile.product_rules
@@ -0,0 +1,168 @@
+
+MODULE_NAME=$(notdir $(PWD))
+
+all: $(MODULE_NAME).so
+
+include repotools/build_tools/Makefile.version
+
+export CC
+export OSARCH
+export CFLAGS
+export OPT
+
+CC=gcc
+LD=ld
+TAR=tar
+
+OSARCH=$(shell uname -s)
+
+FLAVOR_OPT?=-pipe -O3
+FLAVOR_ARCH?=generic
+WARN=-Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations
+#WARN+=-Wno-pointer-sign #Some versions of gcc (such as the one included with RHEL4) don't like this.
+DEBUG=-g3
+
+CPUARCH?=$(shell uname -m)
+
+ifeq ($(CPUARCH),i686)
+FLAVOR_LDEMUL?=elf_i386
+FLAVOR_MODE?=-m32
+FLAVOR_ARCH=x86_32
+ASTLIBDIR:=/usr/lib/asterisk
+endif
+
+ifeq ($(CPUARCH),x86_64)
+FLAVOR_LDEMUL?=elf_x86_64
+FLAVOR_MODE?=-m64
+FLAVOR_ARCH=x86_64
+OPT+=-fPIC
+CFLAGS+=-fPIC
+ifeq ($(wildcard /usr/lib64),)
+ASTLIBDIR:=/usr/lib/asterisk
+else
+ASTLIBDIR:=/usr/lib64/asterisk
+endif
+endif
+
+CFLAGS+=-D_REENTRANT -D_GNU_SOURCE -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
+OPT+=$(FLAVOR_OPT)
+
+SOLINK=-shared -Wl,--version-script,$(subst .so,.exports,$@)
+STRIP:=strip
+INSTALL:=install
+ASTINCDIR:=./asterisk/include
+STATIC:=-static
+WHOLE_OPT:=-fwhole-program
+
+ifneq ($(COPYPROTECT),)
+CFLAGS+=-DCOPYPROTECT
+ifeq ($(COPYPROTECT), FAKE)
+CFLAGS+=-DFAKECOPYPROTECT
+ifneq ($(MAXCALLS),)
+CFLAGS+=-DMAXCALLS=$(MAXCALLS)
+endif # MAXCALLS
+else # COPYPROTECT && COPYPROTECT != FAKE
+CFLAGS+=-Ilibcp
+LIBCP=libcp/cp.o
+
+LIBS+=-Llibcp/$(shell $(MAKE) --no-print-directory -C libcp z_lib) -lz
+LIBS+=-Llibcp/$(shell $(MAKE) --no-print-directory -C libcp ssl_lib) -lssl -lcrypto
+endif # COPYPROTECT=FAKE
+endif # COPYPROTECT
+
+ifneq ($(OSARCH),)
+ ifeq ($(OSARCH),SunOS)
+ SOLINK=-shared -fPIC -mimpure-text
+ INSTALL=ginstall
+ CFLAGS+=-DSOLARIS
+ ASTLIBDIR=/opt/asterisk/lib
+ STATIC=-static
+ else
+ ifeq ($(OSARCH),Darwin)
+ SOLINK=-dynamic -bundle -undefined suppress -force_flat_namespace
+ STRIP=strip -r -u
+ else
+ ifeq ($(OSARCH),FreeBSD)
+ INSTALL=ginstall
+ ASTLIBDIR=/usr/local/lib/asterisk
+ endif
+ endif
+ endif
+endif
+
+$(LIBCP):
+ $(MAKE) -C libcp OPT="$(OPT)" DEBUG="$(DEBUG)"
+
+optarch.h: FORCE
+ @echo "#define OPTARCH \" (optimized for $(FLAVOR_ARCH))\"" > $@.tmp
+ @cmp -s $@.tmp $@ || mv $@.tmp $@
+ @rm -f $@.tmp
+
+asterisk/include/asterisk/buildopts.h: | asterisk/configure
+ @echo "Initializing asterisk source directory. This may take a minute... $(MAKE)"
+ @(cd asterisk && $(MAKE) distclean 2>/dev/null ; ./configure && $(MAKE) include/asterisk/buildopts.h) >/dev/null
+ @sed -i -e /GCC_ATOMICS/d asterisk/include/asterisk/autoconfig.h
+
+include repotools/build_tools/Makefile.dependencies
+
+CFLAGS+=$(MODULE_SDK_CFLAGS)
+MODULE_OBJS=$(MODULE_NAME).o
+
+$(MODULE_NAME).o:: CFLAGS+=-DAST_MODULE=\"$(MODULE_NAME)\" -I$(ASTINCDIR)
+
+.c.o::
+ $(CC) $(FLAVOR_MODE) -c $< -o $@ $(CFLAGS) $(OPT) $(DEBUG) $(WARN) $(MAKE_DEPS)
+
+$(MODULE_NAME).o: $(MODULE_NAME).c optarch.h version.h asterisk/include/asterisk/buildopts.h
+ $(CC) $(FLAVOR_MODE) -c $< -o $@ $(CFLAGS) $(OPT) $(DEBUG) $(WARN) $(MAKE_DEPS)
+
+$(MODULE_NAME).so: $(MODULE_OBJS) $(MODULE_SDK_LIB) $(MODULE_SDK_OBJS) $(LIBCP)
+ $(LD) -m $(FLAVOR_LDEMUL) -r -o $(MODULE_NAME)_complete.o $^ $(STATIC) $(LDFLAGS) $(LIBS)
+ $(CC) $(FLAVOR_MODE) $(DEBUG) $(SOLINK) -o $@ $(MODULE_NAME)_complete.o $(WHOLE_OPT) $(OPT)
+
+clean::
+ rm -f *.o *.so $(MODULE_SDK_OBJS) $(MODULE_SDK_LIB)
+
+distclean:: clean
+ rm -f *.tar.gz
+ if [ -d libcp ] ; then $(MAKE) -C libcp clean ; fi
+ $(MAKE) -C asterisk distclean
+ rm -f optarch.h version.h
+
+install: all
+ $(INSTALL) -m 755 $(MODULE_NAME).so $(ASTLIBDIR)/modules/$(MODULE_NAME).so
+
+# ---------------------
+# targets for building CPU-flavor binaries
+
+flavors: DEBUG=-g0
+flavors: repotools/build_tools/make_cpu_flavors $(LIBCP)
+ @repotools/build_tools/make_cpu_flavors module DEBUG="$(DEBUG)"
+
+flavor-module-clean:
+ @rm -f $(MODULE_NAME).so
+
+flavor-module: TGTDIR=$(MODULE_NAME)-$(PRODUCT_VERSION)-$(FLAVOR_ARCH)
+flavor-module: $(MODULE_NAME).so
+ @$(STRIP) $(MODULE_NAME).so
+ @mkdir $(TGTDIR)
+ @mv $(MODULE_NAME).so $(TGTDIR)
+ @cp LICENSE $(TGTDIR)
+ @$(TAR) --create --owner 0 --group 0 --file $(TGTDIR).tar.gz --gzip $(TGTDIR)
+ @rm -rf $(TGTDIR)
+ @echo Build for $(FLAVOR_ARCH) complete.
+
+# ---------------------
+
+FORCE:
+
+.PHONY: all
+.PHONY: buildver
+.PHONY: clean
+.PHONY: install
+.PHONY: flavors
+.PHONY: flavor-module-clean
+.PHONY: flavor-module
+
+
+
diff --git a/build_tools/Makefile.version b/build_tools/Makefile.version
index 7b00d80..bb8bee5 100644
--- a/build_tools/Makefile.version
+++ b/build_tools/Makefile.version
@@ -3,16 +3,11 @@
export $(VERSION_VARIABLE)
-DIR_PREFIX = $(shell [ -d repotools ] && echo repotools/)
-
-$(VERSION_VARIABLE):=$(shell $(DIR_PREFIX)build_tools/make_version . $(VERSION_PRODUCT_PATH))
+$(VERSION_VARIABLE):=$(shell repotools/build_tools/make_version .)
$(VERSION_HEADER): version_FORCE
- @$(DIR_PREFIX)build_tools/make_version_h $(VERSION_VARIABLE) > $@.tmp
+ @repotools/build_tools/make_version_h $(VERSION_VARIABLE) > $@.tmp
@cmp -s $@.tmp $@ || mv $@.tmp $@
@rm -f $@.tmp
-
-.version::
- @echo $($(VERSION_VARIABLE)) > $@
version_FORCE:
diff --git a/build_tools/buildfuncs b/build_tools/buildfuncs
new file mode 100755
index 0000000..b207e55
--- /dev/null
+++ b/build_tools/buildfuncs
@@ -0,0 +1,404 @@
+# Shell script functions for performing various parts of the binary module build process
+
+# Extract an Asterisk version number from the argument supplied, validating that
+# it is a supported version to build against
+
+extract_astversion() {
+ # args are:
+ #
+ # $1: version string of the format X.X[.X[.X]_Y.Y.Y[.Y], where
+ # the X components are the Asterisk version
+
+ ASTVERSION="${1%_*}"
+
+ if [[ "${ASTVERSION}" == "${1}" ]];
+ then
+ echo "An Asterisk version number must be included in the module version to build; ${1} is not valid."
+ exit 1
+ fi
+
+ case ${ASTVERSION} in
+ (1.2)
+ ;;
+ (1.4)
+ ;;
+ (1.6.[0-9])
+ ;;
+ (1.6.[1-9][0-9])
+ ;;
+ (1.6.[0-9].*)
+ ;;
+ (1.6.[1-9][0-9].*)
+ ;;
+ (1.8.[0-9])
+ ;;
+ (1.8.[0-9][0-9])
+ ;;
+ (10|10.*)
+ ;;
+ (11|11.*)
+ ;;
+ (12|12.*)
+ ;;
+ (13|13.*)
+ ;;
+ (C.3)
+ ;;
+ (*)
+ echo "Asterisk version ${ASTVERSION} is not supported by this build system."
+ exit 1
+ ;;
+ esac
+
+ # determine the LIBDIR path for CentOS 64bit support
+ LIBDIR="/usr/lib"
+ if [ `uname -m` = 'x86_64' -a -d /usr/lib64 ]
+ then
+ LIBDIR="/usr/lib64"
+ fi
+
+}
+
+# Obtain, build and install a specified version of Asterisk, or the baseline version
+# for that release series
+build_asterisk() {
+ # args are:
+ #
+ # $1: Asterisk version to build
+ # $2: if non-empty, build exact version, not baseline
+ BEBRANCH=be/branches
+ BETAG=be/tags
+
+ case ${2}${1} in
+ (1.2)
+ ASTPATH=1.2.33
+ ;;
+ (1.4)
+ ASTPATH=1.4.25
+ ;;
+ (1.6.2.0)
+ ASTPATH=1.6.2.8-rc1
+ ;;
+ (1.8.0)
+ ASTPATH=1.8.2.3
+ ;;
+ (1.8.2)
+ ASTPATH=1.8.2-rc1
+ ;;
+ (1.8.4)
+ ASTPATH=1.8.4
+ ;;
+ (digiumphones1.8.11)
+ ASTPATH=certified/branches/1.8.11
+ ;;
+ (digiumphones10.0)
+ ASTPATH=10-digiumphones
+ ;;
+ (10.*)
+ ASTPATH=10
+ ;;
+ (digiumphones11.*)
+ ASTPATH=11
+ ;;
+ (digiumphones12.*)
+ ASTPATH=12
+ ;;
+ (digiumphones13.*)
+ ASTPATH=13
+ ;;
+ (11.*)
+ ASTPATH=11
+ ;;
+ (12.*)
+ ASTPATH=12
+ ;;
+ (13.*)
+ ASTPATH=13
+ ;;
+ (1.6.[1-9])
+ ASTPATH=${1}.0
+ ;;
+ (1.6.[1-9][0-9])
+ ASTPATH=${1}.0
+ ;;
+ (C.3)
+ ASTPATH=${BEBRANCH}/C.3
+ ;;
+ (*)
+ ASTPATH=${1}
+ ;;
+ esac
+
+ echo "Building Asterisk version ${ASTPATH}..."
+
+ git clone -b ${ASTPATH} git://git.asterisk.org/asterisk/asterisk.git asterisk
+ cd asterisk
+ if [[ ${ASTPATH} == ${OSTAG}/1.2.* ]];
+ then
+ apt-get update
+ apt-get install --yes libssl-dev
+ make
+ make install
+ cp include/asterisk.h /usr/include
+ apt-get remove --purge --yes libssl-dev
+ else
+ ./configure --disable-xmldoc --libdir=$LIBDIR
+ # ensure that the built modules don't use GCC atomic operations
+ sed -i -e /GCC_ATOMICS/d include/asterisk/autoconfig.h
+ make MOD_SUBDIRS=main OTHER_SUBDIRS=
+ make MOD_SUBDIRS=main OTHER_SUBDIRS= install
+ fi
+ cd ..
+ rm -rf asterisk
+}
+
+# Create a directory in Subversion if it does not exist.
+make_staging_dir() {
+ svn ls ${1} &> /dev/null || svn mkdir ${1} -m "create staging directory"
+}
+
+# Ensure that GCC 4.3.0 or higher is in use
+check_gcc43() {
+ cat <<EOF | gcc -E -o /dev/null - || exit 1
+#if (__GNUC__ < 4) || (__GNUC_MINOR__ < 3)
+#error GCC 4.3.x or higher required (gcc).
+#endif
+EOF
+ cat <<EOF | cc -E -o /dev/null - || exit 1
+#if (__GNUC__ < 4) || (__GNUC_MINOR__ < 3)
+#error GCC 4.3.x or higher required (cc).
+#endif
+EOF
+ cat <<EOF | g++ -E -o /dev/null - || exit 1
+#if (__GNUC__ < 4) || (__GNUC_MINOR__ < 3)
+#error GCC 4.3.x or higher required (g++).
+#endif
+EOF
+ cat <<EOF | c++ -E -o /dev/null - || exit 1
+#if (__GNUC__ < 4) || (__GNUC_MINOR__ < 3)
+#error GCC 4.3.x or higher required (c++).
+#endif
+EOF
+}
+
+# Make a release tag from a product with API-numbered branches
+# e.g.: /svn/<project>/<product>/branches/<API version>/<product version>
+make_branch_tag() {
+ FB="${4%.*}"
+ rm -rf tag-tmp
+ NT=${1}/${2}/tags/${3}_${4}
+ # skip it if it exists already
+ svn ls ${NT} 2> /dev/null 1>&2 && exit
+ svn cp ${1}/${2}/branches/${FB}/asterisk-${3} ${NT} -m 'tag for release'
+ svn co ${NT} tag-tmp
+ pushd tag-tmp
+ make .version
+ svn add .version
+ propset_txt .version
+ autotag_externals .
+ svn commit -m 'add version information'
+ popd
+ rm -rf tag-tmp
+}
+
+# Make release tags from a product with API-numbered branches
+# e.g.: /svn/<project>/<product>/branches/<API version>
+make_branch_tags() {
+ FB="${3%.*}"
+ rm -rf tag-tmp
+ for AB in `svn ls ${1}/${2}/branches/${FB} 2> /dev/null`
+ do
+ AB="${AB%/}"
+ AT="${AB#asterisk-}"
+ NT=${1}/${2}/tags/${AT}_${3}
+ # skip it if it exists already
+ svn ls ${NT} 2> /dev/null 1>&2 && continue
+ svn cp ${1}/${2}/branches/${FB}/${AB} ${NT} -m 'tag for release'
+ svn co ${NT} tag-tmp
+ pushd tag-tmp
+ make .version
+ svn add .version
+ propset_txt .version
+ autotag_externals .
+ svn commit -m 'add version information'
+ popd
+ rm -rf tag-tmp
+ done
+}
+
+# Make release tag from a product without API-numbered branches
+# e.g.: /svn/<project>/<product>/trunk
+make_trunk_tag() {
+ svn ls ${1}/${2}/trunk &> /dev/null && for AB in trunk
+ do
+ NT=${1}/${2}/tags/${3}
+ # skip it if it exists already
+ svn ls ${NT} 2> /dev/null 1>&2 && continue
+ svn cp ${1}/${2}/trunk ${NT} -m 'tag for release'
+ svn co ${NT} tag-tmp
+ pushd tag-tmp
+ make .version
+ svn add .version
+ propset_txt .version
+ autotag_externals .
+ svn commit -m 'add version information'
+ popd
+ rm -rf tag-tmp
+ done
+}
+
+# upload release to the appropriate staging directory
+# takes a base filename and base staging directory i.e.
+# <product> https://origsvn.digium.com/svn/sites/downloads.digium.com/stagin/telephony/<product>
+commit_to_staging() {
+ FN=${1}
+ P=${2}
+ make_staging_dir ${P}
+ if [ "${ASTVERSION}" == "1.2" ]; then
+ P=${P}/unsupported
+ make_staging_dir ${P}
+ P=${P}/asterisk-${ASTVERSION}
+ make_staging_dir ${P}
+ P=${P}/Linux
+ make_staging_dir ${P}
+ else
+ P=${P}/asterisk-${ASTVERSION}
+ make_staging_dir ${P}
+ fi
+ case `uname -m` in
+ (x86_64)
+ A=x86-64
+ ;;
+ (i686)
+ A=x86-32
+ ;;
+ esac
+ P=${P}/${A}
+ make_staging_dir ${P}
+ svn ls ${P} &> /dev/null || svn mkdir ${P} -m "create staging directory"
+ svn co ${P} staging
+ mv ${FN}*.tar.gz staging
+ cd staging
+ svn add ${FN}*.tar.gz
+ cd ..
+ svn commit staging -m "commit ${1} builds to staging"
+ rm -rf staging
+}
+
+#
+# Parse arguments the fax build scripts are expecting. Can be used for other
+# build scripts wanting the same parameters as well.
+#
+# usage: parse_fax_args "$@"
+#
+# This function parses the following arguments:
+# --help, -h, -?
+# --asterisk <version>
+#
+# --version <product version>
+# --product-version <product version>
+# --product_version <product version>
+# --prodversion <product version>
+#
+# --commit
+# --svn-path
+#
+# --res_fax <res_fax version>
+# --res-fax <res_fax version>
+#
+# Upon successful parsing the following variables may be set:
+# ASTVERSION: the asterisk version
+# PRODVERSION: the product version (will be written to .version in the
+# source dir)
+# RES_FAX: the res_fax version
+# SVN_PATH: set to '1' if --svn-path is passed
+# COMMIT: set to '1' if --commit is passed
+# ARGS: an array containing any extra positional arguments
+#
+# Positional arguments can be accessed using the ARGS array.
+#
+# echo we have ${#ARGS[@]} extra arguments
+#
+# echo ${ARGS[0]} ${ARGS[1]}
+#
+# for arg in "${ARGS[@]}"
+# do
+# echo $arg
+# done
+#
+# If errors are encountered an error message is printed and the function
+# returns non zero. Unrecognized arguments are considered as errors.
+#
+# If --help, -h, or -? are passed then '2' is returned.
+#
+# In order to read non zero return values for scrips started with 'bash -e',
+# you need to use 'set +e' before calling this function:
+#
+# set +e
+# parse_fax_args "$@"
+# RES=$?
+# set -e
+#
+#
+parse_fax_args()
+{
+ local argument=""
+ ARGS=()
+
+ for arg in "$@"
+ do
+ case "$arg" in
+ # arguments that do not require parameters
+ --commit)
+ COMMIT=1
+ ;;
+
+ --svn-path)
+ SVN_PATH=1
+ ;;
+
+ --help|-h|-\?)
+ return 2
+ ;;
+
+ # additional arguments are params for args or arguments the
+ # need parameters
+ --*)
+ argument="${arg#--}"
+ ;;
+
+ *)
+ case "$argument" in
+ asterisk)
+ ASTVERSION="$arg"
+ ;;
+
+ version|product_version|product-version|prodversion)
+ PRODVERSION="$arg"
+ ;;
+
+ res_fax|res-fax)
+ RES_FAX="$arg"
+ ;;
+
+ "")
+ ARGS=("${ARGS[@]}" "$arg")
+ ;;
+
+ *)
+ echo "error: unknown argument '--$argument'"
+ return 1
+ ;;
+ esac
+ argument=""
+ ;;
+ esac
+ done
+
+ if [ -n "$argument" ]
+ then
+ echo "error: unknown argument '--$argument'"
+ return 1
+ fi
+}
+
diff --git a/build_tools/make_product b/build_tools/make_product
new file mode 100755
index 0000000..3870af3
--- /dev/null
+++ b/build_tools/make_product
@@ -0,0 +1,74 @@
+#!/bin/bash -e
+
+# args
+#
+# $1: tagged version to build (format is X.X_Y.Y.Y)
+
+product=`basename $PWD`
+
+last_tag=0
+commit_to_staging=0
+TAG=
+
+while [ ${#@} -gt 0 ] ; do
+ case ${1} in
+ --last-tag)
+ last_tag=1
+ ;;
+ --commit-to-staging)
+ commit_to_staging=1
+ ;;
+ *)
+ TAG=$1
+ ;;
+ esac
+ shift
+done
+
+if [ -z "$TAG" ] ; then
+ if [ $last_tag -eq 0 ] ; then
+ echo "Usage: ${0} --last-tag | <X.X_Y.Y.Y> [ --commit-to-staging ]"
+ exit 1
+ fi
+fi
+
+if [ $last_tag -eq 1 ] ; then
+ TAG=`git describe --tags`
+else
+ check=`git tag -l $TAG`
+ if [ -z "$TAG" ] ; then
+ echo "Tag $TAG not found."
+ exit 1
+ fi
+fi
+
+if [ -n "$(git status --porcelain)" ]; then
+ echo "The working directory has uncommitted changes."
+ exit 1
+fi
+
+current_head=`git log -n 1 --pretty=format:%H`
+tag_commit=`git describe --tags --long --abbrev=40`
+tag_commit=%{tag_commit##*-g}
+
+if [ "$current_head" != "$tag_commit" ] ; then
+ git checkout $TAG
+fi
+
+. repotools/build_tools/buildfuncs
+
+extract_astversion $TAG
+ASTBRANCH=${ASTVERSION%%.*}
+
+make -C asterisk distclean &>/dev/null || :
+git submodule update
+
+echo "Building $product version $TAG..."
+
+make PRODUCT_VERSION=$TAG flavors
+
+exit 0
+
+if [ $commit_to_staging -eq 1 ]; then
+ commit_to_staging $product https://origsvn.digium.com/svn/sites/downloads.digium.com/staging/telephony/$product
+fi
diff --git a/build_tools/make_tag b/build_tools/make_tag
new file mode 100755
index 0000000..f96c8a5
--- /dev/null
+++ b/build_tools/make_tag
@@ -0,0 +1,21 @@
+#!/bin/bash -e
+
+# args
+#
+# $1: module to tag
+# $2: version to tag (1.4, 1.6.2.0, 1.8.0, ...)
+# $3: tag to make
+
+. commbuild/buildfuncs
+
+R=https://origsvn.digium.com/svn/codecs
+
+case ${1} in
+(codec_g729a | codec_siren7 | codec_siren14 | codec_silk)
+ make_branch_tag ${R} ${1} ${2} ${3}
+ ;;
+(*)
+ echo "Unknown module ${1}."
+ exit 1
+ ;;
+esac
diff --git a/build_tools/make_tags b/build_tools/make_tags
new file mode 100755
index 0000000..cfc4f04
--- /dev/null
+++ b/build_tools/make_tags
@@ -0,0 +1,23 @@
+#!/bin/bash -e
+
+# args
+#
+# $1: module to tag
+# $2: tag to make
+
+. commbuild/buildfuncs
+
+R=https://origsvn.digium.com/svn/codecs
+
+case ${1} in
+(benchg729 | benchsiren7 | benchsiren14 | benchsilk)
+ make_trunk_tag ${R} ${1} ${2}
+ ;;
+(codec_g729a | codec_siren7 | codec_siren14 | codec_silk)
+ make_branch_tags ${R} ${1} ${2}
+ ;;
+(*)
+ echo "Unknown module ${1}."
+ exit 1
+ ;;
+esac
diff --git a/build_tools/make_version b/build_tools/make_version
index cd90325..ab823e7 100755
--- a/build_tools/make_version
+++ b/build_tools/make_version
@@ -5,79 +5,10 @@
exit 1
fi
-if [ -z "${2}" ]; then
- echo "${0}: A package path must be provided as the second argument of this script." 1>&2
- exit 1
-fi
+PRODUCT_VERSION=${PRODUCT_VERSION:-$2}
-if [ -f ${1}/.version ]; then
- cat ${1}/.version
-elif [ -d ${1}/.svn ]; then
- PARTS=`LANG=C svn info ${1} | ${GREP:=grep} URL | ${AWK:=awk} '{print $2;}' | sed -e "s:^.*/svn/${2}/::" | sed -e "s:/: :g"`
- BRANCH=0
- TEAM=0
- TAG=0
-
- REV=`svnversion -c ${1} | cut -d: -f2`
-
- BASE1=`LANG=C svn pg svnmerge-integrated ${1} | cut -d: -f1`
- BASE2=${BASE1#/}
- BASE=${BASE2//\//_}
-
- if [ "${PARTS}" = "trunk" ] ; then
- echo SVN-trunk-r${REV}
- exit 0
- fi
-
- for PART in $PARTS ; do
- if [ ${TAG} != 0 ] ; then
- if [ "${PART#autotag_for_}" != "${PART}" ] ; then
- continue
- fi
- RESULT="${PART}"
- break
- fi
-
- if [ ${BRANCH} != 0 ] ; then
- if [ -z "${RESULT}" ] ; then
- RESULT="${PART}"
- else
- RESULT="${RESULT}_${PART}"
- fi
- break
- fi
-
- if [ ${TEAM} != 0 ] ; then
- if [ -z "${RESULT}" ] ; then
- RESULT="${PART}"
- else
- RESULT="${RESULT}_${PART}"
- fi
- continue
- fi
-
- if [ "${PART}" = "branches" ] ; then
- BRANCH=1
- RESULT="branch"
- continue
- fi
-
- if [ "${PART}" = "tags" ] ; then
- TAG=1
- continue
- fi
-
- if [ "${PART}" = "team" ] ; then
- TEAM=1
- continue
- fi
- done
-
- if [ ${TAG} != 0 ] ; then
- echo ${RESULT}
- else
- echo SVN-${RESULT}-r${REV}${BASE:+-${BASE}}
- fi
+if [ -n "${PRODUCT_VERSION}" ]; then
+ echo ${PRODUCT_VERSION}
elif [ -d ${1}/.git ]; then
AWK=${AWK:-awk}
GIT=${GIT:-git}
@@ -91,95 +22,17 @@
echo "UNKNOWN__and_probably_unsupported"
exit 1
fi
- # If the first log commit messages indicates that this is checked into
- # subversion, we'll just use the SVN- form of the revision.
MODIFIED=""
- SVN_REV=`${GIT} log --pretty=full -1 | ${GREP} -F "git-svn-id:" | sed -e "s/.*\@\([^\s]*\)\s.*/\1/g"`
- if [ -z "$SVN_REV" ]; then
- VERSION=`${GIT} describe --long --always --tags --dirty=M 2> /dev/null`
- if [ $? -ne 0 ]; then
- if [ "`${GIT} ls-files -m | wc -l`" != "0" ]; then
- MODIFIED="M"
- fi
- # Some older versions of git do not support all the above
- # options.
- VERSION=`${GIT} rev-parse --short --verify HEAD`${MODIFIED}
- fi
- echo GIT-${MAINLINE_BRANCH}-${VERSION}
- else
- PARTS=`LANG=C ${GIT} log --pretty=full | ${GREP} -F "git-svn-id:" | head -1 | ${AWK} '{print $2;}' | sed -e s:^.*/svn/$2/:: | sed -e 's:/: :g' | sed -e 's/@.*$//g'`
- BRANCH=0
- TEAM=0
- TAG=0
- FEATURE=0
-
+ VERSION=`${GIT} describe --long --always --tags --dirty=M 2> /dev/null`
+ if [ $? -ne 0 ]; then
if [ "`${GIT} ls-files -m | wc -l`" != "0" ]; then
MODIFIED="M"
fi
-
- for PART in $PARTS ; do
- if [ ${TAG} != 0 ] ; then
- if [ "${PART}" = "autotag_for_be" ] ; then
- continue
- fi
- if [ "${PART}" = "autotag_for_sx00i" ] ; then
- continue
- fi
- RESULT="${PART}"
- break
- fi
-
- if [ ${BRANCH} != 0 ] ; then
- RESULT="${RESULT}-${PART}"
- if [ ${FEATURE} != 0 ] ; then
- RESULT="${RESULT}-${FEATURE_NAME}"
- fi
- break
- fi
-
- if [ ${TEAM} != 0 ] ; then
- if [ -z "${RESULT}" ] ; then
- RESULT="${PART}"
- else
- RESULT="${RESULT}-${PART}"
- fi
- continue
- fi
-
- if [ "${PART}" = "certified" ] ; then
- FEATURE=1
- FEATURE_NAME="cert"
- continue
- fi
-
- if [ "${PART}" = "branches" ] ; then
- BRANCH=1
- RESULT="branch"
- continue
- fi
-
- if [ "${PART}" = "tags" ] ; then
- TAG=1
- continue
- fi
-
- if [ "${PART}" = "team" ] ; then
- TEAM=1
- continue
- fi
-
- if [ "${PART}" = "trunk" ]; then
- echo SVN-trunk-r${SVN_REV}${MODIFIED}
- exit 0
- fi
- done
-
- if [ ${TAG} != 0 ] ; then
- echo ${RESULT}
- else
- echo SVN-${RESULT##-}-r${SVN_REV}${MODIFIED}
- fi
+ # Some older versions of git do not support all the above
+ # options.
+ VERSION=`${GIT} rev-parse --short --verify HEAD`${MODIFIED}
fi
+ echo GIT-${VERSION}
else
echo "UNKNOWN_and_probably_unsupported"
fi
--
To view, visit https://gerrit.asterisk.org/3255
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I41c298d17529cc281d4454825272793d31c7e75a
Gerrit-PatchSet: 1
Gerrit-Project: repotools
Gerrit-Branch: master
Gerrit-Owner: George Joseph <gjoseph at digium.com>
More information about the asterisk-code-review
mailing list