Extract kickstart.package.installed functions for each package manager
This commit is contained in:
parent
5f420e6f24
commit
cafc7b1d93
@ -5,26 +5,24 @@ kickstart.package.manager() {
|
||||
kickstart.info "kickstart supports apt-get, yum or brew" && exit 1
|
||||
}
|
||||
|
||||
kickstart.package.installed.apt-get() {
|
||||
dpkg -s "$@" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
kickstart.package.installed.brew() {
|
||||
! $(brew info "$@" | kickstart.stream.contains "Not installed")
|
||||
}
|
||||
|
||||
kickstart.package.installed.yum() {
|
||||
local yum_packages="`yum list installed`"
|
||||
for package in "$@"; do
|
||||
kickstart.stream.contains $package <<<$yum_packages || return 1
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
kickstart.package.installed() {
|
||||
local pkg_manager=`kickstart.package.manager`
|
||||
|
||||
if [ $pkg_manager = 'apt-get' ]; then
|
||||
dpkg -s "$@" >/dev/null 2>&1
|
||||
return $?
|
||||
fi
|
||||
|
||||
if [ $pkg_manager = 'brew' ]; then
|
||||
! $(brew info "$@" | kickstart.stream.contains "Not installed")
|
||||
return $?
|
||||
fi
|
||||
|
||||
if [ $pkg_manager = 'yum' ]; then
|
||||
local yum_packages="`yum list installed`"
|
||||
for package in "$@"; do
|
||||
kickstart.stream.contains $package <<<$yum_packages || return 1
|
||||
done
|
||||
return 0
|
||||
fi
|
||||
kickstart.package.installed.`kickstart.package.manager` "$@"
|
||||
}
|
||||
|
||||
kickstart.package.install() {
|
||||
|
Loading…
Reference in New Issue
Block a user