diff options
Diffstat (limited to 'mk/flavor/pkg/install-dependencies')
-rwxr-xr-x | mk/flavor/pkg/install-dependencies | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/mk/flavor/pkg/install-dependencies b/mk/flavor/pkg/install-dependencies new file mode 100755 index 00000000000..7db98c2a7db --- /dev/null +++ b/mk/flavor/pkg/install-dependencies @@ -0,0 +1,85 @@ +#!/bin/sh +# +###################################################################### +# +# NAME +# install-dependencies -- install package dependencies +# +# SYNOPSIS +# register-dependencies [ filter ] +# +# DESCRIPTION +# install-dependencies checks all entries in ${DEPENDS_FILE} +# for existance. Missing entries get installed by +# ${DEPENDS_TARGET} in the listed directory. +# +###################################################################### + +: ${CAT:=cat} +: ${ECHO:=echo} +: ${TEST:=test} +: ${TRUE:=true} + +set -e + +DEPENDS_FILE=${_DEPENDS_FILE} +unset _DEPENDS_FILE +PKGNAME=${_PKGNAME} +unset _PKGNAME + +if [ $# = 1 ]; then + type_filter=$1 +else + type_filter=all +fi + +error_msg() { + ${ECHO} "ERROR:" "$*" 1>&2 +} + +step_msg() { + ${ECHO} "=>" "$*" +} + +find_best() { + ${PKG_ADMIN} -b -d ${_PKG_DBDIR} -S lsbest $1 || ${TRUE} +} + +${CAT} ${DEPENDS_FILE} | while read type pattern dir; do + [ $type_filter != all ] && [ $type_filter = "$filter" ] && continue + pkg=`find_best "$pattern"` + case "$pkg" in + "") + step_msg "Required installed package $pattern: NOT found" + target=${DEPENDS_TARGET} + if ${TEST} ! -d "$dir"; then + error_msg "[install-depends] The directory \`\`$dir'' does not exist." + exit 1 + fi + step_msg "Verifying $target for $dir" + cd $dir + ${SETENV} ${PKGSRC_MAKE_ENV} _PKGSRC_DEPS=", ${PKGNAME}${_PKGSRC_DEPS}" PKGNAME_REQD="$pattern" ${MAKE} ${MAKEFLAGS} _AUTOMATIC=yes $target + pkg=`find_best "$pattern"` + case "$pkg" in + "") error_msg "[install-depends] 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 + esac + step_msg "Returning to build of ${PKGNAME}" + ;; + *) + objfmt=`${PKG_INFO} -Q OBJECT_FMT "$pkg"` + case "$objfmt" in + "") ${WARNING_MSG} "[install-depends] Unknown object format for installed package $pkg" ;; + ${OBJECT_FMT}) ;; + *) error_msg "[install-depends] Installed package $pkg has an" + error_msg " object format \`\`$objfmt'' which differs from \`\`${OBJECT_FMT}''. Please" + error_msg " update the $pkg package to ${OBJECT_FMT}." + exit 1 + ;; + esac; + step_msg "Required installed package $pattern: $pkg found" + ;; + esac +done |