From 06f7f3a98baa4c2e4802889121f194b1f7c98b28 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 22 Jan 2009 10:19:03 +0100 Subject: pkg: check_prereqs: Added recommends and suggests, aliased depend to require --- bin/pkg | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) (limited to 'bin/pkg') diff --git a/bin/pkg b/bin/pkg index 32cd2f6..d3e08c6 100755 --- a/bin/pkg +++ b/bin/pkg @@ -396,8 +396,8 @@ function check_prereqs { cd $PDIR/$package wrap_info $1 info "checking prerequisites\n" - typeset -a install - typeset warn + typeset -a -U install maybe_install + typeset warn info function is_installed { [[ -d $PDIR/$1 ]] @@ -418,29 +418,57 @@ function check_prereqs { $* || warn+="Requirement failed: $*\n" } } + function depend { + require $* + } + + function suggest { + if [[ $1 == 'package' ]] { + is_installed $2 || info "$package suggests package $2\n" + } else { + $* || info "Suggest failed: $*\n" + } + } + + function recommend { + if [[ $1 == 'package' ]] { + is_installed $2 || maybe_install+=$2 + } else { + $* || info+="Suggest failed: $*\n" + } + } { source prereqs } always { if (( TRY_BLOCK_ERROR )) { - warn 'Error in prereqs script' + warn "Error in prereqs script\n" TRY_BLOCK_ERROR=0 } } - if [[ -n $warn ]] { + if [[ -n $warn || -n $info ]] { warn $warn + info $info read -q } if [[ -n $install ]] { - info "$1 requires the following packages: $install\n" + info "$1 requires the following packages: ${(j:, :)install}\n" if (confirm_yes "Install them?") { for i in $install; { pkg_add $i } } } + if [[ -n $maybe_install ]] { + info "$1 recommends the following packages: ${(j:, :)maybe_install}\n" + if (confirm_no "Install them?") { + for i in $maybe_install; { + pkg_add $i + } + } + } } # Write a package's documentation to .collected -- cgit v1.2.3