From b58077b3e8c182271ae109cffd125d32c7dd99b6 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Sun, 27 Jan 2013 18:41:06 +0000 Subject: [PATCH] Don't use underscores in (new) bottle filenames. Closes Homebrew/homebrew#14270 --- Library/Homebrew/extend/pathname.rb | 2 +- Library/Homebrew/formula.rb | 3 +++ Library/Homebrew/formula_support.rb | 10 +++++++++- Library/Homebrew/macos.rb | 11 +++++++++-- Library/Homebrew/test/test_bottles.rb | 2 +- Library/Homebrew/test/test_formula.rb | 8 ++++---- Library/Homebrew/test/test_versions.rb | 2 +- Library/Homebrew/test/testball.rb | 14 +++++++------- 8 files changed, 35 insertions(+), 17 deletions(-) diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb index 49aa52c048..77719c9848 100644 --- a/Library/Homebrew/extend/pathname.rb +++ b/Library/Homebrew/extend/pathname.rb @@ -5,7 +5,7 @@ require 'mach' class Pathname include MachO - BOTTLE_EXTNAME_RX = /(\.[a-z]+\.bottle\.(\d+\.)?tar\.gz)$/ + BOTTLE_EXTNAME_RX = /(\.[a-z_]+\.bottle\.(\d+\.)?tar\.gz)$/ def install *sources results = [] diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 32e25415c3..cc16820ef9 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -40,6 +40,9 @@ class Formula # then a bottle is not available for the current platform. if @bottle and not (@bottle.checksum.nil? or @bottle.checksum.empty?) @bottle.url ||= bottle_base_url + bottle_filename(self) + if @bottle.cat_without_underscores + @bottle.url.gsub!(MacOS.cat.to_s, MacOS.cat_without_underscores.to_s) + end else @bottle = nil end diff --git a/Library/Homebrew/formula_support.rb b/Library/Homebrew/formula_support.rb index 6e231e7e36..0a5a62bb71 100644 --- a/Library/Homebrew/formula_support.rb +++ b/Library/Homebrew/formula_support.rb @@ -81,10 +81,13 @@ end class Bottle < SoftwareSpec attr_writer :url attr_reader :revision + # TODO: Can be removed when all bottles migrated to underscored cat symbols. + attr_reader :cat_without_underscores def initialize url=nil, version=nil super @revision = 0 + @cat_without_underscores = false end # Checksum methods in the DSL's bottle block optionally take @@ -103,7 +106,12 @@ class Bottle < SoftwareSpec @#{cksum}[value] = Checksum.new(:#{cksum}, key) end - @checksum = @#{cksum}[MacOS.cat] if @#{cksum}.has_key? MacOS.cat + if @#{cksum}.has_key? MacOS.cat + @checksum = @#{cksum}[MacOS.cat] + elsif @#{cksum}.has_key? MacOS.cat_without_underscores + @checksum = @#{cksum}[MacOS.cat_without_underscores] + @cat_without_underscores = true + end end } end diff --git a/Library/Homebrew/macos.rb b/Library/Homebrew/macos.rb index 7ebf0fdbec..891e458f33 100644 --- a/Library/Homebrew/macos.rb +++ b/Library/Homebrew/macos.rb @@ -8,14 +8,21 @@ module MacOS extend self end def cat - if version == :mountain_lion then :mountainlion + if version == :mountain_lion then :mountain_lion elsif version == :lion then :lion - elsif version == :snow_leopard then :snowleopard + elsif version == :snow_leopard then :snow_leopard elsif version == :leopard then :leopard else nil end end + # TODO: Can be removed when all bottles migrated to underscored cat symbols. + def cat_without_underscores + possibly_underscored_cat = cat + return nil unless possibly_underscored_cat + cat.to_s.gsub('_', '').to_sym + end + def locate tool # Don't call tools (cc, make, strip, etc.) directly! # Give the name of the binary you look for as a string to this method diff --git a/Library/Homebrew/test/test_bottles.rb b/Library/Homebrew/test/test_bottles.rb index 8f5104f36a..19d502b729 100644 --- a/Library/Homebrew/test/test_bottles.rb +++ b/Library/Homebrew/test/test_bottles.rb @@ -19,7 +19,7 @@ class BottleTests < Test::Unit::TestCase f = SnowLeopardBottleSpecTestBall.new assert_equal case MacOS.cat - when :snowleopard then f.bottle + when :snow_leopard then f.bottle else f.stable end, f.active_spec diff --git a/Library/Homebrew/test/test_formula.rb b/Library/Homebrew/test/test_formula.rb index a2c6940ff7..69583c15c9 100644 --- a/Library/Homebrew/test/test_formula.rb +++ b/Library/Homebrew/test/test_formula.rb @@ -103,9 +103,9 @@ class FormulaTests < Test::Unit::TestCase assert_equal :sha1, f.bottle.checksum.hash_type assert_equal :sha256, f.devel.checksum.hash_type assert_equal case MacOS.cat - when :snowleopard then 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeef' + when :snow_leopard then 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeef' when :lion then 'baadf00dbaadf00dbaadf00dbaadf00dbaadf00d' - when :mountainlion then '8badf00d8badf00d8badf00d8badf00d8badf00d' + when :mountain_lion then '8badf00d8badf00d8badf00d8badf00d8badf00d' end, f.bottle.checksum.hexdigest assert_match /[0-9a-fA-F]{40}/, f.stable.checksum.hexdigest assert_match /[0-9a-fA-F]{64}/, f.devel.checksum.hexdigest @@ -241,9 +241,9 @@ class FormulaTests < Test::Unit::TestCase assert_equal 1, f.bottle.revision assert_equal case MacOS.cat - when :snowleopard then 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeef' + when :snow_leopard then 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeef' when :lion then 'baadf00dbaadf00dbaadf00dbaadf00dbaadf00d' - when :mountainlion then '8badf00d8badf00d8badf00d8badf00d8badf00d' + when :mountain_lion then '8badf00d8badf00d8badf00d8badf00d8badf00d' end, f.bottle.checksum.hexdigest end diff --git a/Library/Homebrew/test/test_versions.rb b/Library/Homebrew/test/test_versions.rb index 663e7c78d3..0458481b40 100644 --- a/Library/Homebrew/test/test_versions.rb +++ b/Library/Homebrew/test/test_versions.rb @@ -212,7 +212,7 @@ class VersionParsingTests < Test::Unit::TestCase end def test_another_erlang_bottle_style - assert_version_detected 'R15B01', 'https://downloads.sf.net/project/machomebrew/Bottles/erlang-R15B01.mountainlion.bottle.tar.gz' + assert_version_detected 'R15B01', 'https://downloads.sf.net/project/machomebrew/Bottles/erlang-R15B01.mountain_lion.bottle.tar.gz' end def test_yet_another_erlang_bottle_style diff --git a/Library/Homebrew/test/testball.rb b/Library/Homebrew/test/testball.rb index 4ea4027e8b..cb94fd40be 100644 --- a/Library/Homebrew/test/testball.rb +++ b/Library/Homebrew/test/testball.rb @@ -107,9 +107,9 @@ class SpecTestBall < Formula end bottle do - sha1 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeef' => :snowleopard + sha1 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeef' => :snow_leopard sha1 'baadf00dbaadf00dbaadf00dbaadf00dbaadf00d' => :lion - sha1 '8badf00d8badf00d8badf00d8badf00d8badf00d' => :mountainlion + sha1 '8badf00d8badf00d8badf00d8badf00d8badf00d' => :mountain_lion end def initialize name=nil @@ -189,7 +189,7 @@ class SnowLeopardBottleSpecTestBall < Formula sha1 '482e737739d946b7c8cbaf127d9ee9c148b999f5' bottle do - sha1 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeef' => :snowleopard + sha1 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeef' => :snow_leopard end def initialize name=nil @@ -217,9 +217,9 @@ class AllCatsBottleSpecTestBall < Formula sha1 '482e737739d946b7c8cbaf127d9ee9c148b999f5' bottle do - sha1 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeef' => :snowleopard + sha1 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeef' => :snow_leopard sha1 'baadf00dbaadf00dbaadf00dbaadf00dbaadf00d' => :lion - sha1 '8badf00d8badf00d8badf00d8badf00d8badf00d' => :mountainlion + sha1 '8badf00d8badf00d8badf00d8badf00d8badf00d' => :mountain_lion end def initialize name=nil @@ -234,9 +234,9 @@ class RevisedBottleSpecTestBall < Formula bottle do version 1 - sha1 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeef' => :snowleopard + sha1 'deadbeefdeadbeefdeadbeefdeadbeefdeadbeef' => :snow_leopard sha1 'baadf00dbaadf00dbaadf00dbaadf00dbaadf00d' => :lion - sha1 '8badf00d8badf00d8badf00d8badf00d8badf00d' => :mountainlion + sha1 '8badf00d8badf00d8badf00d8badf00d8badf00d' => :mountain_lion end def initialize name=nil