summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2008-10-30 13:51:08 +0100
committerDaniel Friesel <derf@derf.homelinux.org>2008-10-30 13:51:08 +0100
commit290a99cef54edfd8b54349cfe658450f14d69134 (patch)
tree7df6f9bea696793d81850cc612c9fc14381c1e6b /bin
parentfec1c5f638fb8c97c15afe3dc665a8af0e9b879f (diff)
bin/pkg: check_prereqs: Added require() for less redundancy
Diffstat (limited to 'bin')
-rwxr-xr-xbin/pkg21
1 files changed, 17 insertions, 4 deletions
diff --git a/bin/pkg b/bin/pkg
index 3816b4c..427f13f 100755
--- a/bin/pkg
+++ b/bin/pkg
@@ -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?") {