summaryrefslogtreecommitdiff
path: root/mk/flavor/pkg/resolve-dependencies
blob: 30f343566e39855d6ad9c828885e6ef664d62c66 (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
#!/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() {
	${PKG_ADMIN} -b -d ${_PKG_DBDIR} -S lsbest $1 || ${TRUE}
}

${CAT} ${DEPENDS_FILE} | while read type pattern dir; do
	pkg=`find_best "$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