Changeset View
Changeset View
Standalone View
Standalone View
Mk/Scripts/depends-list.sh
#!/bin/sh | #!/bin/sh | ||||
# MAINTAINER: portmgr@FreeBSD.org | # MAINTAINER: portmgr@FreeBSD.org | ||||
# $FreeBSD$ | # $FreeBSD$ | ||||
set -e | set -e | ||||
. ${dp_SCRIPTSDIR}/functions.sh | . ${dp_SCRIPTSDIR}/functions.sh | ||||
recursive=0 | recursive=0 | ||||
missing=0 | |||||
requires_wrkdir=0 | requires_wrkdir=0 | ||||
while getopts "rw" FLAG; do | while getopts "mrw" FLAG; do | ||||
case "${FLAG}" in | case "${FLAG}" in | ||||
m) | |||||
missing=1 | |||||
recursive=1 | |||||
;; | |||||
r) | r) | ||||
recursive=1 | recursive=1 | ||||
;; | ;; | ||||
w) | w) | ||||
# Only list dependencies that have a WRKDIR. Used for | # Only list dependencies that have a WRKDIR. Used for | ||||
# 'make clean-depends'. | # 'make clean-depends'. | ||||
requires_wrkdir=1 | requires_wrkdir=1 | ||||
;; | ;; | ||||
Show All 12 Lines | if [ ${recursive} -eq 1 -o ${requires_wrkdir} -eq 1 ]; then | ||||
# sub-make. | # sub-make. | ||||
MAKE="${dp_MAKE}" export_ports_env >/dev/null | MAKE="${dp_MAKE}" export_ports_env >/dev/null | ||||
fi | fi | ||||
[ -n "${DEBUG_MK_SCRIPTS}" -o -n "${DEBUG_MK_SCRIPTS_DEPENDS_LIST}" ] && set -x | [ -n "${DEBUG_MK_SCRIPTS}" -o -n "${DEBUG_MK_SCRIPTS_DEPENDS_LIST}" ] && set -x | ||||
set -u | set -u | ||||
if [ ${missing} -eq 1 ]; then | |||||
existing=$(${dp_PKG_INFO} -aoq|sed -e "s=^=${PORTSDIR}/="|xargs echo) | |||||
fi | |||||
check_dep() { | check_dep() { | ||||
local _dep wrkdir show_dep | local _dep wrkdir show_dep | ||||
for _dep ; do | for _dep ; do | ||||
myifs=${IFS} | myifs=${IFS} | ||||
IFS=: | IFS=: | ||||
set -- ${_dep} | set -- ${_dep} | ||||
IFS=${myifs} | IFS=${myifs} | ||||
case "${2}" in | case "${2}" in | ||||
/*) d=${2} ;; | /*) d=${2} ;; | ||||
*) d=${PORTSDIR}/${2} ;; | *) d=${PORTSDIR}/${2} ;; | ||||
esac | esac | ||||
case " ${checked} " in | case " ${checked} " in | ||||
*\ ${d}\ *) continue ;; # Already checked | *\ ${d}\ *) continue ;; # Already checked | ||||
esac | esac | ||||
checked="${checked} ${d}" | checked="${checked} ${d}" | ||||
# Check if the dependency actually exists or skip otherwise. | # Check if the dependency actually exists or skip otherwise. | ||||
if [ ! -d ${d} ]; then | if [ ! -d ${d} ]; then | ||||
echo "${dp_PKGNAME}: \"${d}\" non-existent -- dependency list incomplete" >&2 | echo "${dp_PKGNAME}: \"${d}\" non-existent -- dependency list incomplete" >&2 | ||||
continue | continue | ||||
fi | fi | ||||
# If only looking for missign, show if missing | |||||
wblock: spelling, "missing" | |||||
if [ ${missing} -eq 1 ]; then | |||||
case " ${existing} " in | |||||
*\ ${d}\ *) continue ;; # We have it, nothing to see | |||||
esac | |||||
fi | |||||
# Grab any needed vars from the port. | # Grab any needed vars from the port. | ||||
if [ ${requires_wrkdir} -eq 1 -a ${recursive} -eq 1 ]; then | if [ ${requires_wrkdir} -eq 1 -a ${recursive} -eq 1 ]; then | ||||
set -- $(${dp_MAKE} -C ${d} -VWRKDIR -V_UNIFIED_DEPENDS) | set -- $(${dp_MAKE} -C ${d} -VWRKDIR -V_UNIFIED_DEPENDS) | ||||
wrkdir="$1" | wrkdir="$1" | ||||
shift | shift | ||||
elif [ ${requires_wrkdir} -eq 1 -a ${recursive} -eq 0 ]; then | elif [ ${requires_wrkdir} -eq 1 -a ${recursive} -eq 0 ]; then | ||||
set -- "$(${dp_MAKE} -C ${d} -VWRKDIR)" | set -- "$(${dp_MAKE} -C ${d} -VWRKDIR)" | ||||
wrkdir="$1" | wrkdir="$1" | ||||
elif [ ${recursive} -eq 1 ]; then | elif [ ${recursive} -eq 1 ]; then | ||||
set -- $(${dp_MAKE} -C ${d} -V_UNIFIED_DEPENDS) | set -- $(${dp_MAKE} -C ${d} -V_UNIFIED_DEPENDS) | ||||
fi | fi | ||||
# If a WRKDIR is required to show the dependency, check for it. | # If a WRKDIR is required to show the dependency, check for it. | ||||
show_dep=1 | show_dep=1 | ||||
if [ ${requires_wrkdir} -eq 1 ] && ! [ -d "${wrkdir}" ]; then | if [ ${requires_wrkdir} -eq 1 ] && ! [ -d "${wrkdir}" ]; then | ||||
show_dep=0 | show_dep=0 | ||||
fi | fi | ||||
[ ${show_dep} -eq 1 ] && echo ${d} | [ ${show_dep} -eq 1 ] && echo ${d} | ||||
if [ ${recursive} -eq 1 ]; then | if [ ${recursive} -eq 1 -o ${missing} -eq 1 ]; then | ||||
check_dep $@ | check_dep $@ | ||||
fi | fi | ||||
done | done | ||||
} | } | ||||
checked= | checked= | ||||
check_dep $@ | check_dep $@ |
spelling, "missing"