diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index 95deedd830..8f936dfc55 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -4,7 +4,7 @@ ##### case "${MACHTYPE}" in - arm64-*) + arm64-* | aarch64-*) HOMEBREW_PROCESSOR="arm64" ;; x86_64-*) diff --git a/Library/Homebrew/github_packages.rb b/Library/Homebrew/github_packages.rb index 43f2556292..16726347de 100644 --- a/Library/Homebrew/github_packages.rb +++ b/Library/Homebrew/github_packages.rb @@ -350,7 +350,7 @@ class GitHubPackages tar_gz_sha256 = write_tar_gz(local_file, blobs) tab = tag_hash["tab"] - architecture = TAB_ARCH_TO_PLATFORM_ARCHITECTURE[tab["arch"].presence || bottle_tag.arch.to_s] + architecture = TAB_ARCH_TO_PLATFORM_ARCHITECTURE[tab["arch"].presence || bottle_tag.standardized_arch.to_s] raise TypeError, "unknown tab['arch']: #{tab["arch"]}" if architecture.blank? os = if tab["built_on"].present? && tab["built_on"]["os"].present? diff --git a/Library/Homebrew/software_spec.rb b/Library/Homebrew/software_spec.rb index cb7969a7da..f8a4a981e9 100644 --- a/Library/Homebrew/software_spec.rb +++ b/Library/Homebrew/software_spec.rb @@ -315,7 +315,7 @@ class Bottle raise ArgumentError, "Invalid bottle version" unless Utils.safe_filename?(version.to_s) @version = version - @tag = tag.to_s + @tag = tag.to_unstandardized_sym.to_s @rebuild = rebuild end diff --git a/Library/Homebrew/test/formula_spec.rb b/Library/Homebrew/test/formula_spec.rb index 7dfa9b70fc..da58f08b6b 100644 --- a/Library/Homebrew/test/formula_spec.rb +++ b/Library/Homebrew/test/formula_spec.rb @@ -1024,6 +1024,11 @@ RSpec.describe Formula do "intel-formula", "linux-formula" ] + }, + "arm64_linux": { + "dependencies": [ + "linux-formula" + ] } } JSON diff --git a/Library/Homebrew/test/support/fixtures/bottles/testball_bottle-0.1.aarch64_linux.bottle.tar.gz b/Library/Homebrew/test/support/fixtures/bottles/testball_bottle-0.1.arm64_linux.bottle.tar.gz similarity index 100% rename from Library/Homebrew/test/support/fixtures/bottles/testball_bottle-0.1.aarch64_linux.bottle.tar.gz rename to Library/Homebrew/test/support/fixtures/bottles/testball_bottle-0.1.arm64_linux.bottle.tar.gz diff --git a/Library/Homebrew/test/utils/bottles/tag_spec.rb b/Library/Homebrew/test/utils/bottles/tag_spec.rb index cddf686c11..919e15deaf 100644 --- a/Library/Homebrew/test/utils/bottles/tag_spec.rb +++ b/Library/Homebrew/test/utils/bottles/tag_spec.rb @@ -79,11 +79,11 @@ RSpec.describe Utils::Bottles::Tag do expect(tag.valid_combination?).to be true end - it "returns false for ARM on Linux" do + it "returns true for ARM on Linux" do tag = described_class.new(system: :linux, arch: :arm64) - expect(tag.valid_combination?).to be false + expect(tag.valid_combination?).to be true tag = described_class.new(system: :linux, arch: :arm) - expect(tag.valid_combination?).to be false + expect(tag.valid_combination?).to be true end end end diff --git a/Library/Homebrew/utils/bottles.rb b/Library/Homebrew/utils/bottles.rb index 73c6b014be..c0578b1b9b 100644 --- a/Library/Homebrew/utils/bottles.rb +++ b/Library/Homebrew/utils/bottles.rb @@ -186,20 +186,14 @@ module Utils sig { returns(Symbol) } def standardized_arch return :x86_64 if [:x86_64, :intel].include? arch - return :arm64 if [:arm64, :arm].include? arch + return :arm64 if [:arm64, :arm, :aarch64].include? arch arch end sig { returns(Symbol) } def to_sym - if system == :all && arch == :all - :all - elsif macos? && [:x86_64, :intel].include?(arch) - system - else - :"#{standardized_arch}_#{system}" - end + arch_to_symbol(standardized_arch) end sig { returns(String) } @@ -207,6 +201,14 @@ module Utils to_sym.to_s end + def to_unstandardized_sym + # Never allow these generic names + return to_sym if [:intel, :arm].include? arch + + # Backwards compatibility with older bottle names + arch_to_symbol(arch) + end + sig { returns(MacOSVersion) } def to_macos_version @to_macos_version ||= MacOSVersion.from_symbol(system) @@ -224,8 +226,8 @@ module Utils sig { returns(T::Boolean) } def valid_combination? - return true unless [:arm64, :arm].include? arch - return false if linux? + return true unless [:arm64, :arm, :aarch64].include? arch + return true unless macos? # Big Sur is the first version of macOS that runs on ARM to_macos_version >= :big_sur @@ -235,7 +237,7 @@ module Utils def default_prefix if linux? HOMEBREW_LINUX_DEFAULT_PREFIX - elsif arch == :arm64 + elsif standardized_arch == :arm64 HOMEBREW_MACOS_ARM_DEFAULT_PREFIX else HOMEBREW_DEFAULT_PREFIX @@ -246,12 +248,25 @@ module Utils def default_cellar if linux? Homebrew::DEFAULT_LINUX_CELLAR - elsif arch == :arm64 + elsif standardized_arch == :arm64 Homebrew::DEFAULT_MACOS_ARM_CELLAR else Homebrew::DEFAULT_MACOS_CELLAR end end + + private + + sig { params(arch: Symbol).returns(Symbol) } + def arch_to_symbol(arch) + if system == :all && arch == :all + :all + elsif macos? && standardized_arch == :x86_64 + system + else + :"#{arch}_#{system}" + end + end end # The specification for a specific tag diff --git a/docs/Homebrew-on-Linux.md b/docs/Homebrew-on-Linux.md index fdecb2d27d..590d658909 100644 --- a/docs/Homebrew-on-Linux.md +++ b/docs/Homebrew-on-Linux.md @@ -77,7 +77,7 @@ To install build tools, paste at a terminal prompt: ### ARM (unsupported) -Homebrew can run on 32-bit ARM (Raspberry Pi and others) and 64-bit ARM (AArch64), but as they lack binary packages (bottles) they are unsupported. Pull requests are welcome to improve the experience on ARM platforms. +Homebrew can run on 32-bit ARM (e.g. Raspberry Pi and others) and 64-bit ARM (ARM64, also known as AArch64), but as they lack bottles (binary packages) they are unsupported. Pull requests are welcome to improve the experience on ARM platforms. You may need to install your own Ruby using your system package manager, a PPA, or `rbenv/ruby-build` as we no longer distribute a Homebrew Portable Ruby for ARM.