Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Rewrite the 'ppa' dep to use `add-apt-repository` so the repo's key i…

…s added.

* Also, check for existence by checking for the apt list, which will catch the case where the ppa has been added but `apt-get update` hasn't been run yet.
  • Loading branch information...
commit 86662889bd8d2937febb43046bfb09e081e0f6a5 1 parent da32050
@benhoskings authored
Showing with 14 additions and 16 deletions.
  1. +14 −16 deps/apt.rb
View
30 deps/apt.rb
@@ -20,26 +20,24 @@ def present_in_file? filename
end
dep 'ppa', :spec do
- def spec_path
- spec.to_s.gsub(/^.*:/, '')
+ requires 'python-software-properties.bin'
+ def spec_name
+ log_error("'#{spec}' doesn't look like 'ppa:something'.") unless spec[/^ppa\:\w+/]
+ spec.sub(/^ppa\:/, '')
end
- def present_in_file? filename
- # e.g. deb http://ppa.launchpad.net/pitti/postgresql/ubuntu natty main
- filename.p.read[/^deb https?:\/\/[^\/]+\/#{spec_path}\/#{Babushka.host.flavour}\b/]
+ def ppa_release_file
+ # This may be hardcoded to some extent, but I'm calling YAGNI on it for now.
+ "ppa.launchpad.net_#{spec_name.gsub('/', '_')}_ubuntu_dists_#{Babushka.host.name}_Release"
end
- before {
- spec[/^\w+\:\w+/] or log_error("'#{spec}' doesn't look like 'ppa:something'.")
- }
met? {
- present_in_file?('/etc/apt/sources.list') or
- Dir.glob("/etc/apt/sources.list.d/*").any? {|f| present_in_file?(f) }
+ ('/var/lib/apt/lists/' / ppa_release_file).exists?
}
meet {
- '/etc/apt/sources.list.d/babushka.list'.p.append(
- "deb http://ppa.launchpad.net/#{spec_path}/ubuntu #{Babushka.host.name} main\n"
- )
- }
- after {
- Babushka::AptHelper.update_pkg_lists "Updating apt lists to load #{spec}."
+ log_shell "Adding #{spec}", "add-apt-repository '#{spec}'", :spinner => true
+ log_shell "Updating apt lists to load #{spec}.", "apt-get update"
}
end
+
+dep 'python-software-properties.bin' do
+ provides 'add-apt-repository'
+end
Please sign in to comment.
Something went wrong with that request. Please try again.