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
@deps << curl_dep_if_needed(tags)
parse_url_spec(spec.url, tags)
elsif strategy <= NoUnzipCurlDownloadStrategy
# ensure NoUnzip never adds any dependencies
elsif strategy <= CurlDownloadStrategy
parse_url_spec(spec.url, tags)
elsif strategy <= GitDownloadStrategy
@ -196,8 +198,7 @@ class DependencyCollector
elsif strategy < AbstractDownloadStrategy
# allow unknown strategies to pass through
else
raise TypeError,
"#{strategy.inspect} is not an AbstractDownloadStrategy subclass"
raise TypeError, "#{strategy.inspect} is not an AbstractDownloadStrategy subclass"
end
end
@ -209,7 +210,7 @@ class DependencyCollector
when ".bz2" then bzip2_dep_if_needed(tags)
when ".lha", ".lzh" then Dependency.new("lha", 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)
end
end

View File

@ -88,7 +88,7 @@ describe DependencyCollector do
it "creates a resource dependency from a '.rar' URL" do
resource = Resource.new
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
it "raises a TypeError for unknown classes" do

View File

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