aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias C. Berner <tcberner@FreeBSD.org>2023-09-12 15:21:03 +0000
committerTobias C. Berner <tcberner@FreeBSD.org>2023-09-12 18:27:47 +0000
commitf3790c0170d85995b0fa58c6c50cef03088bf5ec (patch)
tree99df4cd75beffbd13c2934e9c1ca3fef4c2c1974
parentb3229433aa825a4b309fca69c13c06c31fea896d (diff)
downloadports-f3790c0170d85995b0fa58c6c50cef03088bf5ec.tar.gz
ports-f3790c0170d85995b0fa58c6c50cef03088bf5ec.zip
sanity: warn about unnused LIB_DEPENDS entries
`stage-qa` already warns about missing dependencies. However, it does not warn about possibly unneeded ones. This change tries to address this, by simply walking the list of linked against shared libraries and then matching the entries of LIB_DEPENDS against them. Note: this may lead to false positives -- as always, user your brain, and don't rely on output of static tools alone. Possible output might look like: [...] ====> Running Q/A tests (stage-qa) Warning: you might not need LIB_DEPENDS on libqgpgme.so Warning: you might not need LIB_DEPENDS on libintl.so Warning: you might not need LIB_DEPENDS on libKF5IconThemes.so Warning: you might not need LIB_DEPENDS on libqca-qt5.so Warning: you might not need LIB_DEPENDS on libQt5Test.so [...] Note, that in this case all are false positives. Differential Revision: https://reviews.freebsd.org/D27304
-rw-r--r--Mk/Scripts/qa.sh11
-rw-r--r--Mk/bsd.port.mk1
2 files changed, 11 insertions, 1 deletions
diff --git a/Mk/Scripts/qa.sh b/Mk/Scripts/qa.sh
index bdbff58cdb23..63fa9f6f370e 100644
--- a/Mk/Scripts/qa.sh
+++ b/Mk/Scripts/qa.sh
@@ -649,7 +649,7 @@ proxydeps_suggest_uses() {
}
proxydeps() {
- local file dep_file dep_file_pkg already rc
+ local file dep_file dep_file_pkg already rc dep_lib_file dep_lib_files
rc=0
@@ -697,6 +697,8 @@ proxydeps() {
rc=1
fi
already="${already} ${dep_file}"
+ dep_lib_file=$(basename ${dep_file})
+ dep_lib_files="${dep_lib_files} ${dep_lib_file%%.so*}.so"
done <<-EOT
$(env LD_LIBMAP_DISABLE=1 ldd -a "${STAGEDIR}${file}" | \
awk '
@@ -712,6 +714,13 @@ proxydeps() {
sed -e 's/^\.//')
EOT
+ # Check whether all files in LIB_DPEENDS are actually linked against
+ for _library in ${WANTED_LIBRARIES} ; do
+ if ! listcontains ${_library} "${dep_lib_files}" ; then
+ warn "you might not need LIB_DEPENDS on ${_library}"
+ fi
+ done
+
[ -z "${PROXYDEPS_FATAL}" ] && return 0
return ${rc}
diff --git a/Mk/bsd.port.mk b/Mk/bsd.port.mk
index b11c99fc0476..4679774d9640 100644
--- a/Mk/bsd.port.mk
+++ b/Mk/bsd.port.mk
@@ -1650,6 +1650,7 @@ QA_ENV+= STAGEDIR=${STAGEDIR} \
PKGORIGIN=${PKGORIGIN} \
LIB_RUN_DEPENDS='${_LIB_RUN_DEPENDS:C,[^:]*:([^:]*):?.*,\1,}' \
UNIFIED_DEPENDS=${_UNIFIED_DEPENDS:C,([^:]*:[^:]*):?.*,\1,:O:u:Q} \
+ WANTED_LIBRARIES='${LIB_DEPENDS:C,([^:]*):([^:]*):?.*,\1,}' \
PKGBASE=${PKGBASE} \
LICENSE="${LICENSE}" \
LICENSE_PERMS="${_LICENSE_PERMS}" \