[Asterisk-code-review] Fix downloader not working with curl (asterisk[13])

Jenkins2 asteriskteam at digium.com
Fri Aug 18 10:20:10 CDT 2017


Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/6237 )

Change subject: Fix downloader not working with curl
......................................................................

Fix downloader not working with curl

The codec/dpma downloader wasn't handling curl correctly.  The logic
that transforms makeopts into a bash-sourceable file wasn't
handling the make 'or' command in DOWNLOAD_TIMEOUT so bash was
looking for an 'or' command.

That logic has been eliminated.  Instead of trying to transform
and source makeopts, the downloader now calls a make scriptlet
to print the value of a specific variable.  This way, make handles
the ors (or any other make construct that happens to creep into
that file).

ASTERISK-27202
Reported by: Sean McCord

Change-Id: Iadfb6693528e4d4da7b8bb201fa66da2c71c7f99
---
M build_tools/download_externals
M build_tools/list_valid_installed_externals
2 files changed, 35 insertions(+), 16 deletions(-)

Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  Kevin Harwell: Looks good to me, approved
  Jenkins2: Approved for Submit



diff --git a/build_tools/download_externals b/build_tools/download_externals
index f6cc523..efeb6c5 100755
--- a/build_tools/download_externals
+++ b/build_tools/download_externals
@@ -5,7 +5,24 @@
 fi
 set -e
 
+
 ASTTOPDIR=${ASTTOPDIR:-.}
+export make=`sed -n -r -e "s/^MAKE\s*=\s*//gp" ${ASTTOPDIR}/makeopts`
+
+getvar() {
+	$make --quiet --no-print-directory -f- <<EOF
+include ${ASTTOPDIR}/makeopts
+all:
+	@echo "\$($1)"
+EOF
+}
+
+XMLSTARLET=`getvar XMLSTARLET`
+ASTMODDIR=`getvar ASTMODDIR`
+cache_dir=`getvar EXTERNALS_CACHE_DIR`
+DOWNLOAD_TO_STDOUT=`getvar DOWNLOAD_TO_STDOUT`
+HOST_CPU=`getvar HOST_CPU`
+INSTALL=`getvar INSTALL`
 
 module_name=${1%%-*}
 variant=${1##*-}
@@ -26,24 +43,16 @@
 fi
 trap "rm -rf ${tmpdir}" EXIT
 
-# We have to pre-process the makeopts file so it will be parsable by bash
-# Surround values with double quotes
-# Convert make  $(or) functions to bash ${name:-value}
-sed -r  -e "s/^([^ =]+)\s*=\s*(.*)$/\1=\"\2\"/g" \
-	-e 's/^([^ =]+)="\$\(or ([^,]*),([^)]+)\)"/_tmp="\2"\n\1="${_tmp:-\3}"/g'  ${ASTTOPDIR}/makeopts >${tmpdir}/makeopts
-source ${tmpdir}/makeopts
 if [[ -z "${ASTMODDIR}" ]] ; then
 	echo "${module_name}: Unable to parse ${ASTTOPDIR}/makeopts."
 	exit 1
 fi
 
-XMLSTARLET=${XMLSTARLET:-xmlstarlet}
 if [[ "${XMLSTARLET}" = ":" ]] ; then
 	echo "${module_name}: The externals downloader requires xmlstarlet to be installed."
 	exit 1
 fi
 
-cache_dir="${EXTERNALS_CACHE_DIR}"
 if [[ -z ${cache_dir} ]] ; then
 	cache_dir=${tmpdir}
 fi
@@ -191,7 +200,7 @@
 fi
 
 if [[ ${need_download} = 1 ]] ; then
-	echo "${full_name}: Downloading ${remote_url}/${tarball}"
+	echo "${full_name}: Downloading ${remote_url}/${tarball} to ${cache_dir}/${tarball}"
 	${DOWNLOAD_TO_STDOUT} ${remote_url}/${tarball} > ${cache_dir}/${tarball} || {
 		echo "${full_name}: Unable to fetch ${remote_url}/${tarball}"
 		exit 1
diff --git a/build_tools/list_valid_installed_externals b/build_tools/list_valid_installed_externals
index 194801c..ed36274 100755
--- a/build_tools/list_valid_installed_externals
+++ b/build_tools/list_valid_installed_externals
@@ -6,6 +6,23 @@
 set -e
 
 ASTTOPDIR=${ASTTOPDIR:-.}
+export make=`sed -n -r -e "s/^MAKE\s*=\s*//gp" ${ASTTOPDIR}/makeopts`
+
+getvar() {
+	$make --quiet --no-print-directory -f- <<EOF
+include ${ASTTOPDIR}/makeopts
+all:
+	@echo "\$($1)"
+EOF
+}
+
+
+XMLSTARLET=`getvar XMLSTARLET`
+ASTMODDIR=`getvar ASTMODDIR`
+cache_dir=`getvar EXTERNALS_CACHE_DIR`
+DOWNLOAD_TO_STDOUT=`getvar DOWNLOAD_TO_STDOUT`
+HOST_CPU=`getvar HOST_CPU`
+INSTALL=`getvar INSTALL`
 
 tmpdir=$(mktemp -d)
 if [[ -z "${tmpdir}" ]] ; then
@@ -14,18 +31,11 @@
 fi
 trap "rm -rf ${tmpdir}" EXIT
 
-# We have to pre-process the makeopts file so it will be parsable by bash
-# Surround values with double quotes
-# Convert make  $(or) functions to bash ${name:-value}
-sed -r  -e "s/^([^ =]+)\s*=\s*(.*)$/\1=\"\2\"/g" \
-	-e 's/^([^ =]+)="\$\(or ([^,]*),([^)]+)\)"/_tmp="\2"\n\1="${_tmp:-\3}"/g'  ${ASTTOPDIR}/makeopts >${tmpdir}/makeopts
-source ${tmpdir}/makeopts
 if [[ -z "${ASTMODDIR}" ]] ; then
 	echo "${module_name}: Unable to parse ${ASTTOPDIR}/makeopts."
 	exit 1
 fi
 
-XMLSTARLET=${XMLSTARLET:-xmlstarlet}
 if [[ "${XMLSTARLET}" = ":" ]] ; then
 	echo "${module_name}: The externals downloader requires xmlstarlet to be installed."
 	exit 1

-- 
To view, visit https://gerrit.asterisk.org/6237
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: merged
Gerrit-Change-Id: Iadfb6693528e4d4da7b8bb201fa66da2c71c7f99
Gerrit-Change-Number: 6237
Gerrit-PatchSet: 1
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20170818/c7500d84/attachment-0001.html>


More information about the asterisk-code-review mailing list