From 91b26c3f5e55db39eb2afce52453f47fd3c7f360 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 3 Aug 2008 11:47:30 +0200 Subject: bin/pkg: Added support for dependencies on files in $PATH --- bin/pkg | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/bin/pkg b/bin/pkg index c79c45d..600be8b 100755 --- a/bin/pkg +++ b/bin/pkg @@ -268,24 +268,45 @@ exec_hook () { } # Check dependencies and offer to install them +check_path_dep () { + which $1 > /dev/null +} + check_deps () { [[ -r $PDIR/$1/dependencies ]] || return 0 - DEPS=($(cat $PDIR/$1/dependencies)) - INSTALL=() - for dep in $DEPS; { - if [[ ! -d $PDIR/$dep ]] { - INSTALL+="$dep" + dependencies=($(cat $PDIR/$1/dependencies)) + install=() + path_install=() + + for dep in $dependencies; { + pathdep=${dep#=} + if [[ $dep != $pathdep ]] { + if (! check_path_dep $pathdep) { + path_install+=$pathdep + } + } else { + if [[ ! -d $PDIR/$dep ]] { + install+=$dep + } } } - if [[ -n "$INSTALL" ]] { + + if [[ -n $install ]] { + clear_line info "$1 has unmet dependencies: " - echo $INSTALL + echo $install if (confirm_yes "Install dependencies?") { - for pkg in $INSTALL; { + for pkg in $install; { pkg_add $pkg } } } + if [[ -n $path_install ]] { + clear_line + info "$1 has unmet dependencies: " + echo $path_install + echo 'Please make sure these files are within $PATH' + } } check_conflicts () { @@ -298,6 +319,7 @@ check_conflicts () { } } if [[ -n $REMOVE ]] { + clear_line info "$1 conflicts with the following packages: " echo $REMOVE if (confirm_no "Remove conflicting packages and proceed with installation?") { @@ -305,7 +327,7 @@ check_conflicts () { pkg_remove $pkg } } else { - die "Installation aborted" + die "Installation aborted\n" } } } -- cgit v1.2.3