Add yum support to kickstart.package functions
Yum only supports passing one package to check its info. Other package managers allow you to have several packages name, and return non-zero whenever one is not installed. To have the same behaviour on yum, we iterate over the list until we find one that is not installed.
This commit is contained in:
parent
c9633bb7b9
commit
02cc6bcbf9
@ -1,13 +1,21 @@
|
||||
kickstart.package.manager() {
|
||||
kickstart.command_exists apt-get && echo "apt-get" && return 0
|
||||
kickstart.command_exists brew && echo "brew" && return 0
|
||||
kickstart.info "kickstart supports apt-get or brew" && exit 1
|
||||
kickstart.command_exists yum && echo "yum" && return 0
|
||||
kickstart.info "kickstart supports apt-get, yum or brew" && exit 1
|
||||
}
|
||||
|
||||
kickstart.package.installed() {
|
||||
local pkg_manager=`kickstart.package.manager`
|
||||
[ $pkg_manager = 'apt-get' ] && dpkg -s "$@" >/dev/null 2>&1 && return $?
|
||||
[ $pkg_manager = 'brew' ] && ! $(brew info "$@" | kickstart.stream.contains "Not installed") && return $?
|
||||
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.install() {
|
||||
|
Loading…
Reference in New Issue
Block a user