Add changes to Homebrew internals for bottling.
This commit is contained in:
parent
760bbb4e36
commit
31dea3b800
@ -60,7 +60,7 @@ class CurlDownloadStrategy < AbstractDownloadStrategy
|
||||
raise
|
||||
end
|
||||
else
|
||||
puts "File already downloaded and cached to #{HOMEBREW_CACHE}"
|
||||
puts "File already downloaded in #{File.dirname(@tarball_path)}"
|
||||
end
|
||||
return @tarball_path # thus performs checksum verification
|
||||
end
|
||||
@ -160,6 +160,18 @@ class CurlUnsafeDownloadStrategy < CurlDownloadStrategy
|
||||
end
|
||||
end
|
||||
|
||||
# This strategy extracts our binary packages.
|
||||
class CurlBottleDownloadStrategy <CurlDownloadStrategy
|
||||
def initialize url, name, version, specs
|
||||
super
|
||||
@tarball_path=HOMEBREW_CACHE+'Bottles'+("#{name}-#{version}"+ext)
|
||||
end
|
||||
def stage
|
||||
ohai "Pouring #{File.basename(@tarball_path)}"
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
class SubversionDownloadStrategy <AbstractDownloadStrategy
|
||||
def initialize url, name, version, specs
|
||||
super
|
||||
|
||||
@ -58,10 +58,19 @@ module HomebrewArgvExtension
|
||||
def build_head?
|
||||
flag? '--HEAD'
|
||||
end
|
||||
|
||||
def build_universal?
|
||||
include? '--universal'
|
||||
end
|
||||
|
||||
def build_from_source?
|
||||
flag? '--build-from-source' or ENV['HOMEBREW_BUILD_FROM_SOURCE']
|
||||
end
|
||||
|
||||
def one?
|
||||
flag? "--1"
|
||||
end
|
||||
|
||||
def flag? flag
|
||||
options_only.each do |arg|
|
||||
return true if arg == flag
|
||||
|
||||
@ -45,6 +45,13 @@ 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.
|
||||
@ -94,12 +101,14 @@ end
|
||||
class Formula
|
||||
include FileUtils
|
||||
|
||||
attr_reader :name, :path, :url, :version, :homepage, :specs, :downloader
|
||||
attr_reader :name, :path, :url, :bottle, :bottle_sha1, :version, :homepage, :specs, :downloader
|
||||
|
||||
# Homebrew determines the name
|
||||
def initialize name='__UNKNOWN__', path=nil
|
||||
set_instance_variable 'homepage'
|
||||
set_instance_variable 'url'
|
||||
set_instance_variable 'bottle'
|
||||
set_instance_variable 'bottle_sha1'
|
||||
set_instance_variable 'head'
|
||||
set_instance_variable 'specs'
|
||||
|
||||
@ -110,6 +119,8 @@ class Formula
|
||||
@url = @head
|
||||
@version = 'HEAD'
|
||||
@spec_to_use = @unstable
|
||||
elsif pouring
|
||||
@spec_to_use = BottleSoftwareSpecification.new(@bottle, @specs)
|
||||
else
|
||||
if @stable.nil?
|
||||
@spec_to_use = SoftwareSpecification.new(@url, @specs)
|
||||
@ -442,6 +453,10 @@ class Formula
|
||||
end
|
||||
end
|
||||
|
||||
def pouring
|
||||
return (@bottle or ARGV.build_from_source?)
|
||||
end
|
||||
|
||||
protected
|
||||
# Pretty titles the command and buffers stdout/stderr
|
||||
# Throws if there's an error
|
||||
@ -500,10 +515,16 @@ private
|
||||
|
||||
def verify_download_integrity fn
|
||||
require 'digest'
|
||||
type=CHECKSUM_TYPES.detect { |type| instance_variable_defined?("@#{type}") }
|
||||
type ||= :md5
|
||||
supplied=instance_variable_get("@#{type}")
|
||||
type=type.to_s.upcase
|
||||
if not pouring
|
||||
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"
|
||||
end
|
||||
|
||||
hasher = Digest.const_get(type)
|
||||
hash = fn.incremental_hash(hasher)
|
||||
|
||||
@ -528,14 +549,21 @@ EOF
|
||||
fetched = @downloader.fetch
|
||||
verify_download_integrity fetched if fetched.kind_of? Pathname
|
||||
|
||||
mktemp do
|
||||
@downloader.stage
|
||||
yield
|
||||
if not pouring
|
||||
mktemp do
|
||||
@downloader.stage
|
||||
yield
|
||||
end
|
||||
else
|
||||
HOMEBREW_CELLAR.cd do
|
||||
@downloader.stage
|
||||
yield
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def patch
|
||||
return if patches.nil?
|
||||
return if patches.nil? or pouring
|
||||
|
||||
if not patches.kind_of? Hash
|
||||
# We assume -p1
|
||||
@ -629,6 +657,7 @@ EOF
|
||||
|
||||
attr_rw :version, :homepage, :specs, :deps, :external_deps
|
||||
attr_rw :keg_only_reason, :fails_with_llvm_reason, :skip_clean_all
|
||||
attr_rw :bottle, :bottle_sha1
|
||||
attr_rw(*CHECKSUM_TYPES)
|
||||
|
||||
def head val=nil, specs=nil
|
||||
|
||||
@ -89,7 +89,7 @@ def install f
|
||||
else
|
||||
f.prefix.mkpath
|
||||
beginning=Time.now
|
||||
f.install
|
||||
f.install if not f.pouring
|
||||
FORMULA_META_FILES.each do |filename|
|
||||
next if File.directory? filename
|
||||
target_file = filename
|
||||
@ -99,7 +99,7 @@ def install f
|
||||
f.prefix.install target_file => filename rescue nil
|
||||
(f.prefix+file).chmod 0644 rescue nil
|
||||
end
|
||||
build_time = Time.now-beginning
|
||||
build_time = Time.now-beginning if not f.pouring
|
||||
end
|
||||
end
|
||||
rescue Exception
|
||||
@ -131,7 +131,7 @@ def install f
|
||||
|
||||
begin
|
||||
require 'cleaner'
|
||||
Cleaner.new f
|
||||
Cleaner.new f if not f.pouring
|
||||
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"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user