From 4a1a8b86ac094621a50eff1526b53f62758ad1be Mon Sep 17 00:00:00 2001 From: ilovezfs Date: Wed, 24 Jan 2018 03:51:23 -0800 Subject: [PATCH 1/2] bump-formula-pr: use "resource" not "rsrc" --- Library/Homebrew/dev-cmd/bump-formula-pr.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb index 59dfc121dc..0094ae4f83 100644 --- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb @@ -184,23 +184,23 @@ module Homebrew elsif !new_url odie "#{formula}: no --url= argument specified!" else - rsrc_url = if requested_spec != :devel && new_url =~ /.*ftpmirror.gnu.*/ + resource_url = if requested_spec != :devel && new_url =~ /.*ftpmirror.gnu.*/ new_mirror = new_url.sub "ftpmirror.gnu.org", "ftp.gnu.org/gnu" new_mirror else new_url end - rsrc = Resource.new { @url = rsrc_url } - rsrc.download_strategy = CurlDownloadStrategy - rsrc.owner = Resource.new(formula.name) - rsrc.version = forced_version if forced_version - odie "No --version= argument specified!" unless rsrc.version - rsrc_path = rsrc.fetch + resource = Resource.new { @url = resource_url } + resource.download_strategy = CurlDownloadStrategy + resource.owner = Resource.new(formula.name) + resource.version = forced_version if forced_version + odie "No --version= argument specified!" unless resource.version + resource_path = resource.fetch gnu_tar_gtar_path = HOMEBREW_PREFIX/"opt/gnu-tar/bin/gtar" gnu_tar_gtar = gnu_tar_gtar_path if gnu_tar_gtar_path.executable? tar = which("gtar") || gnu_tar_gtar || which("tar") - if Utils.popen_read(tar, "-tf", rsrc_path) =~ %r{/.*\.} - new_hash = rsrc_path.sha256 + if Utils.popen_read(tar, "-tf", resource_path) =~ %r{/.*\.} + new_hash = resource_path.sha256 elsif new_url.include? ".tar" odie "#{formula}: no --url=/--#{hash_type}= arguments specified!" end From 5a3555eeee38fed0cadf4df94dc601a77b1f08ad Mon Sep 17 00:00:00 2001 From: ilovezfs Date: Wed, 24 Jan 2018 04:22:11 -0800 Subject: [PATCH 2/2] bump-formula-pr: only validate tar files. --- Library/Homebrew/dev-cmd/bump-formula-pr.rb | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb index 0094ae4f83..7069a48167 100644 --- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb @@ -196,13 +196,18 @@ module Homebrew resource.version = forced_version if forced_version odie "No --version= argument specified!" unless resource.version resource_path = resource.fetch - gnu_tar_gtar_path = HOMEBREW_PREFIX/"opt/gnu-tar/bin/gtar" - gnu_tar_gtar = gnu_tar_gtar_path if gnu_tar_gtar_path.executable? - tar = which("gtar") || gnu_tar_gtar || which("tar") - if Utils.popen_read(tar, "-tf", resource_path) =~ %r{/.*\.} + tar_file_extensions = %w[.tar .tb2 .tbz .tbz2 .tgz .tlz .txz .tZ] + if tar_file_extensions.any? { |extension| new_url.include? extension } + gnu_tar_gtar_path = HOMEBREW_PREFIX/"opt/gnu-tar/bin/gtar" + gnu_tar_gtar = gnu_tar_gtar_path if gnu_tar_gtar_path.executable? + tar = which("gtar") || gnu_tar_gtar || which("tar") + if Utils.popen_read(tar, "-tf", resource_path) =~ %r{/.*\.} + new_hash = resource_path.sha256 + else + odie "#{resource_path} is not a valid tar file!" + end + else new_hash = resource_path.sha256 - elsif new_url.include? ".tar" - odie "#{formula}: no --url=/--#{hash_type}= arguments specified!" end end