[Asterisk-code-review] make_xml_documentation: Remove usage of get_sourceable_makeopts (asterisk[19.3])

Kevin Harwell asteriskteam at digium.com
Mon Mar 28 13:21:22 CDT 2022


Kevin Harwell has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/18292 )


Change subject: make_xml_documentation: Remove usage of get_sourceable_makeopts
......................................................................

make_xml_documentation: Remove usage of get_sourceable_makeopts

get_sourceable_makeopts wasn't handling variables with embedded
double quotes in them very well.  One example was the DOWNLOAD
variable when curl was being used instead of wget.  Rather than
trying to fix get_sourceable_makeopts, it's just been removed.

ASTERISK-29986
Reported by: Stefan Ruijsenaars

Change-Id: Idf2a90902228c2558daa5be7a4f8327556099cd2
---
M Makefile
D build_tools/get_sourceable_makeopts
M build_tools/make_xml_documentation
3 files changed, 19 insertions(+), 82 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/92/18292/1

diff --git a/Makefile b/Makefile
index bb8cdd0..99f4692 100644
--- a/Makefile
+++ b/Makefile
@@ -101,6 +101,11 @@
 export PATCH
 export SED
 export NM
+export FIND
+export BASENAME
+export DIRNAME
+export XMLLINT
+export XMLSTARLET
 
 # makeopts is required unless the goal is just {dist{-}}clean
 ifeq ($(MAKECMDGOALS),clean)
diff --git a/build_tools/get_sourceable_makeopts b/build_tools/get_sourceable_makeopts
deleted file mode 100755
index fbf4c38..0000000
--- a/build_tools/get_sourceable_makeopts
+++ /dev/null
@@ -1,54 +0,0 @@
-#!/bin/sh
-PROGNAME="${0##*/}"
-
-if [ "$1" = "-h"  ] || [ "$1" = "--help" ] ; then
-	cat <<-EOF
-		Usage: ${PROGNAME}: [ <input_file> ] [ <output_file> ]
-
-		This script takes an Asterisk makeopts file, or any file containing
-		"make" style variable assignments, and converts it into a format
-		that can be directly 'sourced' by shell scripts.
-
-		* Any spaces around the equals sign are removed.
-		* The variable value is quoted.
-		* The "make" "or" command is evaluated.
-
-		Both input and output files are optional and will default to
-		stdin and stdout respectively.
-
-		NOTE: This script relies on NO external commands and only POSIX
-		constructs.  It should be runnable by any shell.
-	EOF
-	exit 1
-fi
-
-input_file="/dev/stdin"
-if [ "$1" != "" ] ; then
-	input_file="$1"
-fi
-
-output_file="/dev/stdout"
-if [ "$2" != "" ] ; then
-	output_file="$2"
-fi
-
-# orfunc is a code fragment to be added to the outp[ut file.
-# We don't WANT the variables evaluated.
-# shellcheck disable=SC2016
-orfunc='or (){ before="${1%,*}" ; after="${1#*,}" ; if [ "$before" = "" ] ; then echo "${after}" ; else echo "${before}" ; fi ; }'
-echo "${orfunc}" >"${output_file}"
-
-while read -r LINE ; do
-	var="${LINE%%=*}"
-	if [ "${var}" != "" ] ; then
-		val="${LINE#*=}"
-		if [ "${val}" != "${var}" ] ; then
-			if [ "${val%% *}" = "" ] ; then
-				echo "${var% *}=\"${val#* }\""
-			else
-				echo "${var% *}=\"${val}\""
-			fi
-		fi
-	fi
-done <"${input_file}"  >>"${output_file}"
-
diff --git a/build_tools/make_xml_documentation b/build_tools/make_xml_documentation
index 54144ce..3446fff 100755
--- a/build_tools/make_xml_documentation
+++ b/build_tools/make_xml_documentation
@@ -1,10 +1,7 @@
 #!/bin/sh
-# The GREP, SED, FIND, etc variables are all set at run time from
-# makeopts.
 # shellcheck disable=SC2154
 
 PROGNAME="${0##*/}"
-PROGDIR="${0%/*}"
 
 # Fail on errors
 set -e
@@ -111,36 +108,25 @@
 	exit 1
 fi
 
-if [ ! -f "${source_tree}/Makefile" ] ; then
-	echo "There's no 'Makefile' in '${source_tree}'."
-	exit 1
-fi
-
 if [ ! -f "${source_tree}/makeopts" ] ; then
 	echo "There's no 'makeopts' in '${source_tree}'.  Maybe you need to run ./configure?"
 	exit 1
 fi
 
-# This will get the paths to the utilities we need, all
-# of which will be in makeopts.  We need to convert the
-# format so it's sourceable.
-tmpname="/tmp/ast_makeopts.$$.env"
-trap 'rm "$tmpname" >/dev/null 2>&1' INT QUIT TERM EXIT
-"${PROGDIR}/get_sourceable_makeopts" "${source_tree}/makeopts" >"${tmpname}"
-# The file to be sourced is generated at run time and can't be checked.
-# shellcheck disable=SC1090
-. "${tmpname}"
-rm "${tmpname}" > /dev/null 2>&1 || :
-trap - INT QUIT TERM EXIT
-
-# Make sure we have everything we need.
-for c in GREP FIND AWK DIRNAME BASENAME SED CAT ; do
-	bin=$(eval "echo \${${c}}")
-	if [ "${bin}" = "" ] ; then
-		echo "The '${c}' utility was not found."
-		exit 1
-	fi
-done
+# This script is normally run from the top-level Makefile which
+# will set the tools variables to actual paths, or ':' if
+# the tool isn't found.  If this script is run from the
+# command line for testing purposes however, we'll need to
+# set some sane defaults.
+if [ "${GREP}" = "" ] ; then GREP="grep" ; fi
+if [ "${FIND}" = "" ] ; then FIND="find" ; fi
+if [ "${AWK}" = "" ] ; then AWK="awk" ; fi
+if [ "${DIRNAME}" = "" ] ; then DIRNAME="dirname" ; fi
+if [ "${BASENAME}" = "" ] ; then BASENAME="basename" ; fi
+if [ "${SED}" = "" ] ; then SED="sed" ; fi
+if [ "${CAT}" = "" ] ; then CAT="cat" ; fi
+if [ "${XMLLINT}" = "" ] ; then XMLLINT="xmllint" ; fi
+if [ "${XMLSTARLET}" = "" ] ; then XMLSTARLET="xmlstarlet" ; fi
 
 if [ "${for_wiki}" -eq "1" ] || [ "${validate}" -eq "1" ]; then
 	if [ "${XMLLINT}${XMLSTARLET}" = "::" ] ; then

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/18292
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 19.3
Gerrit-Change-Id: Idf2a90902228c2558daa5be7a4f8327556099cd2
Gerrit-Change-Number: 18292
Gerrit-PatchSet: 1
Gerrit-Owner: Kevin Harwell <kharwell at digium.com>
Gerrit-CC: George Joseph <gjoseph at digium.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20220328/cf0a9d75/attachment-0001.html>


More information about the asterisk-code-review mailing list