From 88420e232be244ab98953ca8d98b1beee80fadd4 Mon Sep 17 00:00:00 2001 From: MilhouseVH Date: Wed, 13 Feb 2019 15:10:54 +0000 Subject: [PATCH] tools/pkgcheck: add "ignored depends assign" warning --- packages/readme.md | 1 + tools/pkgcheck | 22 ++++++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/packages/readme.md b/packages/readme.md index f141c19d57..3553a7023e 100644 --- a/packages/readme.md +++ b/packages/readme.md @@ -246,6 +246,7 @@ Issue | Level | Meaning | | bad func - missing brace | FAIL | Opening brace (`{`) for function definition should be on same line as the function def, ie. `pre_configure_target() {` | | intertwined vars & funcs | WARN | Variable assignments and logic is intertwined with functions - this is cosmetic, but variables and logic should be specified before all functions | | unknown function | WARN | Could be a misspelled function, ie. `per_configure_target() {` which might fail silently.| +| ignored depends assign | WARN | Values assigned to `PKG_DEPENDS_*` outside of the global section or `configure_package()` will be ignored. | ## Add a new package to the Image diff --git a/tools/pkgcheck b/tools/pkgcheck index 53e4b661ad..cab6a6af58 100755 --- a/tools/pkgcheck +++ b/tools/pkgcheck @@ -21,14 +21,20 @@ log() { [ ${lc} -eq 0 ] && flc="---" || flc="$(printf "%03d" ${lc})" [[ ${filename} =~ packages/addons/addon-depends ]] && colw=80 || colw=50 - printf "[%s]: %3s: %-*s: %-25s: %s\n" "${txcolour}${level}${TXRESET}" "${flc}" ${colw} "${filename}" "${msg}" "${data}" + printf "[%s] %3s: %-*s: %-25s: %s\n" "${txcolour}${level}${TXRESET}" "${flc}" ${colw} "${filename}" "${msg}" "${data}" } process_line() { - local filename="$1" lc="$2" line="$3" inassign="$4" infunc="$5" + local filename="$1" lc="$2" line="$3" inassign="$4" funcname="$5" local var matches assignallowed=Y - [ "${infunc}" = "Y" ] && return 0 + if [ -n "${funcname}" -a "${funcname}" != "configure_package" -a "${inassign}" = "Y" ]; then + if [[ ${line} =~ PKG_DEPENDS_.*= ]]; then + log "${filename}" ${lc} "WARN" "ignored depends assign" "${funcname}() => ${line//[[:space:]]*PKG_DEPENDS_/PKG_DEPENDS_}" + fi + fi + + [ -n "${funcname}" ] && return 0 rightside="${line#*=}" @@ -104,7 +110,7 @@ check_func_name() { process_pkg() { local filename="$1" - local lc=0 isassign=N isfunc=N fc=0 intertwined=N + local lc=0 isassign=N funcname= fc=0 intertwined=N while IFS= read -r line; do lc=$((lc + 1)) @@ -116,22 +122,22 @@ process_pkg() { fi if [[ "${line}" =~ \(\)[[:space:]]*\{ ]]; then - isfunc=Y + funcname="${line//(*/}" fc=$((fc+1)) check_func_name "${filename}" "${lc}" "${line}" fi - if [ "${intertwined}" = "N" -a "${isfunc}" = "N" -a ${fc} -ge 1 ]; then + if [ "${intertwined}" = "N" -a -z "${funcname}" -a ${fc} -ge 1 ]; then log "${filename}" ${lc} "WARN" "intertwined vars & funcs" "${line}" intertwined=Y fi [[ "${line}" =~ ^[[:space:]]*PKG_.*=\" ]] && isassign=Y - process_line "$1" "${lc}" "${line}" "${isassign}" "${isfunc}" + process_line "$1" "${lc}" "${line}" "${isassign}" "${funcname}" [[ "${line}" =~ (\"$|\"[[:space:]]*$|\"[[:space:]]*#.*$) ]] && isassign=N - [[ "${line}" =~ (^}|^[[:space:]]*}) ]] && isfunc=N + [[ "${line}" =~ (^}|^[[:space:]]*}) ]] && funcname= done < "${filename}" # Duplicate function check