Implement homebrew/aptitude adapters for rake provisioner

This commit is contained in:
Henrik Lissner 2014-09-05 17:02:40 -04:00
parent 889a15ad70
commit 042a681c09
4 changed files with 56 additions and 17 deletions

View file

@ -8,6 +8,20 @@ module Package
self.run("install", "-y", package) self.run("install", "-y", package)
end end
def installed?; end
def remove(package); end
def update(*args); end
def tap(repo)
sh_safe "sudo add-apt-repository #{repo}"
end
def untap(repo); end
def tapped?(repo); end
# TODO Finish aptitude adapter # TODO Finish aptitude adapter
def run(*args) def run(*args)

View file

@ -33,23 +33,31 @@ module Package
end end
end end
def tap(repo)
self.run("tap", repo) unless self.tapped?(repo)
end
def untap(repo)
self.run("untap #{repo}")
end
def tapped?(repo)
self.run("tap | grep -w '#{repo}' >& /dev/null")
end
# Homebrew-specific functions # Homebrew-specific functions
def cask_install(cask) def cask_install(cask)
self.run("cask", "install", cask) unless self.cask_installed?(cask) self.run("cask", "install", cask) unless self.cask_installed?(cask)
end end
def cask_remove(cask)
self.run("cask", "uninstall", cask) unless self.cask_installed?(cask)
end
def cask_installed?(cask) def cask_installed?(cask)
self.run("cask list | grep -w '#{cask}' >& /dev/null") self.run("cask list | grep -w '#{cask}' >& /dev/null")
end end
def tap(repo)
self.run("tap", repo) unless self.tapped?(repo)
end
def tapped?(repo)
self.run("tap | grep -w '#{repo}' >& /dev/null")
end
def run(*args) def run(*args)
raise "Homebrew isn't installed!" unless self.installed? raise "Homebrew isn't installed!" unless self.installed?

View file

@ -6,14 +6,32 @@ require_relative "lib/sh"
verbose(false) verbose(false)
if is_mac?
desc 'Setup/update homebrew & packages'
task :update => 'pkg:homebrew:update'
elsif is_linux?
desc 'Setup/update packages'
task :update => 'pkg:aptitude:update'
end
namespace :pkg do namespace :pkg do
desc 'Setup/update package manager & packages'
if is_mac?
task :update => 'homebrew:update'
elsif is_linux?
task :update => 'aptitude:update'
else
task :update do
echo "Package manager not implemented for this OS"
end
end
load_all("pkg/*.rake") load_all("pkg/*.rake")
end end
namespace :test do
task :output do
echo "Testing output"
echo "Testing sub-header output", 2
echo "Another sub-header", 3
error "A big bad error!"
end
task :tasks do
sh "echo 'This should pass'"
sh_safe "fake-command_ This should fail" # without disrupting the task
end
end

View file

@ -48,7 +48,6 @@ if is_mac?
Package.update Package.update
end end
desc "Remove homebrew cleanly"
task :remove do task :remove do
Package.destroy if Package.installed? Package.destroy if Package.installed?
end end