Fix Missing Download Strategy And Dependency

This commit is contained in:
Michael Wagner 2023-05-17 16:30:00 -05:00
parent f7b3225574
commit 78c07fd0e1
No known key found for this signature in database
GPG Key ID: 63FBE98417C278D2
3 changed files with 9 additions and 8 deletions

View File

@ -179,6 +179,8 @@ class DependencyCollector
if strategy <= HomebrewCurlDownloadStrategy if strategy <= HomebrewCurlDownloadStrategy
@deps << curl_dep_if_needed(tags) @deps << curl_dep_if_needed(tags)
parse_url_spec(spec.url, tags) parse_url_spec(spec.url, tags)
elsif strategy <= NoUnzipCurlDownloadStrategy
# ensure NoUnzip never adds any dependencies
elsif strategy <= CurlDownloadStrategy elsif strategy <= CurlDownloadStrategy
parse_url_spec(spec.url, tags) parse_url_spec(spec.url, tags)
elsif strategy <= GitDownloadStrategy elsif strategy <= GitDownloadStrategy
@ -196,8 +198,7 @@ class DependencyCollector
elsif strategy < AbstractDownloadStrategy elsif strategy < AbstractDownloadStrategy
# allow unknown strategies to pass through # allow unknown strategies to pass through
else else
raise TypeError, raise TypeError, "#{strategy.inspect} is not an AbstractDownloadStrategy subclass"
"#{strategy.inspect} is not an AbstractDownloadStrategy subclass"
end end
end end
@ -209,7 +210,7 @@ class DependencyCollector
when ".bz2" then bzip2_dep_if_needed(tags) when ".bz2" then bzip2_dep_if_needed(tags)
when ".lha", ".lzh" then Dependency.new("lha", tags) when ".lha", ".lzh" then Dependency.new("lha", tags)
when ".lz" then Dependency.new("lzip", tags) when ".lz" then Dependency.new("lzip", tags)
when ".rar" then Dependency.new("unrar", tags) when ".rar" then Dependency.new("libarchive", tags)
when ".7z" then Dependency.new("p7zip", tags) when ".7z" then Dependency.new("p7zip", tags)
end end
end end

View File

@ -88,7 +88,7 @@ describe DependencyCollector do
it "creates a resource dependency from a '.rar' URL" do it "creates a resource dependency from a '.rar' URL" do
resource = Resource.new resource = Resource.new
resource.url("https://brew.sh/foo.rar") resource.url("https://brew.sh/foo.rar")
expect(collector.add(resource)).to eq(Dependency.new("unrar", [:build, :test])) expect(collector.add(resource)).to eq(Dependency.new("libarchive", [:build, :test]))
end end
it "raises a TypeError for unknown classes" do it "raises a TypeError for unknown classes" do

View File

@ -16,16 +16,16 @@ module UnpackStrategy
end end
def dependencies def dependencies
@dependencies ||= [Formula["unrar"]] @dependencies ||= [Formula["libarchive"]]
end end
private private
sig { override.params(unpack_dir: Pathname, basename: Pathname, verbose: T::Boolean).returns(T.untyped) } sig { override.params(unpack_dir: Pathname, basename: Pathname, verbose: T::Boolean).returns(T.untyped) }
def extract_to_dir(unpack_dir, basename:, verbose:) def extract_to_dir(unpack_dir, basename:, verbose:)
system_command! "unrar", system_command! "bsdtar",
args: ["x", "-inul", path, unpack_dir], args: ["x", "-f", path, "-C", unpack_dir],
env: { "PATH" => PATH.new(Formula["unrar"].opt_bin, ENV.fetch("PATH")) }, env: { "PATH" => PATH.new(Formula["libarchive"].opt_bin, ENV.fetch("PATH")) },
verbose: verbose verbose: verbose
end end
end end