Skip to content

Commit 3fbfff2

Browse files
committed
dev-cmd/bottle: fix relocatable bottling for GCC and Binutils on Linux
Since dc71b7c, bottles for GCC and Binutils are no longer relocatable due to a misplacement of the relevant code in `extend/os`. Fix this by moving the code to the correct location.
1 parent b302729 commit 3fbfff2

File tree

3 files changed

+33
-20
lines changed

3 files changed

+33
-20
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# typed: strict
22
# frozen_string_literal: true
33

4+
require "extend/os/linux/dev-cmd/bottle" if OS.linux?
45
require "extend/os/mac/dev-cmd/bottle" if OS.mac?
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# typed: strict
2+
# frozen_string_literal: true
3+
4+
module OS
5+
module Linux
6+
module DevCmd
7+
module Bottle
8+
sig { params(formula: Formula).returns(T::Array[Regexp]) }
9+
def formula_ignores(formula)
10+
ignores = super
11+
12+
cellar_regex = Regexp.escape(HOMEBREW_CELLAR)
13+
prefix_regex = Regexp.escape(HOMEBREW_PREFIX)
14+
15+
ignores << case formula.name
16+
# On Linux, GCC installation can be moved so long as the whole directory tree is moved together:
17+
# https://gcc-help.gcc.gnu.narkive.com/GnwuCA7l/moving-gcc-from-the-installation-path-is-it-allowed.
18+
when Version.formula_optionally_versioned_regex(:gcc)
19+
Regexp.union(%r{#{cellar_regex}/gcc}, %r{#{prefix_regex}/opt/gcc})
20+
# binutils is relocatable for the same reason: https://github.com/Homebrew/brew/pull/11899#issuecomment-906804451.
21+
when Version.formula_optionally_versioned_regex(:binutils)
22+
%r{#{cellar_regex}/binutils}
23+
end
24+
25+
ignores.compact
26+
end
27+
end
28+
end
29+
end
30+
end
31+
32+
Homebrew::DevCmd::Bottle.prepend(OS::Linux::DevCmd::Bottle)

Library/Homebrew/extend/os/mac/dev-cmd/bottle.rb

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,6 @@ def tar_args
1818
def gnu_tar(gnu_tar_formula)
1919
"#{gnu_tar_formula.opt_bin}/gtar"
2020
end
21-
22-
sig { params(formula: Formula).returns(T::Array[Regexp]) }
23-
def formula_ignores(formula)
24-
ignores = super
25-
26-
cellar_regex = Regexp.escape(HOMEBREW_CELLAR)
27-
prefix_regex = Regexp.escape(HOMEBREW_PREFIX)
28-
29-
ignores << case formula.name
30-
# On Linux, GCC installation can be moved so long as the whole directory tree is moved together:
31-
# https://gcc-help.gcc.gnu.narkive.com/GnwuCA7l/moving-gcc-from-the-installation-path-is-it-allowed.
32-
when Version.formula_optionally_versioned_regex(:gcc)
33-
Regexp.union(%r{#{cellar_regex}/gcc}, %r{#{prefix_regex}/opt/gcc}) if OS.linux?
34-
# binutils is relocatable for the same reason: https://github.com/Homebrew/brew/pull/11899#issuecomment-906804451.
35-
when Version.formula_optionally_versioned_regex(:binutils)
36-
%r{#{cellar_regex}/binutils} if OS.linux?
37-
end
38-
39-
ignores.compact
40-
end
4121
end
4222
end
4323
end

0 commit comments

Comments
 (0)