summaryrefslogtreecommitdiff
path: root/mk/pkgformat/pkg/resolve-dependencies
blob: 89296f1e5fa961f919cd80f405e24b0d777c5b63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/sh
#
######################################################################
#
# NAME
#	resolve-dependencies -- resolve package dependencies
#
# SYNOPSIS
#	resolve-dependencies
#
# DESCRIPTION
#	resolve-dependencies checks all entries in ${DEPENDS_FILE}
#	for existance.  The best matching pattern is printed similiar
#	to list-dependencies
#
######################################################################

: ${CAT:=cat}
: ${ECHO:=echo}
: ${TEST:=test}
: ${TRUE:=true}

set -e

DEPENDS_FILE=${_DEPENDS_FILE}
unset _DEPENDS_FILE

error_msg() {
	${ECHO} "ERROR:" "$*" 1>&2
}

find_best() {
	case $1 in
	bootstrap|tool)
		${HOST_PKG_INFO} -E "$2" || ${TRUE};;
	build|full)
		${PKG_INFO} -E "$2" || ${TRUE};;
	esac
}

${CAT} ${DEPENDS_FILE} | while read type pattern dir; do
	pkg=`find_best "$type" "$pattern"`
	case "$pkg" in
	"")
		error_msg "[resolve-dependencies] A package matching \`\`$pattern'' should"
		error_msg "    be installed, but one cannot be found.  Perhaps there is a"
		error_msg "    stale work directory for $dir?"
		exit 1
		;;
	*)
		${ECHO} "$type	$pattern	$pkg"
		;;
	esac
done