bottle: do not fail on missing bottle block

For :all bottle blocks in linuxbrew-core, we are going to remove the bottle
block completely before rebottling.
In linuxbrew-core, we use --keep-old to keep the macOS sha lines.

I am not sure why this exception was written initially, but it
now prevents bottling these formulae, because we have no bottle block
and use --keep-old.

I think it's safe to just skip this check, when there is no bottle block
the old_checksum can just directly return nil.
This commit is contained in:
Michka Popoff 2021-04-29 07:52:53 +02:00
parent 813f75159b
commit 697edce654
No known key found for this signature in database
GPG Key ID: 033D03F151030611
2 changed files with 1 additions and 23 deletions

View File

@ -717,10 +717,7 @@ module Homebrew
def old_checksums(formula, formula_ast, bottle_hash, args:) def old_checksums(formula, formula_ast, bottle_hash, args:)
bottle_node = formula_ast.bottle_block bottle_node = formula_ast.bottle_block
if bottle_node.nil? return if bottle_node.nil?
odie "`--keep-old` was passed but there was no existing bottle block!" if args.keep_old?
return
end
return [] unless args.keep_old? return [] unless args.keep_old?
old_keys = Utils::AST.body_children(bottle_node.body).map(&:method_name) old_keys = Utils::AST.body_children(bottle_node.body).map(&:method_name)

View File

@ -273,25 +273,6 @@ describe "brew bottle" do
EOS EOS
end end
it "fails to add the bottle block to a formula that has no bottle block when using --keep-old" do
core_tap.path.cd do
system "git", "init"
setup_test_formula("testball")
system "git", "add", "--all"
system "git", "commit", "-m", "testball 0.1"
end
expect {
brew "bottle",
"--merge",
"--write",
"--keep-old",
"#{TEST_TMPDIR}/testball-1.0.arm64_big_sur.bottle.json",
"#{TEST_TMPDIR}/testball-1.0.big_sur.bottle.json",
"#{TEST_TMPDIR}/testball-1.0.catalina.bottle.json"
}.to output("Error: `--keep-old` was passed but there was no existing bottle block!\n").to_stderr
end
it "updates the bottle block in a formula that already has a bottle block (old format) when using --keep-old" do it "updates the bottle block in a formula that already has a bottle block (old format) when using --keep-old" do
core_tap.path.cd do core_tap.path.cd do
system "git", "init" system "git", "init"