From 57109a175a5ca268025e6d39d39867ea05c910bc Mon Sep 17 00:00:00 2001 From: Jonathan Chang Date: Fri, 13 Mar 2020 11:39:27 +1100 Subject: [PATCH] diagnostic: add doctor check for CPU arch on Linux Co-Authored-By: Mike McQuaid --- Library/Homebrew/extend/os/linux/diagnostic.rb | 12 ++++++++++++ Library/Homebrew/test/os/linux/diagnostic_spec.rb | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/Library/Homebrew/extend/os/linux/diagnostic.rb b/Library/Homebrew/extend/os/linux/diagnostic.rb index c1698ecedd..61110bbec3 100644 --- a/Library/Homebrew/extend/os/linux/diagnostic.rb +++ b/Library/Homebrew/extend/os/linux/diagnostic.rb @@ -2,6 +2,7 @@ require "tempfile" require "utils/shell" +require "hardware" require "os/linux/diagnostic" require "os/linux/glibc" require "os/linux/kernel" @@ -13,6 +14,7 @@ module Homebrew %w[ check_glibc_minimum_version check_kernel_minimum_version + check_supported_architecture ].freeze end @@ -71,6 +73,16 @@ module Homebrew EOS end + def check_supported_architecture + return if Hardware::CPU.arch == :x86_64 + + <<~EOS + Your CPU architecture (#{Hardware::CPU.arch}) is not supported. We only support + x86_64 CPU architectures. You will be unable to use binary packages (bottles). + #{please_create_pull_requests} + EOS + end + def check_glibc_minimum_version return unless OS::Linux::Glibc.below_minimum_version? diff --git a/Library/Homebrew/test/os/linux/diagnostic_spec.rb b/Library/Homebrew/test/os/linux/diagnostic_spec.rb index 4c1b2cf5ac..185eab89a5 100644 --- a/Library/Homebrew/test/os/linux/diagnostic_spec.rb +++ b/Library/Homebrew/test/os/linux/diagnostic_spec.rb @@ -3,6 +3,13 @@ require "diagnostic" describe Homebrew::Diagnostic::Checks do + specify "#check_supported_architecture" do + allow(Hardware::CPU).to receive(:type).and_return(:arm64) + + expect(subject.check_supported_architecture) + .to match(/Your CPU architecture .+ is not supported/) + end + specify "#check_glibc_minimum_version" do allow(OS::Linux::Glibc).to receive(:below_minimum_version?).and_return(true)