diff --git a/rake/lib/package_adapters/aptitude.rb b/rake/lib/package_adapters/aptitude.rb index abe68006..3c52b59d 100644 --- a/rake/lib/package_adapters/aptitude.rb +++ b/rake/lib/package_adapters/aptitude.rb @@ -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) diff --git a/rake/lib/package_adapters/homebrew.rb b/rake/lib/package_adapters/homebrew.rb index dc028e33..f9be8090 100644 --- a/rake/lib/package_adapters/homebrew.rb +++ b/rake/lib/package_adapters/homebrew.rb @@ -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? diff --git a/rake/packages.rake b/rake/packages.rake index a7f0f620..14752f84 100644 --- a/rake/packages.rake +++ b/rake/packages.rake @@ -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 diff --git a/rake/pkg/package.rake b/rake/pkg/package.rake index 3382b7b4..a9cb84b0 100644 --- a/rake/pkg/package.rake +++ b/rake/pkg/package.rake @@ -48,7 +48,6 @@ if is_mac? Package.update end - desc "Remove homebrew cleanly" task :remove do Package.destroy if Package.installed? end