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
This commit is contained in:
George Joseph 2022-03-25 08:33:30 -06:00 committed by Friendly Automation
parent 0d11938e92
commit 144b3c5453
3 changed files with 19 additions and 82 deletions

View File

@ -101,6 +101,11 @@ export TAR
export PATCH export PATCH
export SED export SED
export NM export NM
export FIND
export BASENAME
export DIRNAME
export XMLLINT
export XMLSTARLET
# makeopts is required unless the goal is just {dist{-}}clean # makeopts is required unless the goal is just {dist{-}}clean
ifeq ($(MAKECMDGOALS),clean) ifeq ($(MAKECMDGOALS),clean)

View File

@ -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}"

View File

@ -1,10 +1,7 @@
#!/bin/sh #!/bin/sh
# The GREP, SED, FIND, etc variables are all set at run time from
# makeopts.
# shellcheck disable=SC2154 # shellcheck disable=SC2154
PROGNAME="${0##*/}" PROGNAME="${0##*/}"
PROGDIR="${0%/*}"
# Fail on errors # Fail on errors
set -e set -e
@ -111,36 +108,25 @@ if [ ! -d "${source_tree}" ] ; then
exit 1 exit 1
fi fi
if [ ! -f "${source_tree}/Makefile" ] ; then
echo "There's no 'Makefile' in '${source_tree}'."
exit 1
fi
if [ ! -f "${source_tree}/makeopts" ] ; then if [ ! -f "${source_tree}/makeopts" ] ; then
echo "There's no 'makeopts' in '${source_tree}'. Maybe you need to run ./configure?" echo "There's no 'makeopts' in '${source_tree}'. Maybe you need to run ./configure?"
exit 1 exit 1
fi fi
# This will get the paths to the utilities we need, all # This script is normally run from the top-level Makefile which
# of which will be in makeopts. We need to convert the # will set the tools variables to actual paths, or ':' if
# format so it's sourceable. # the tool isn't found. If this script is run from the
tmpname="/tmp/ast_makeopts.$$.env" # command line for testing purposes however, we'll need to
trap 'rm "$tmpname" >/dev/null 2>&1' INT QUIT TERM EXIT # set some sane defaults.
"${PROGDIR}/get_sourceable_makeopts" "${source_tree}/makeopts" >"${tmpname}" if [ "${GREP}" = "" ] ; then GREP="grep" ; fi
# The file to be sourced is generated at run time and can't be checked. if [ "${FIND}" = "" ] ; then FIND="find" ; fi
# shellcheck disable=SC1090 if [ "${AWK}" = "" ] ; then AWK="awk" ; fi
. "${tmpname}" if [ "${DIRNAME}" = "" ] ; then DIRNAME="dirname" ; fi
rm "${tmpname}" > /dev/null 2>&1 || : if [ "${BASENAME}" = "" ] ; then BASENAME="basename" ; fi
trap - INT QUIT TERM EXIT if [ "${SED}" = "" ] ; then SED="sed" ; fi
if [ "${CAT}" = "" ] ; then CAT="cat" ; fi
# Make sure we have everything we need. if [ "${XMLLINT}" = "" ] ; then XMLLINT="xmllint" ; fi
for c in GREP FIND AWK DIRNAME BASENAME SED CAT ; do if [ "${XMLSTARLET}" = "" ] ; then XMLSTARLET="xmlstarlet" ; fi
bin=$(eval "echo \${${c}}")
if [ "${bin}" = "" ] ; then
echo "The '${c}' utility was not found."
exit 1
fi
done
if [ "${for_wiki}" -eq "1" ] || [ "${validate}" -eq "1" ]; then if [ "${for_wiki}" -eq "1" ] || [ "${validate}" -eq "1" ]; then
if [ "${XMLLINT}${XMLSTARLET}" = "::" ] ; then if [ "${XMLLINT}${XMLSTARLET}" = "::" ] ; then