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