From c32283e5be444565bda707f8cb93bad1d15296c2 Mon Sep 17 00:00:00 2001 From: Jonathan Chang Date: Tue, 1 Jan 2019 15:46:57 -0800 Subject: [PATCH 1/3] diagnostic: use universal pull request message --- Library/Homebrew/diagnostic.rb | 10 ++++++++++ Library/Homebrew/extend/os/mac/diagnostic.rb | 5 +---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/diagnostic.rb b/Library/Homebrew/diagnostic.rb index 55df9aca8c..a6033feb4d 100644 --- a/Library/Homebrew/diagnostic.rb +++ b/Library/Homebrew/diagnostic.rb @@ -95,6 +95,16 @@ module Homebrew ]).freeze end + def please_create_pull_requests(what = "unsupported configuration") + <<~EOS + You may encounter build failures and other breakages. + Please create pull requests instead of asking for help on + Homebrew's GitHub, Discourse, Twitter or IRC. You are + responsible for resolving any issues you experience, as + you are running this #{what}. + EOS + end + def check_for_installed_developer_tools return if DevelopmentTools.installed? diff --git a/Library/Homebrew/extend/os/mac/diagnostic.rb b/Library/Homebrew/extend/os/mac/diagnostic.rb index 0af10f9698..321e0cda18 100644 --- a/Library/Homebrew/extend/os/mac/diagnostic.rb +++ b/Library/Homebrew/extend/os/mac/diagnostic.rb @@ -60,10 +60,7 @@ module Homebrew <<~EOS You are using macOS #{MacOS.version}. #{who} do not provide support for this #{what}. - You will encounter build failures and other breakages. - Please create pull requests instead of asking for help on Homebrew's - GitHub, Discourse, Twitter or IRC. As you are running this #{what}, - you are responsible for resolving any issues you experience. + #{please_create_pull_requests(what)} EOS end From 03597404af1d0082ce01d703d69d710209d5155d Mon Sep 17 00:00:00 2001 From: Jonathan Chang Date: Tue, 1 Jan 2019 15:49:12 -0800 Subject: [PATCH 2/3] os: add version info for kernel and glibc [Linux] --- Library/Homebrew/os/linux/glibc.rb | 8 ++++++++ Library/Homebrew/os/linux/kernel.rb | 24 ++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 Library/Homebrew/os/linux/kernel.rb diff --git a/Library/Homebrew/os/linux/glibc.rb b/Library/Homebrew/os/linux/glibc.rb index 7be42f2043..0d7397c9c5 100644 --- a/Library/Homebrew/os/linux/glibc.rb +++ b/Library/Homebrew/os/linux/glibc.rb @@ -11,6 +11,14 @@ module OS @system_version = Version.new version end + + def minimum_version + Version.new "2.12" + end + + def below_minimum_version? + system_version < minimum_version + end end end end diff --git a/Library/Homebrew/os/linux/kernel.rb b/Library/Homebrew/os/linux/kernel.rb new file mode 100644 index 0000000000..4534409e6d --- /dev/null +++ b/Library/Homebrew/os/linux/kernel.rb @@ -0,0 +1,24 @@ +module OS + module Linux + module Kernel + module_function + + def version + return @version if @version + + version = Utils.popen_read("uname", "-r").chomp + return Version::NULL unless version + + @version = Version.new version + end + + def minimum_version + Version.new "2.6.32" + end + + def below_minimum_version? + version < minimum_version + end + end + end +end From 76d7b586ceb83459ad07f5f68bae00b6757c5263 Mon Sep 17 00:00:00 2001 From: Jonathan Chang Date: Tue, 1 Jan 2019 15:51:32 -0800 Subject: [PATCH 3/3] diagnostic: check kernel, glibc versions [Linux] --- .../Homebrew/extend/os/linux/diagnostic.rb | 29 +++++++++++++++++++ .../Homebrew/test/os/linux/diagnostic_spec.rb | 17 +++++++++++ 2 files changed, 46 insertions(+) create mode 100644 Library/Homebrew/test/os/linux/diagnostic_spec.rb diff --git a/Library/Homebrew/extend/os/linux/diagnostic.rb b/Library/Homebrew/extend/os/linux/diagnostic.rb index 63db648831..1a89f9d956 100644 --- a/Library/Homebrew/extend/os/linux/diagnostic.rb +++ b/Library/Homebrew/extend/os/linux/diagnostic.rb @@ -1,6 +1,8 @@ require "tempfile" require "utils/shell" require "os/linux/diagnostic" +require "os/linux/glibc" +require "os/linux/kernel" module Homebrew module Diagnostic @@ -59,6 +61,33 @@ module Homebrew echo 'umask 002' >> #{shell_profile} EOS end + + def check_glibc_minimum_version + return unless OS::Linux::Glibc.below_minimum_version? + + <<~EOS + Your system glibc #{OS::Linux::Glibc.system_version} is too old. + We only support glibc #{OS::Linux::Glibc.minimum_version} or later. + #{please_create_pull_requests} + We recommend updating to a newer version via your distribution's + package manager, upgrading your distribution to the latest version, + or changing distributions. + EOS + end + + def check_kernel_minimum_version + return unless OS::Linux::Kernel.below_minimum_version? + + <<~EOS + Your Linux kernel #{OS::Linux::Kernel.version} is too old. + We only support kernel #{OS::Linux::Kernel.minimum_version} or later. + You will be unable to use binary packages (bottles). + #{please_create_pull_requests} + We recommend updating to a newer version via your distribution's + package manager, upgrading your distribution to the latest version, + or changing distributions. + EOS + end end end end diff --git a/Library/Homebrew/test/os/linux/diagnostic_spec.rb b/Library/Homebrew/test/os/linux/diagnostic_spec.rb new file mode 100644 index 0000000000..d5d85cc0fd --- /dev/null +++ b/Library/Homebrew/test/os/linux/diagnostic_spec.rb @@ -0,0 +1,17 @@ +require "diagnostic" + +describe Homebrew::Diagnostic::Checks do + specify "#check_glibc_minimum_version" do + allow(OS::Linux::Glibc).to receive(:below_minimum_version?).and_return(true) + + expect(subject.check_glibc_minimum_version) + .to match(/Your system glibc .+ is too old/) + end + + specify "#check_kernel_minimum_version" do + allow(OS::Linux::Kernel).to receive(:below_minimum_version?).and_return(true) + + expect(subject.check_kernel_minimum_version) + .to match(/Your Linux kernel .+ is too old/) + end +end