git: 7cae85122b13 - main - Mk/Scripts/do-depends.sh: summarize dependency errors
Baptiste Daroussin <[email protected]>
| Newsgroups | gmane.os.freebsd.devel.cvs.ports |
|---|---|
| Message-ID | <[email protected]> |
The branch main has been updated by bapt: URL: https://cgit.FreeBSD.org/ports/commit/?id=7cae85122b132ac9813780e42da7f74973c4ffab commit 7cae85122b132ac9813780e42da7f74973c4ffab Author: Baptiste Daroussin <[email protected]> AuthorDate: 2026-08-17 08:39:04 +0000 Commit: Baptiste Daroussin <[email protected]> CommitDate: 2026-08-17 09:02:53 +0000 Mk/Scripts/do-depends.sh: summarize dependency errors Accumulate and number dependency resolution errors in do-depends.sh instead of only setting a flag, so that a clear summary of all errors is printed at the end of the run rather than being buried in the output of the dependency traversal. (#257069) Add a record_error() helper that increments an error counter, prints each error to stderr, and accumulates the messages for the final summary. Use printf "%b" with a literal format string to avoid interpreting user-controlled data (origins, patterns) as format specifiers. PR: 257069 Submitted by: [email protected] --- Mk/Scripts/do-depends.sh | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/Mk/Scripts/do-depends.sh b/Mk/Scripts/do-depends.sh index c01bd8c16965..47629c006314 100644 --- a/Mk/Scripts/do-depends.sh +++ b/Mk/Scripts/do-depends.sh @@ -98,8 +98,17 @@ find_lib() echo " - found (${libfile})" } +record_error() +{ + ecnt=$((ecnt + 1)) + _err="Error #${ecnt}: $*" + printf '%b\n' "${_err}" >&2 + err="${err}${_err}\n" +} + anynotfound=0 -err=0 +err="" +ecnt=0 for _line in ${dp_RAWDEPENDS} ; do # ensure we never leak flavors unset FLAVOR @@ -108,10 +117,7 @@ for _line in ${dp_RAWDEPENDS} ; do set -- ${_line} IFS=${myifs} if [ $# -lt 2 -o $# -gt 3 ]; then - echo "Error: bad dependency syntax in ${dp_DEPTYPE}" >&2 - echo "expecting: pattern:origin[@flavour][:target]" >&2 - echo "got: ${_line}" >&2 - err=1 + record_error "bad dependency syntax in ${dp_DEPTYPE}\n expecting: pattern:origin[@flavour][:target]\n got: ${_line}" continue fi pattern=$1 @@ -119,14 +125,12 @@ for _line in ${dp_RAWDEPENDS} ; do last=${3:-} if [ -z "${pattern}" ]; then - echo "Error: there is an empty port dependency in ${dp_DEPTYPE}" >&2 - err=1 + record_error "there is an empty port dependency in ${dp_DEPTYPE}" continue fi if [ -z "${origin}" ]; then - echo "Error: a dependency has an empty origin in ${dp_DEPTYPE}" >&2 - err=1 + record_error "a dependency has an empty origin in ${dp_DEPTYPE}" continue fi @@ -182,8 +186,7 @@ for _line in ${dp_RAWDEPENDS} ; do case ${pattern} in lib*.so*) fct=find_lib ;; *) - echo "Error: pattern ${pattern} in LIB_DEPENDS is not valid" - err=1 + record_error "pattern ${pattern} in LIB_DEPENDS is not valid" continue ;; esac ;; @@ -201,8 +204,7 @@ for _line in ${dp_RAWDEPENDS} ; do [ ${pattern} = "/nonexistent" ] || anynotfound=1 if [ ! -f "${origin}/Makefile" ]; then - echo "Error a dependency refers to a non existing origin: ${origin} in ${dp_DEPTYPE}" >&2 - err=1 + record_error "a dependency refers to a non existing origin: ${origin} in ${dp_DEPTYPE}" continue fi @@ -213,8 +215,8 @@ for _line in ${dp_RAWDEPENDS} ; do echo "===> Returning to build of ${dp_PKGNAME}" done -if [ $err -eq 1 ]; then - echo "Errors with dependencies." +if [ $ecnt -ne 0 ]; then + printf 'Found %s error(s) with dependencies:\n%b' "${ecnt}" "${err}" exit 1 fi