Move each package operation into a file.
This change will accomodate better new package managers
This commit is contained in:
parent
d178098b44
commit
0f0ba26f8e
@ -5,39 +5,6 @@ kickstart.package.manager() {
|
|||||||
kickstart.info "kickstart supports apt-get, yum or brew" && exit 1
|
kickstart.info "kickstart supports apt-get, yum or brew" && exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
kickstart.package.installed.apt-get() {
|
for recipe in recipes/kickstart/package/*.sh; do
|
||||||
dpkg -s "$@" >/dev/null 2>&1
|
source $recipe
|
||||||
}
|
|
||||||
|
|
||||||
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
|
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
|
|
||||||
}
|
|
||||||
|
20
kickstart/recipes/kickstart/package/install.sh
Normal file
20
kickstart/recipes/kickstart/package/install.sh
Normal 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 "$@"
|
||||||
|
}
|
19
kickstart/recipes/kickstart/package/installed.sh
Normal file
19
kickstart/recipes/kickstart/package/installed.sh
Normal 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
|
||||||
|
}
|
5
kickstart/recipes/kickstart/package/update.sh
Normal file
5
kickstart/recipes/kickstart/package/update.sh
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
|
||||||
|
kickstart.package.update() {
|
||||||
|
kickstart.mute `kickstart.package.manager` update -y
|
||||||
|
}
|
||||||
|
|
3
kickstart/recipes/kickstart/package/upgrade.sh
Normal file
3
kickstart/recipes/kickstart/package/upgrade.sh
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
kickstart.package.upgrade() {
|
||||||
|
kickstart.mute `kickstart.package.manager` upgrade -y
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user