From 17464d28071074f27d57b2d7eac5d5f8cd8ca781 Mon Sep 17 00:00:00 2001 From: Bo Anderson Date: Fri, 31 Jan 2025 22:54:41 +0100 Subject: [PATCH] Rename aarch64_linux tag to arm64_linux --- Library/Homebrew/brew.sh | 2 +- Library/Homebrew/github_packages.rb | 2 +- Library/Homebrew/software_spec.rb | 2 +- Library/Homebrew/test/formula_spec.rb | 5 +++ ...ball_bottle-0.1.arm64_linux.bottle.tar.gz} | 0 .../Homebrew/test/utils/bottles/tag_spec.rb | 6 +-- Library/Homebrew/utils/bottles.rb | 39 +++++++++++++------ docs/Homebrew-on-Linux.md | 2 +- 8 files changed, 39 insertions(+), 19 deletions(-) rename Library/Homebrew/test/support/fixtures/bottles/{testball_bottle-0.1.aarch64_linux.bottle.tar.gz => testball_bottle-0.1.arm64_linux.bottle.tar.gz} (100%) diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index 95deedd830d77..8f936dfc552ad 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 43f255629251f..16726347de0d8 100644 --- a/Library/Homebrew/github_packages.rb +++ b/Library/Homebrew/github_packages.rb @@ -350,7 +350,7 @@ def upload_bottle(user, token, skopeo, formula_full_name, bottle_hash, keep_old: 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 cb7969a7dab90..f8a4a981e9031 100644 --- a/Library/Homebrew/software_spec.rb +++ b/Library/Homebrew/software_spec.rb @@ -315,7 +315,7 @@ def initialize(name, version, tag, rebuild) 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 7dfa9b70fced3..da58f08b6b343 100644 --- a/Library/Homebrew/test/formula_spec.rb +++ b/Library/Homebrew/test/formula_spec.rb @@ -1024,6 +1024,11 @@ class FooVariations < Formula "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 cddf686c11d4b..919e15deafbda 100644 --- a/Library/Homebrew/test/utils/bottles/tag_spec.rb +++ b/Library/Homebrew/test/utils/bottles/tag_spec.rb @@ -79,11 +79,11 @@ 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 73c6b014bee52..c0578b1b9bf46 100644 --- a/Library/Homebrew/utils/bottles.rb +++ b/Library/Homebrew/utils/bottles.rb @@ -186,20 +186,14 @@ def hash 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 @@ def to_s 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 @@ def macos? 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 @@ def valid_combination? 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 @@ def default_prefix 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 fdecb2d27d9a8..cfb2d4d8ca955 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 (Raspberry Pi and others) and 64-bit ARM (AArch64, also known as ARM64), but as they lack binary packages (bottles) 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.