Index: Mk/bsd.port.mk =================================================================== --- Mk/bsd.port.mk (revision 372818) +++ Mk/bsd.port.mk (working copy) @@ -4848,6 +4848,11 @@ ${PKG_QUERY} "\"%n\": {origin: %o, version: \"%v\"}" " " ${_LIB_RUN_DEPENDS:C,[^:]*:([^:]*):?.*,\1,:C,${PORTSDIR}/,,} 2>/dev/null || : ; \ fi +ACTUAL-PACKAGE-DEPENDS-NAMES?= \ + if [ "${_LIB_RUN_DEPENDS}" != " " ]; then \ + ${PKG_QUERY} "%n-%v" " " ${_LIB_RUN_DEPENDS:C,[^:]*:([^:]*):?.*,\1,:C,${PORTSDIR}/,,} 2>/dev/null || : ; \ + fi + create-manifest: @${MKDIR} ${METADIR}; \ (\ @@ -4919,6 +4924,9 @@ actual-package-depends: @${ACTUAL-PACKAGE-DEPENDS} +actual-package-depends-names: + @${ACTUAL-PACKAGE-DEPENDS-NAMES} + # Build packages for port and dependencies package-recursive: package @@ -5280,7 +5288,7 @@ .if !target(stage-qa) stage-qa: @${ECHO_MSG} "====> Running Q/A tests (stage-qa)" - @${SETENV} ${QA_ENV} ${SH} ${SCRIPTSDIR}/qa.sh + @${SETENV} ${QA_ENV} ${SH} ${SCRIPTSDIR}/qa.sh "${PKGBASE}-${PKGVERSION}" "`${ACTUAL-PACKAGE-DEPENDS-NAMES}`" .endif # Fake installation of package so that user can pkg delete it later. Index: Mk/Scripts/qa.sh =================================================================== --- Mk/Scripts/qa.sh (revision 372818) +++ Mk/Scripts/qa.sh (working copy) @@ -7,6 +7,17 @@ exit 1 fi +usage () { + echo "usage: $0 pkg-name pkg-deps" + exit 1 +} + +[ -n "$1" ] || usage +[ -n "$2" ] || usage + +PKG_NAME=$1 +PKG_DEPS=$2 + LF=$(printf '\nX') LF=${LF%X} @@ -18,6 +29,19 @@ echo "Error: $@" >&2 } +listcontains() { + local str lst elt + str=$1 + lst=$2 + + for elt in ${lst} ; do + if [ ${elt} = ${str} ] ; then + return 0 + fi + done + return 1 +} + shebangonefile() { local f interp rc @@ -206,8 +230,78 @@ fi } -checks="shebang symlinks paths stripped desktopfileutils sharedmimeinfo suidfiles libtool" +proxydeps_suggest_uses() { + local pkg=$1 + if expr ${pkg} : '^gettext-[0-9]' > /dev/null ; then + warn "you need USES+=gettext" + fi + if expr ${pkg} : '^glib-2' > /dev/null ; then + warn "you need USE_GNOME+=glib20" + fi + if expr ${pkg} : '^cairo-[0-9]' > /dev/null ; then + warn "you need USE_GNOME+=cairo" + fi + # Xorg-libraries: this should be by XORG_MODULES @ bsd.xorg.mk + if echo ${pkg} | grep -E '^lib(X11|Xau|Xdmcp|Xext|SM|ICE|Xfixes|Xft|Xdamage|Xcomposite|Xmu|Xmuu|Xpm|Xt|Xi|Xrandr|Xrender|Xres)-' > /dev/null ; then + warn "you need USE_XORG+=$(echo ${pkg} | sed -E 's/^lib(.+)\-.*/\1/' | tr '[:upper:]' '[:lower:]')" + fi + # Qt4 + if echo ${pkg} | grep -E '^qt4-([a-z]+)-[0-9]' > /dev/null ; then + warn "you need USE_QT4+=$(echo ${pkg} | sed -E 's/^qt4-([a-z]+)-[0-9].*/\1/')" + fi + # Qt5 + if echo ${pkg} | grep -E '^qt5-([a-z]+)-[0-9]' > /dev/null ; then + warn "you need USE_QT5+=$(echo ${pkg} | sed -E 's/^qt5-([a-z]+)-[0-9].*/\1/')" + fi +} +proxydeps_check() { + local pkg=$1 + local filelist=$2 + local deplist=$3 + + local file dep_file dep_file_pkg already pkg_dep_files + + # check for every dynamic executable + for file in ${filelist}; do + pkg_dep_files=$(ldd -a "${file}" | \ + awk 'BEGIN {section=0}; /^\// {section++} /^[^\/]/ {if(section<=1) print}' | \ + sed -e 's/.*=> //' | sed -e 's/ .*//') + # check every dependency file + for dep_file in $pkg_dep_files; do + if listcontains ${dep_file} "${already}" ; then + continue + fi + if ! (expr "$dep_file" : '^/lib/' \| "$dep_file" : '^/usr/lib/' > /dev/null) ; then + if $(pkg which ${dep_file} > /dev/null 2>&1) ; then + dep_file_pkg=$(pkg which ${dep_file} | sed -e 's/.* installed by package //g') + if ! listcontains ${dep_file_pkg} "${deplist} ${pkg}" ; then + warn "dependency file ${dep_file} belongs to the package ${dep_file_pkg} which isn't declared as a dependency" + proxydeps_suggest_uses ${dep_file_pkg} + fi + else + warn "dependency file ${dep_file} doesn't belong to any package" + fi + fi + already="${already} ${dep_file}" + done + done +} + + +proxydeps() { + # finds all dynamic executables which have dependencies that aren't within the + # declared set of dependencies in this port + local filelist + filelist=`find ${STAGEDIR} -type f \ + \( -perm -u+x -or -perm -g+x -or -perm -o+x \) \ + -and -exec /bin/sh -c "ldd {} > /dev/null 2>&1" \; \ + -and -exec echo {} \;` + proxydeps_check ${PKG_NAME} "${filelist}" "${PKG_DEPS}" +} + +checks="shebang symlinks paths stripped desktopfileutils sharedmimeinfo suidfiles libtool proxydeps" + ret=0 cd ${STAGEDIR} for check in ${checks}; do