Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-ports-gnome
Path: blob/main/Mk/Scripts/depends-list.sh
16124 views
1
#!/bin/sh
2
# MAINTAINER: [email protected]
3
4
set -e
5
set -o pipefail
6
7
. ${dp_SCRIPTSDIR}/functions.sh
8
9
flavors=0
10
recursive=0
11
missing=0
12
requires_wrkdir=0
13
while getopts "fmrw" FLAG; do
14
case "${FLAG}" in
15
f)
16
flavors=1
17
;;
18
m)
19
missing=1
20
recursive=1
21
;;
22
r)
23
recursive=1
24
;;
25
w)
26
# Only list dependencies that have a WRKDIR. Used for
27
# 'make clean-depends'.
28
# Without -r recurse when WRKDIR exists; with -r
29
# always recurse.
30
requires_wrkdir=1
31
;;
32
*)
33
echo "Unknown flag" >&2
34
exit 1
35
;;
36
esac
37
done
38
shift $((OPTIND-1))
39
40
validate_env PORTSDIR dp_OVERLAYS dp_PKGNAME
41
if [ ${recursive} -eq 1 -o ${requires_wrkdir} -eq 1 ]; then
42
validate_env dp_MAKE
43
# Cache command executions to avoid looking them up again in every
44
# sub-make.
45
MAKE="${dp_MAKE}" export_ports_env >/dev/null
46
fi
47
48
[ -n "${DEBUG_MK_SCRIPTS}" -o -n "${DEBUG_MK_SCRIPTS_DEPENDS_LIST}" ] && set -x
49
50
set -u
51
52
if [ ${missing} -eq 1 ]; then
53
existing=$(${dp_PKG_INFO} -aoq|paste -d ' ' -s -)
54
fi
55
56
check_dep() {
57
local _dep wrkdir show_dep
58
59
for _dep ; do
60
unset FLAVOR
61
myifs=${IFS}
62
IFS=:
63
set -- ${_dep}
64
IFS=${myifs}
65
66
case "${2}" in
67
/*) d=${2} ;;
68
*) for overlay in ${dp_OVERLAYS} ${PORTSDIR}; do
69
d=${overlay}/${2}
70
f=
71
case "${d}" in
72
*@*/*) ;; # Ignore @ in the path which would not be a flavor
73
*@*)
74
f=${d##*@}
75
d=${d%@*}
76
;;
77
esac
78
if [ -f ${d}/Makefile ]; then
79
if [ -n $f ]; then
80
export FLAVOR=$f
81
fi
82
break
83
fi
84
done
85
esac
86
87
if [ ${flavors} -eq 1 -a -n "${FLAVOR:-}" ]; then
88
port_display="${d}@${FLAVOR}"
89
else
90
port_display="${d}"
91
fi
92
93
case " ${checked} " in
94
*\ ${d}\ *) continue ;; # Already checked
95
esac
96
checked="${checked} ${d}"
97
# Check if the dependency actually exists or skip otherwise.
98
if [ ! -d "${d}" ]; then
99
echo "${dp_PKGNAME}: \"${port_display}\" non-existent -- dependency list incomplete" >&2
100
continue
101
fi
102
103
# If only looking for missing, show if missing
104
if [ ${missing} -eq 1 ]; then
105
case " ${existing} " in
106
*\ ${d#${PORTSDIR}/}\ *) continue ;; # We have it, nothing to see
107
esac
108
fi
109
110
# Grab any needed vars from the port.
111
112
if [ ${requires_wrkdir} -eq 1 ]; then
113
# shellcheck disable=SC2046
114
# We want word splitting here.
115
set -- $(${dp_MAKE} -C ${d} -VWRKDIR -V_UNIFIED_DEPENDS)
116
wrkdir="$1"
117
shift
118
elif [ ${recursive} -eq 1 ]; then
119
# shellcheck disable=SC2046
120
# We want word splitting here.
121
set -- $(${dp_MAKE} -C ${d} -V_UNIFIED_DEPENDS)
122
fi
123
124
# If a WRKDIR is required to show the dependency, check for it.
125
show_dep=1
126
if [ ${requires_wrkdir} -eq 1 ] && ! [ -d "${wrkdir}" ]; then
127
show_dep=0
128
fi
129
[ ${show_dep} -eq 1 ] && echo "${port_display}"
130
if [ ${recursive} -eq 1 -o ${requires_wrkdir} -eq 1 -a ${show_dep} -eq 1 ]; then
131
# shellcheck disable=SC2068
132
# Do not add quotes, we want to split the string here.
133
check_dep $@
134
fi
135
done
136
}
137
138
checked=
139
# shellcheck disable=SC2068
140
# Do not add quotes, we want to split the string here.
141
check_dep $@
142
143