Implement homebrew/aptitude adapters for rake provisioner
This commit is contained in:
parent
889a15ad70
commit
042a681c09
|
@ -8,6 +8,20 @@ module Package
|
|||
self.run("install", "-y", package)
|
||||
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
|
||||
|
||||
def run(*args)
|
||||
|
|
|
@ -33,23 +33,31 @@ module Package
|
|||
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
|
||||
def cask_install(cask)
|
||||
self.run("cask", "install", cask) unless self.cask_installed?(cask)
|
||||
end
|
||||
|
||||
def cask_remove(cask)
|
||||
self.run("cask", "uninstall", cask) unless self.cask_installed?(cask)
|
||||
end
|
||||
|
||||
def cask_installed?(cask)
|
||||
self.run("cask list | grep -w '#{cask}' >& /dev/null")
|
||||
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)
|
||||
raise "Homebrew isn't installed!" unless self.installed?
|
||||
|
||||
|
|
|
@ -6,14 +6,32 @@ require_relative "lib/sh"
|
|||
|
||||
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
|
||||
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")
|
||||
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
|
||||
|
|
|
@ -48,7 +48,6 @@ if is_mac?
|
|||
Package.update
|
||||
end
|
||||
|
||||
desc "Remove homebrew cleanly"
|
||||
task :remove do
|
||||
Package.destroy if Package.installed?
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue