mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Implement bottles again
Bottles now pour purely, without doing all the other unnecessary stuff that happened before the `brew upgrade` code shuffle. Formula.pourable? removed since it was install-specific metadata and not related to the formula itself. Now all such logic is in the FormulaInstaller which is much cleaner. I also changed the bottle cache location to the normal directory and added a .bottle pre-extension. Thus you can see everything in one directory without messing about.
This commit is contained in:
parent
19e387d92e
commit
6ac0a28523
@ -183,8 +183,7 @@ end
|
||||
class CurlBottleDownloadStrategy <CurlDownloadStrategy
|
||||
def initialize url, name, version, specs
|
||||
super
|
||||
HOMEBREW_CACHE_BOTTLES.mkpath
|
||||
@tarball_path=HOMEBREW_CACHE_BOTTLES+("#{name}-#{version}"+ext)
|
||||
@tarball_path = HOMEBREW_CACHE/"#{name}-#{version}.bottle#{ext}"
|
||||
end
|
||||
def stage
|
||||
ohai "Pouring #{File.basename(@tarball_path)}"
|
||||
|
@ -45,13 +45,6 @@ class SoftwareSpecification
|
||||
end
|
||||
end
|
||||
|
||||
class BottleSoftwareSpecification < SoftwareSpecification
|
||||
def download_strategy
|
||||
return CurlBottleDownloadStrategy if @using.nil?
|
||||
raise "Strategies cannot be used with bottles."
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# Used to annotate formulae that duplicate OS X provided software
|
||||
# or cause conflicts when linked in.
|
||||
@ -120,8 +113,6 @@ class Formula
|
||||
@url = @head
|
||||
@version = 'HEAD'
|
||||
@spec_to_use = @unstable
|
||||
elsif pourable?
|
||||
@spec_to_use = BottleSoftwareSpecification.new(@bottle, @specs)
|
||||
else
|
||||
if @stable.nil?
|
||||
@spec_to_use = SoftwareSpecification.new(@url, @specs)
|
||||
@ -457,10 +448,6 @@ class Formula
|
||||
end
|
||||
end
|
||||
|
||||
def pourable?
|
||||
@bottle and not ARGV.build_from_source?
|
||||
end
|
||||
|
||||
protected
|
||||
# Pretty titles the command and buffers stdout/stderr
|
||||
# Throws if there's an error
|
||||
@ -521,16 +508,17 @@ private
|
||||
|
||||
CHECKSUM_TYPES=[:md5, :sha1, :sha256].freeze
|
||||
|
||||
def verify_download_integrity fn
|
||||
public # for FormulaInstaller
|
||||
|
||||
def verify_download_integrity fn, *args
|
||||
require 'digest'
|
||||
if not pourable?
|
||||
if args.count != 2
|
||||
type=CHECKSUM_TYPES.detect { |type| instance_variable_defined?("@#{type}") }
|
||||
type ||= :md5
|
||||
supplied=instance_variable_get("@#{type}")
|
||||
type=type.to_s.upcase
|
||||
else
|
||||
supplied=instance_variable_get("@bottle_sha1")
|
||||
type="SHA1"
|
||||
supplied, type = args
|
||||
end
|
||||
|
||||
hasher = Digest.const_get(type)
|
||||
@ -552,26 +540,20 @@ EOF
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def stage
|
||||
HOMEBREW_CACHE.mkpath
|
||||
fetched = @downloader.fetch
|
||||
verify_download_integrity fetched if fetched.kind_of? Pathname
|
||||
|
||||
if not pourable?
|
||||
mktemp do
|
||||
@downloader.stage
|
||||
yield
|
||||
end
|
||||
else
|
||||
HOMEBREW_CELLAR.cd do
|
||||
@downloader.stage
|
||||
yield
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def patch
|
||||
return if patches.nil? or pourable?
|
||||
return if patches.nil?
|
||||
|
||||
if not patches.kind_of? Hash
|
||||
# We assume -p1
|
||||
|
@ -14,7 +14,7 @@ class FormulaInstaller
|
||||
@f = ff
|
||||
@show_header = true
|
||||
@ignore_deps = ARGV.include? '--ignore-dependencies' || ARGV.interactive?
|
||||
@install_bottle = ff.pourable? #TODO better
|
||||
@install_bottle = !ff.bottle.nil? && !ARGV.build_from_source?
|
||||
end
|
||||
|
||||
def install
|
||||
@ -149,7 +149,7 @@ class FormulaInstaller
|
||||
|
||||
def clean
|
||||
require 'cleaner'
|
||||
Cleaner.new f if not f.pourable?
|
||||
Cleaner.new f
|
||||
rescue Exception => e
|
||||
opoo "The cleaning step did not complete successfully"
|
||||
puts "Still, the installation was successful, so we will link it into your prefix"
|
||||
@ -157,6 +157,18 @@ class FormulaInstaller
|
||||
@show_summary_heading = true
|
||||
end
|
||||
|
||||
def pour
|
||||
HOMEBREW_CACHE.mkpath
|
||||
downloader = CurlBottleDownloadStrategy.new f.bottle, f.name, f.version, nil
|
||||
downloader.fetch
|
||||
f.verify_download_integrity downloader.tarball_path, f.bottle_sha1, "SHA1"
|
||||
HOMEBREW_CELLAR.cd do
|
||||
downloader.stage
|
||||
end
|
||||
end
|
||||
|
||||
## checks
|
||||
|
||||
def paths
|
||||
@paths ||= ENV['PATH'].split(':').map{ |p| File.expand_path p }
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user