diff options
author | Michael Olbrich <m.olbrich@pengutronix.de> | 2019-10-03 17:28:19 +0200 |
---|---|---|
committer | Michael Olbrich <m.olbrich@pengutronix.de> | 2019-10-03 18:48:11 +0200 |
commit | 013ae54851fa282d6636321f29abc445f2060530 (patch) | |
tree | 82b9492af633a27dff4ed7fb2253cddbb226baa5 /bin | |
parent | 90162a8149210a6cf883487209c40dc3c3f785d6 (diff) | |
download | ptxdist-013ae54851fa282d6636321f29abc445f2060530.tar.gz ptxdist-013ae54851fa282d6636321f29abc445f2060530.tar.xz |
ptxdist: improve variable printing
This adds a new 'printnext' command. It prints the value of the value of
the variable.
The print code is refactored to allow this. The make error must be parsed
to determine which variable is undefined.
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/ptxdist | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/bin/ptxdist b/bin/ptxdist index 1c473809f..a04715b4b 100755 --- a/bin/ptxdist +++ b/bin/ptxdist @@ -1011,6 +1011,8 @@ Misc: package-info <package> print some basic information about the package print <var> print the contents of a variable, in the way it is known by "make" + printnext <var> assumes that the contents of <var> is another + variable and print the contents of this variable list-packages print a list of all selected packages local-src <pkg> [<directory>] overwrite a package source with a locally provided directory containing the sourcecode. @@ -2089,10 +2091,16 @@ EOF ptxd_make_log "${pkgs[@]/%/.${cmd}}" exit ;; + printnext) + make_vars=( "${@}" ) + set -- + ;& print) - if [ ${#} -eq 0 ]; then + local tmpfd + if [ ${#} -eq 0 -a ${#make_vars[*]} -eq 0 ]; then exit 1 fi + exec {tmpfd}>&1 while [ ${#} -gt 0 ]; do if [[ ! ( "${1}" =~ "/" ) ]] && ([ -n "${!1}" ]) 2>/dev/null; then if [ "${PTXDIST_VERBOSE}" = "1" ]; then @@ -2100,19 +2108,23 @@ EOF fi echo "${!1}" else - local check - if [ -z "${check}" ]; then - check_config && - check_deps || exit 1 - check=1 - fi - ptxd_make_log "/print-${1}" 2>/dev/null || { - echo "${1} undefined" >&2 - exit 1 - } + make_vars[${#make_vars[*]}]="${1}" fi shift done + if [ ${#make_vars[*]} -gt 0 ]; then + local prefix + check_config && + check_deps || exit 1 + if [ "${cmd}" = "print" ]; then + prefix="/print-" + else + prefix="/printnext-" + fi + ptxd_make_log "${make_vars[@]/#/${prefix}}" 2>&1 1>&${tmpfd} | \ + sed 's/^.*##\(.*\)##.*$/\1 undefined/' >&2 + check_pipe_status || exit 1 + fi exit ;; test) |