Move each package operation into a file.

This change will accomodate better new package managers
This commit is contained in:
Bruno Tavares 2014-03-20 18:21:22 -03:00
parent d178098b44
commit 0f0ba26f8e
5 changed files with 50 additions and 36 deletions

View File

@ -5,39 +5,6 @@ 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() {
kickstart.package.installed.`kickstart.package.manager` "$@"
}
kickstart.package.install() {
if kickstart.package.installed "$@"; then
kickstart.info "$@ already installed"
else
kickstart.info "No packages found matching $@. Installing..."
kickstart.mute `kickstart.package.manager` install -y "$@"
fi
}
kickstart.package.update() {
kickstart.mute `kickstart.package.manager` update -y
}
kickstart.package.upgrade() {
kickstart.mute `kickstart.package.manager` upgrade -y
}
for recipe in recipes/kickstart/package/*.sh; do
source $recipe
done

View File

@ -0,0 +1,20 @@
kickstart.package.install() {
if kickstart.package.installed "$@"; then
kickstart.info "$@ already installed"
else
kickstart.info "No packages found matching $@. Installing..."
kickstart.package.install.`kickstart.package.manager` "$@"
fi
}
kickstart.package.install.apt-get() {
kickstart.mute apt-get install -y "$@"
}
kickstart.package.install.brew() {
kickstart.mute brew install -y "$@"
}
kickstart.package.install.yum() {
kickstart.mute yum install -y "$@"
}

View File

@ -0,0 +1,19 @@
kickstart.package.installed() {
kickstart.package.installed.`kickstart.package.manager` "$@"
}
kickstart.package.installed.apt-get() {
kickstart.mute dpkg -s "$@"
}
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
}

View File

@ -0,0 +1,5 @@
kickstart.package.update() {
kickstart.mute `kickstart.package.manager` update -y
}

View File

@ -0,0 +1,3 @@
kickstart.package.upgrade() {
kickstart.mute `kickstart.package.manager` upgrade -y
}