[Asterisk-code-review] build tools: Support module downloading (repotools[master])
George Joseph
asteriskteam at digium.com
Mon Aug 8 16:10:05 CDT 2016
George Joseph has uploaded a new change for review.
https://gerrit.asterisk.org/3430
Change subject: build_tools: Support module downloading
......................................................................
build_tools: Support module downloading
Split tarball and stage code out of Makefile.product_rules into
their own shell scripts.
Added make_manifest.
After upgrading to this version, you must have a "manifest.xml.in"
file in the root directory of your repo.
Change-Id: I404e9eb2ecf0711468902c2f59fd537b984c8a95
---
M build_tools/Makefile.product_rules
D build_tools/commit_to_staging
A build_tools/make_manifest
A build_tools/make_stage
A build_tools/make_tarball
5 files changed, 337 insertions(+), 147 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/repotools refs/changes/30/3430/1
diff --git a/build_tools/Makefile.product_rules b/build_tools/Makefile.product_rules
index d67a91a..f378337 100644
--- a/build_tools/Makefile.product_rules
+++ b/build_tools/Makefile.product_rules
@@ -2,6 +2,8 @@
MODULE_NAME?=$(notdir $(shell pwd))
+export MODULE_NAME
+
ifeq ($(NOISY_BUILD),)
ECHO_PREFIX=@
CMD_PREFIX=@
@@ -42,11 +44,10 @@
yesno=$(if $(findstring yes,$(1)),yes,no)
yesonly=$(if $(findstring yes,$(1)),yes,)
-define libcp_build
- @echo " [MAKE] libcp_build $(ARCH) ";\
- $(MAKE) INDENT="+ " --quiet --no-print-directory -C libcp clean;\
- $(MAKE) INDENT="+ " --quiet --no-print-directory -C libcp ARCH=$(ARCH) OPT="$(FLAVOR_CFLAGS)" DEBUG="$(DEBUG_OPT)" libcp.a;
-endef
+libcp_build=\
+ @echo " [MAKE] libcp_build $(ARCH) " ; \
+ $(MAKE) INDENT="+ " --quiet --no-print-directory -C libcp clean ; \
+ $(MAKE) INDENT="+ " --quiet --no-print-directory -C libcp ARCH=$(ARCH) OPT="$(FLAVOR_CFLAGS)" DEBUG="$(DEBUG_OPT)" libcp.a ;
COPYPROTECT_BITS=$(shell ((objdump -f libcp/libcp.a 2>/dev/null) || echo "") | sed -n -r -e "s/^cp.o:.*elf(32|64)-.*/\1/p")
COPYPROTECT_BUILD_NEEDED=$(if $(wildcard libcp),$(if $(findstring $(ARCH_BITS),$(COPYPROTECT_BITS)),,yes),)
@@ -54,14 +55,13 @@
COPYPROTECT_CFLAGS=$(if $(wildcard libcp),$(if $(filter-out no,$(COPYPROTECT)),-DCOPYPROTECT $(if $(filter FAKE,$(COPYPROTECT)),-DFAKECOPYPROTECT) $(if $(MAXCALLS),-DMAXCALLS=$(MAXCALLS)) -Ilibcp))
COPYPROTECT_LIBS=$(if $(wildcard libcp),$(if $(filter-out FAKE no,$(COPYPROTECT)),-Llibcp -lcp))
-define asterisk_configure
- echo " [MAKE] asterisk_configure $(ARCH) $(ASTERISK_CONFIGURE_FLAGS). This may take a minute or 2...";\
- cd asterisk;\
- $(MAKE) --quiet --no-print-directory distclean &>/dev/null;\
- ./configure $(ASTERISK_CONFIGURE_FLAGS) &>/dev/null || exit 1;\
- $(MAKE) --quiet --no-print-directory include/asterisk/buildopts.h &>/dev/null;\
- sed -i -e /GCC_ATOMICS/d include/asterisk/autoconfig.h;
-endef
+asterisk_configure=\
+ @echo " [MAKE] asterisk_configure $(ARCH) $(ASTERISK_CONFIGURE_FLAGS). This may take a minute or 2..." ;\
+ cd asterisk ; $(MAKE) --quiet --no-print-directory distclean &>/dev/null ;\
+ ./configure $(ASTERISK_CONFIGURE_FLAGS) &>/dev/null || exit 1 ;\
+ $(MAKE) --quiet --no-print-directory include/asterisk/buildopts.h &>/dev/null ;\
+ sed -i -e /GCC_ATOMICS/d include/asterisk/autoconfig.h ;
+
ASTERISK_ARCH=$(shell sed -n -r -e "s/HOST_PLATFORM=([^-]+)-.+/\1/p" asterisk/makeopts 2>/dev/null || echo "unknown")
ASTERISK_ARCH_MISMATCH=$(if $(findstring $(BUILD_ARCH),$(ASTERISK_ARCH)),,yes)
@@ -110,7 +110,7 @@
$(CMD_PREFIX) $(CC) $(FLAVOR_CFLAGS) $(DEBUG_OPT) $(SOLINK) -o $@ $^ $(LDFLAGS) $(LIBS) $(COPYPROTECT_LIBS)
clean::
- @rm -f *.o *.so
+ @rm -f *.o *.so manifest.xml
distclean:: clean
- at rm -f optarch.h version.h
@@ -124,25 +124,16 @@
$(INSTALL) -m 755 -t $(DESTDIR)$(FLAVOR_ASTLIBDIR)/modules/ $^
$(MODULE_NAME)-%.tar.gz: $(MODULE_NAME).so $(MODULE_EXTRA_LIBRARIES)
- @echo " [TAR] $@"
- @if [ "$(NOSTRIP)" != "yes" ] ; then $(STRIP) $^ ; fi
- @-rm -rf $(@:.tar.gz=)
- @mkdir $(@:.tar.gz=)
- @mv $^ $(@:.tar.gz=)/
- @cp LICENSE $(@:.tar.gz=)/
- @if [ -f README ] ; then cp README $(@:.tar.gz=)/ ; fi
- @if [ -f CHANGES ] ; then cp CHANGES $(@:.tar.gz=)/ ; fi
- @if [ -f UPGRADE ] ; then cp UPGRADE $(@:.tar.gz=)/ ; fi
- @if [ -d doc ] ; then cp -a doc/* $(@:.tar.gz=)/ ; fi
- @if [ -n "$(EXTRAS_DIR)" ] ; then cp -a $(EXTRAS_DIR)/* $(@:.tar.gz=)/ ; fi
- @$(TAR) --create --owner 0 --group 0 --file $@ --gzip $(@:.tar.gz=)
- @rm -rf $(@:.tar.gz=)
+ $(ECHO_PREFIX) echo " [TAR] $^"
+ $(CMD_PREFIX)repotools/build_tools/make_tarball --nostrip=$(or $(NOSTRIP),no) --version=$(PRODUCT_VERSION) \
+ --arch=$(ARCH) --package-name=$(MODULE_NAME) $(if $(MANIFEST_IN),--manifest-in=$(MANIFEST_IN)) \
+ $(if $(MANIFEST),--manifest-in=$(MANIFEST)) $^
clean_tarball: COPYPROTECT=yes
clean_tarball:: distclean $(PRODUCT_DIR).tar.gz
-debug: DEBUG=1
-debug: NOSTRIP=1
+debug: DEBUG=yes
+debug: NOSTRIP=yes
debug: distclean $(PRODUCT_DIR)-debug.tar.gz
nocp: COPYPROTECT=
@@ -152,7 +143,11 @@
tarballs_64: PRODUCTS+=clean_tarball
tarballs_64:
@echo "[TARGET] $@: $(PRODUCTS)"
- @for p in $(PRODUCTS) ; do echo " [TARGET] $$p $(ARCH) " ; $(MAKE) --no-print-directory $$p || exit 1 ; echo " [TARGET] $$p $(ARCH) COMPLETE"; done
+ @for p in $(PRODUCTS) ; do \
+ echo " [TARGET] $$p $(ARCH) " ;\
+ $(MAKE) --no-print-directory $$p || exit 1 ;\
+ echo " [TARGET] $$p $(ARCH) COMPLETE" ;\
+ done
@echo "[TARGET] $@: $(PRODUCTS) COMPLETE"
@echo
@@ -160,48 +155,33 @@
tarballs_32: PRODUCTS+=clean_tarball
tarballs_32:
@echo "[TARGET] $@: $(PRODUCTS)"
- @for p in $(PRODUCTS) ; do echo " [TARGET] $$p $(ARCH) " ; $(MAKE) --no-print-directory $$p || exit 1 ; echo " [TARGET] $$p $(ARCH) COMPLETE"; done
+ @for p in $(PRODUCTS) ; do \
+ echo " [TARGET] $$p $(ARCH) " ;\
+ $(MAKE) --no-print-directory $$p || exit 1 ;\
+ echo " [TARGET] $$p $(ARCH) COMPLETE" ;\
+ done
@echo "[TARGET] $@: $(PRODUCTS) COMPLETE"
@echo
everything: superclean tarballs_64 tarballs_32
-VALID_TAG=$(shell echo $(PRODUCT_VERSION) | sed -n -r -e "s/^([0-9]+\.[0-9]+)_[0-9]+\.[0-9]+\.[0-9]+$$/\1/gp")
-STAGEDIR=$(REPO)/$(MODULE_NAME)/asterisk-$(VALID_TAG)/$(subst _,-,$(ARCH))
-GIT_STATUS=$(shell git status --porcelain)
-
-checkstage:
- @if [ -n "$(GIT_STATUS)" ] ; then echo -e "This directory has uncommitted changes.\n$(GIT_STATUS)" ; exit 1 ; fi
- @if [ -z "$(VALID_TAG)" ] ; then echo "PRODUCT_VERSION($(PRODUCT_VERSION)) isn't a valid tag." ; exit 1 ; fi
-
-stagearch: FORCE
+stage_32: export ARCH:=x86_32
+stage_32: export REPO:=$(REPO)
+stage_32:
+ $(ECHO_PREFIX) echo " [STAGE] $@"
@if [ -z "$(REPO)" ] ; then echo -e "Missing REPO=<repository>.\nExample: make stage REPO=https://origsvn.digium.com/svn/sites/downloads.digium.com/staging/telephony\n\n" ; exit 1 ; fi
- svn ls $(STAGEDIR) &> /dev/null || svn mkdir --parents $(STAGEDIR) -m "Create staging directory"
- rm -rf staging
- svn co $(STAGEDIR) staging
- cp $(PRODUCT_DIR).tar.gz staging/
- cp $(PRODUCT_DIR).tar.gz staging/$(MODULE_NAME)-current-$(ARCH).tar.gz
- for variant in $(STAGE_VARIANTS) ; do \
- if [ -f "$(PRODUCT_DIR)-$$variant.tar.gz" ] ; then \
- cp $(PRODUCT_DIR)-$$variant.tar.gz staging/ ;\
- cp $(PRODUCT_DIR)-$$variant.tar.gz staging/$(MODULE_NAME)-current-$$variant-$(ARCH).tar.gz ;\
- fi ;\
- done ;
- if [ -f README ] ; then cp README staging/ ; fi
- if [ -f LICENSE ] ; then cp LICENSE staging/ ; fi
- (cd staging ; svn add *)
- svn commit staging -m "commit $(MODULE_NAME)-$(PRODUCT_VERSION)-$(ARCH) builds to staging"
- rm -rf staging
+ $(CMD_PREFIX)repotools/build_tools/make_stage --version=$(PRODUCT_VERSION) --arch=$(ARCH) --package-name=$(MODULE_NAME) \
+ --variants=$(STAGE_VARIANTS) --skip-checks=$(SKIP_CHECKS) --repo=$(REPO)
-stage_32: ARCH=x86_32
-stage_32: stagearch
+stage_64: export ARCH=x86_64
+stage_64: export REPO:=$(REPO)
+stage_64:
+ $(ECHO_PREFIX) echo " [STAGE] $<"
+ @if [ -z "$(REPO)" ] ; then echo -e "Missing REPO=<repository>.\nExample: make stage REPO=https://origsvn.digium.com/svn/sites/downloads.digium.com/staging/telephony\n\n" ; exit 1 ; fi
+ $(CMD_PREFIX)repotools/build_tools/make_stage --version=$(PRODUCT_VERSION) --arch=$(ARCH) --package-name=$(MODULE_NAME) \
+ --variants=$(STAGE_VARIANTS) --skip-checks=$(SKIP_CHECKS) --repo=$(REPO)
-stage_64: ARCH=x86_64
-stage_64: stagearch
-
-stage: checkstage
- $(MAKE) stage_32
- $(MAKE) stage_64
+stage: stage_32 stage_64
printit:
@echo ------------------
diff --git a/build_tools/commit_to_staging b/build_tools/commit_to_staging
deleted file mode 100755
index a2c4528..0000000
--- a/build_tools/commit_to_staging
+++ /dev/null
@@ -1,83 +0,0 @@
-#!/bin/bash
-
-. repotools/build_tools/buildfuncs
-
-make_staging_dir() {
- svn ls ${1} &> /dev/null || svn mkdir --parents ${1} -m "create staging directory"
-}
-
-c2s() {
- FN=${1}
- VERSION=${2}
- ASTVERSION=`extract_astversion ${2}`
- ARCH=${3}
- P=${4}
- 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 $ARCH in
- (x86_64)
- A=x86-64
- ;;
- (x86_32)
- A=x86-32
- ;;
- esac
- P=${P}/${A}
- make_staging_dir ${P}
- svn ls ${P} &> /dev/null || svn mkdir --parents ${P} -m "create staging directory"
- svn co ${P} staging
- cp ${FN}-${VERSION}-${ARCH}.tar.gz staging
- cp ${FN}-${VERSION}-${ARCH}.tar.gz staging/${FN}-current-${ARCH}.tar.gz
- if [ -f README ] ; then cp README staging/ ; fi
- if [ -f LICENSE ] ; then cp LICENSE staging/ ; fi
- cd staging
- svn add ${FN}-${VERSION}-${ARCH}.tar.gz
- svn add ${FN}-current-${ARCH}.tar.gz
- if [ -f README ] ; then svn add README ; fi
- if [ -f LICENSE ] ; then svn add LICENSE ; fi
- cd ..
- svn commit staging -m "commit ${1} builds to staging"
- rm -rf staging
-}
-
-if [ -z "$1" ] ; then
- echo "You must supply a staging repository".
- echo "Example: ${0} https://origsvn.digium.com/svn/sites/downloads.digium.com/staging/telephony/<product>"
- exit 1
-fi
-
-if [ -n "$(git status --porcelain)" ]; then
- echo "The working directory has uncommitted changes."
- exit 1
-fi
-
-version=`git describe --tags`
-if [ $? -ne 0 ] ; then
- echo "There isn't a valid tag for the current branch"
- exit 1
-fi
-
-if [ "${version#*-}" != "$version" ] ; then
- echo "The latest HEAD doesn't have a tag directly associated with it."
- echo "The closest found was $version"
- exit 1
-fi
-
-product=`basename ${PWD}`
-
-if [ -f $product-$version-x86_32.tar.gz ] ; then
- c2s $product $version x86_32 $1
-fi
-if [ -f $product-$version-x86_64.tar.gz ] ; then
- c2s $product $version x86_64 $1
-fi
diff --git a/build_tools/make_manifest b/build_tools/make_manifest
new file mode 100755
index 0000000..9301f06
--- /dev/null
+++ b/build_tools/make_manifest
@@ -0,0 +1,115 @@
+#!/bin/bash
+if [[ ( ${BASH_VERSINFO[0]} == 4 && ${BASH_VERSINFO[1]} > 1 ) || ${BASH_VERSINFO[0]} > 4 ]] ; then
+ shopt -s compat41
+fi
+set -e
+
+which xmlstarlet >/dev/null || {
+ echo "xmlstarlet is not installed."
+ exit 1
+}
+
+script_path=$(readlink -f ${0})
+script_dir=$(dirname ${script_path})
+
+declare -a module_list
+
+while [ ${#@} -gt 0 ] ; do
+ case ${1} in
+ --package-name=*)
+ package_name=${1#*=}
+ ;;
+ --tar-dir=*)
+ tardir=${1#*=}
+ ;;
+ --manifest-in=*)
+ manifest_in=${1#*=}
+ ;;
+ --manifest-out=*)
+ manifest_out=${1#*=}
+ ;;
+ --version=*)
+ version=${1#*=}
+ ;;
+ --arch=*)
+ arch=${1#*=}
+ ;;
+ *)
+ module_list+=( $1 )
+ ;;
+ esac
+ shift
+done
+
+manifest_in=${manifest_in:-${MANIFEST_IN:-manifest.xml.in}}
+manifest_out=${manifest_out:-${MANIFEST:-manifest.xml}}
+
+if [[ ( -z "${package_name}" ) || ( -z "${module_list[@]}" ) ]] ; then
+ echo "Usage ${0} --package-name=<package name> [ --manifest-in=<manifest.xml.in> ] [ --manifest-out=<manifest.xml> ] [ --arch=(x86_32 | x86_64) ] [ --version=<x.x_y.y.y> ] <module list>"
+ exit 1
+fi
+
+arch=${arch:-${ARCH}}
+if [ -z "${arch}" ] ; then
+ filetype=`file ${module_list[0]}`
+ if [[ "${filetype}" =~ 32-bit ]] ; then
+ arch=x86_32
+ else
+ arch=x86_64
+ fi
+fi
+
+version=${version:-${PRODUCT_VERSION}}
+if [ -z "${version}" ] ; then
+ version=$(${script_dir}/make_version .)
+fi
+
+tmpdir=$(mktemp -d)
+if [[ $? != 0 || ( -z "${tmpdir}" ) ]] ; then
+ echo "Unable to create temporary directory."
+ exit 1
+fi
+trap "rm -rf ${tmpdir}" EXIT
+
+function xstar() {
+ local argv=( "$@" )
+ local file=${argv[$((${#argv[@]} - 1))]}
+ xmlstarlet "$@" > ${file}.tmp && mv ${file}.tmp ${file}
+}
+
+cp ${manifest_in} ${tmpdir}/manifest.xml
+
+xstar ed -i "/package" -t attr -n version -v ${version} ${tmpdir}/manifest.xml
+xstar ed -i "/package" -t attr -n arch -v ${arch} ${tmpdir}/manifest.xml
+xstar ed -s "/package" -t elem -n "modules" -v "" ${tmpdir}/manifest.xml
+
+for so in ${module_list[@]} ; do
+ module=${so/.so/}
+ xstar ed -s "/package/modules" -t elem -n "module_${module}" -v "" ${tmpdir}/manifest.xml
+ xstar ed -s "/package/modules/module_${module}" -t attr -n "name" -v "${module}" ${tmpdir}/manifest.xml
+ xstar ed -r "/package/modules/module_${module}" -v "module" ${tmpdir}/manifest.xml
+ depends=$(sed -n -r -e "/MODULEINFO/,/[*]{3}\// s/\s*<depend>([^<]+)<\/depend>\s*/\1/p" ${module}.c | tr '\n' ' ')
+ for depend in ${depends} ; do
+ xstar ed -s "/package/modules/module[@name='${module}']" -t elem -n "depend" -v "${depend}" ${tmpdir}/manifest.xml
+ done
+done
+
+files=$(xmlstarlet sel -t -m "//file" -v "concat(@src_path,'|',string(@tarball_path))" -n ${tmpdir}/manifest.xml)
+for line in ${files} ; do
+ file=${line%|*}
+ tfile=${line#*|}
+ if [ -n "${tfile}" ] ; then
+ xstar ed -r "//file[@src_path='${file}']/@tarball_path" -v "name" ${tmpdir}/manifest.xml
+ name=${tfile}
+ else
+ xstar ed -r "//file[@src_path='${file}']/@src_path" -v "name" ${tmpdir}/manifest.xml
+ name=${file}
+ fi
+
+ csum=$(md5sum ${tardir:+${tardir}/}${name} | cut -b1-32)
+ xstar ed -a "//file[@name='${name}']" -t attr -n md5sum -v "${csum}" ${tmpdir}/manifest.xml
+done
+
+xstar ed -d "//file/@src_path" ${tmpdir}/manifest.xml
+
+cp ${tmpdir}/manifest.xml ${manifest_out}
diff --git a/build_tools/make_stage b/build_tools/make_stage
new file mode 100755
index 0000000..569b903
--- /dev/null
+++ b/build_tools/make_stage
@@ -0,0 +1,74 @@
+#!/bin/bash
+if [[ ( ${BASH_VERSINFO[0]} == 4 && ${BASH_VERSINFO[1]} > 1 ) || ${BASH_VERSINFO[0]} > 4 ]] ; then
+ shopt -s compat41
+fi
+set -e
+
+script_path=$(readlink -f ${0})
+script_dir=$(dirname ${script_path})
+
+skip_checks=no
+
+while [ ${#@} -gt 0 ] ; do
+ case ${1} in
+ --package-name=*)
+ package_name=${1#*=}
+ ;;
+ --version=*)
+ version=${1#*=}
+ ;;
+ --arch=*)
+ arch=${1#*=}
+ ;;
+ --repo=*)
+ repo=${1#*=}
+ ;;
+ --variants=*)
+ variants=${1#*=}
+ ;;
+ --skip-checks=*)
+ skip_checks=${1#*=}
+ ;;
+ esac
+ shift
+done
+
+git_status=$(git status --porcelain)
+
+if [ -n "${git_status}" -a "${skip_checks}" = "no" ] ; then
+ echo -e "This directory has uncommitted changes.\n${git_status}\n"
+ exit 1
+fi
+
+if [[ ! "${version}" =~ ^([0-9]+\.[0-9]+)_([0-9]+\.[0-9]+\.[0-9]+)$ && "${skip_checks}" = "no" ]] ; then
+ echo "version(${version}) isn't a valid tag.\n"
+ exit 1
+fi
+
+directory_name=$(sed -n -r -e "/MODULEINFO/,/[*]{3}\// s/.*\s+directory_name=\"([^\"]+)\".*/\1/gp" ${package_name}.c )
+
+astversion=${version%_*}
+prodversion=${version#*_}
+stagedir=${repo}/${directory_name:-${package_name}}/asterisk-${astversion}/${arch/_/-}
+package_dir=${package_name}-${version}-${arch}
+tarball=${package_dir}.tar.gz
+
+svn ls ${stagedir} &> /dev/null || svn mkdir --parents ${stagedir} -m "Create staging directory"
+rm -rf staging
+svn co ${stagedir} staging
+trap "rm -rf staging" EXIT
+
+tar --strip-components=1 -xzf ${tarball} -C staging ${package_dir}/manifest.xml
+cp ${tarball} staging/
+cp ${tarball} staging/${package_name}-current-${arch}.tar.gz
+for variant in ${variants} ; do
+ if [ -f "${package_dir}-${variant}.tar.gz" ] ; then
+ cp ${package_dir}-${variant}.tar.gz staging/
+ cp ${package_dir}-${variant}.tar.gz staging/${package_name}-current-${variant}-${arch}.tar.gz
+ fi
+done
+tar --strip-components=1 -xzf ${tarball} -C staging ${package_dir}/README &>/dev/null || :
+tar --strip-components=1 -xzf ${tarball} -C staging ${package_dir}/LICENSE &>/dev/null || :
+
+(cd staging ; svn add *)
+svn commit staging -m "commit ${package_name}-${version}-${arch} builds to staging"
diff --git a/build_tools/make_tarball b/build_tools/make_tarball
new file mode 100755
index 0000000..6071a37
--- /dev/null
+++ b/build_tools/make_tarball
@@ -0,0 +1,104 @@
+#!/bin/bash
+if [[ ( ${BASH_VERSINFO[0]} == 4 && ${BASH_VERSINFO[1]} > 1 ) || ${BASH_VERSINFO[0]} > 4 ]] ; then
+ shopt -s compat41
+fi
+set -e
+
+which xmlstarlet >/dev/null || {
+ echo "xmlstarlet is not installed."
+ exit 1
+}
+
+script_path=$(readlink -f ${0})
+script_dir=$(dirname ${script_path})
+
+nostrip=no
+declare -a module_list
+
+while [ ${#@} -gt 0 ] ; do
+ case ${1} in
+ --package-name=*)
+ package_name=${1#*=}
+ ;;
+ --manifest-in=*)
+ manifest_in=${1#*=}
+ ;;
+ --manifest-out=*)
+ manifest_out=${1#*=}
+ ;;
+ --nostrip=*)
+ nostrip=${1#*=}
+ ;;
+ --version=*)
+ version=${1#*=}
+ ;;
+ --arch=*)
+ arch=${1#*=}
+ ;;
+ *.tar.gz)
+ tarfile=$1
+ ;;
+ *.so)
+ module_list+=( $1 )
+ ;;
+ esac
+ shift
+done
+
+manifest_in=${manifest_in:-${MANIFEST_IN:-manifest.xml.in}}
+manifest_out=${manifest_out:-${MANIFEST:-manifest.xml}}
+
+if [[ ( -z "${package_name}" ) || ( -z "${module_list[@]}" ) ]] ; then
+ echo "Usage ${0} --package-name=<package name> [ --manifest-in=<manifest.xml.in> ] [ --arch=(x86_32 | x86_64) ] [ --nostrip=(yes|no) ] [ --version=<x.x_y.y.y> ] <module list>"
+ exit 1
+fi
+
+arch=${arch:-${ARCH}}
+if [ -z "${arch}" ] ; then
+ filetype=`file ${module_list[0]}`
+ if [[ "${filetype}" =~ 32-bit ]] ; then
+ arch=x86_32
+ else
+ arch=x86_64
+ fi
+fi
+
+version=${version:-${PRODUCT_VERSION}}
+if [ -z "${version}" ] ; then
+ version=$(${script_dir}/make_version .)
+fi
+
+tardir=${package_name}-${version}-${arch}
+tarfile=${tarfile:-${tardir}.tar.gz}
+
+rm -rf ${tardir}
+mkdir ${tardir}
+trap "if [ -f ${tardir} ] ; then rm -rf ${tardir} ; fi" EXIT
+
+files=$(xmlstarlet sel -t -m "//file" -v "concat(@src_path,'|',string(@tarball_path),'^',string(@executable))" -n ${manifest_in})
+for line in ${files} ; do
+ file=${line%|*}
+ tfile=${line#*|}
+ executable=${tfile#*^}
+ tfile=${tfile%^*}
+
+ if [ "${tfile:0:1}" = "/" ] ; then
+ echo "tarball_path ${tfile} must not be an absolute path."
+ exit 1
+ fi
+
+ mkdir -p ${tardir}/$(dirname ${tfile:-${file}})
+ cp ${file} ${tardir}/${tfile:-${file}}
+
+ if [[ "${NOSTRIP}" != "yes" && "${executable}" = "yes" ]] ; then
+ strip ${tardir}/${tfile:-${file}}
+ fi
+done
+
+echo " [MANIFEST] ${manifest_in} -> ${manifest_out}"
+./repotools/build_tools/make_manifest --package-name=${package_name} --tar-dir=${tardir} ${manifest_in:+--manifest-in=${manifest_in}} ${manifest_out:+--manifest-out=${manifest_out}} \
+ ${version:+--version=${version}} ${module_list[@]}
+
+cp ${manifest_out} ${tardir}/
+
+tar --create --owner 0 --group 0 --file ${tarfile} --gzip ${tardir}
--
To view, visit https://gerrit.asterisk.org/3430
To unsubscribe, visit https://gerrit.asterisk.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I404e9eb2ecf0711468902c2f59fd537b984c8a95
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