diff options
author | Daniel Friesel <derf@derf.homelinux.org> | 2008-10-30 13:51:08 +0100 |
---|---|---|
committer | Daniel Friesel <derf@derf.homelinux.org> | 2008-10-30 13:51:08 +0100 |
commit | 290a99cef54edfd8b54349cfe658450f14d69134 (patch) | |
tree | 7df6f9bea696793d81850cc612c9fc14381c1e6b /bin/pkg | |
parent | fec1c5f638fb8c97c15afe3dc665a8af0e9b879f (diff) |
bin/pkg: check_prereqs: Added require() for less redundancy
Diffstat (limited to 'bin/pkg')
-rwxr-xr-x | bin/pkg | 21 |
1 files changed, 17 insertions, 4 deletions
@@ -295,22 +295,35 @@ function check_prereqs { cd $PDIR/$package info "checking prerequisites\n" typeset -a install + typeset warn - is_installed () { + function is_installed { [[ -d $PDIR/$1 ]] } - perlmodule () { + function perlmodule { perl -M$1 < /dev/null 2> /dev/null } - file_in_path () { + function file_in_path { which $1 > /dev/null } - offer_install () { + function offer_install { install+=$1 } + function require { + if [[ $1 == 'package' ]] { + is_installed $2 || offer_install $2 + } else { + $* || warn+="Requirement failed: $*\n" + } + } source prereqs + if [[ -n $warn ]] { + warn $warn + read -q + } + if [[ -n $install ]] { info "$1 requires the following packages: $install\n" if (confirm_yes "Install them?") { |