Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-ports-kde
Path: blob/main/Mk/Scripts/depends-list.sh
16462 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 subpkg
73
*~*)
74
d=${d%~*}
75
;;
76
esac
77
case "${d}" in
78
*@*/*) ;; # Ignore @ in the path which would not be a flavor
79
*@*)
80
f=${d##*@}
81
d=${d%@*}
82
;;
83
esac
84
if [ -f ${d}/Makefile ]; then
85
if [ -n "$f" ]; then
86
export FLAVOR=$f
87
fi
88
break
89
fi
90
done
91
esac
92
93
if [ ${flavors} -eq 1 -a -n "${FLAVOR:-}" ]; then
94
port_display="${d}@${FLAVOR}"
95
else
96
port_display="${d}"
97
fi
98
99
case " ${checked} " in
100
*\ ${port_display}\ *) continue ;; # Already checked
101
esac
102
checked="${checked} ${port_display}"
103
# Check if the dependency actually exists or skip otherwise.
104
if [ ! -d "${d}" ]; then
105
echo "${dp_PKGNAME}: \"${port_display}\" non-existent -- dependency list incomplete" >&2
106
continue
107
fi
108
109
# If only looking for missing, show if missing
110
if [ ${missing} -eq 1 ]; then
111
case " ${existing} " in
112
*\ ${d#${PORTSDIR}/}\ *) continue ;; # We have it, nothing to see
113
esac
114
fi
115
116
# Grab any needed vars from the port.
117
118
if [ ${requires_wrkdir} -eq 1 ]; then
119
# shellcheck disable=SC2046
120
# We want word splitting here.
121
set -- $(${dp_MAKE} -C ${d} -VWRKDIR -V_UNIFIED_DEPENDS)
122
wrkdir="$1"
123
shift
124
elif [ ${recursive} -eq 1 ]; then
125
# shellcheck disable=SC2046
126
# We want word splitting here.
127
set -- $(${dp_MAKE} -C ${d} -V_UNIFIED_DEPENDS)
128
fi
129
130
# If a WRKDIR is required to show the dependency, check for it.
131
show_dep=1
132
if [ ${requires_wrkdir} -eq 1 ] && ! [ -d "${wrkdir}" ]; then
133
show_dep=0
134
fi
135
[ ${show_dep} -eq 1 ] && echo "${port_display}"
136
if [ ${recursive} -eq 1 -o ${requires_wrkdir} -eq 1 -a ${show_dep} -eq 1 ]; then
137
# shellcheck disable=SC2068
138
# Do not add quotes, we want to split the string here.
139
check_dep $@
140
fi
141
done
142
}
143
144
checked=
145
# shellcheck disable=SC2068
146
# Do not add quotes, we want to split the string here.
147
check_dep $@
148
149