From 55c82749ad8343541d15f91227478035363bff12 Mon Sep 17 00:00:00 2001 From: Sean Molenaar Date: Sun, 11 Dec 2022 14:47:48 +0100 Subject: [PATCH 1/2] SystemConfig: show WSL version if available on Linux --- Library/Homebrew/extend/os/linux/system_config.rb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/extend/os/linux/system_config.rb b/Library/Homebrew/extend/os/linux/system_config.rb index 0a52ec99e7..07fd6f82e2 100644 --- a/Library/Homebrew/extend/os/linux/system_config.rb +++ b/Library/Homebrew/extend/os/linux/system_config.rb @@ -40,10 +40,20 @@ module SystemConfig out end + def wsl_version(kernel) + return "no" unless /-microsoft/i.match?(kernel) + + return "2 (store)" if Version.new kernel[/Linux ([0-9.]*)-.*/, 1] > Version.new("5.15") + return "2" if /-microsoft/.match?(kernel) + return "1" if /-Microsoft/.match?(kernel) + end + def dump_verbose_config(out = $stdout) + kernel = Utils.safe_popen_read("uname", "-mors").chomp dump_generic_verbose_config(out) - out.puts "Kernel: #{`uname -mors`.chomp}" + out.puts "Kernel: #{kernel}" out.puts "OS: #{OS::Linux.os_version}" + out.puts "WSL: #{wsl_version(kernel)}" out.puts "Host glibc: #{host_glibc_version}" out.puts "/usr/bin/gcc: #{host_gcc_version}" out.puts "/usr/bin/ruby: #{host_ruby_version}" if RUBY_PATH != HOST_RUBY_PATH From 84911edbed408540cf74e3f706d61840f061e9ec Mon Sep 17 00:00:00 2001 From: Sean Molenaar Date: Mon, 2 Jan 2023 16:08:42 +0100 Subject: [PATCH 2/2] system config: don't print WSL info on non-WSL systems Co-authored-by: Mike McQuaid --- Library/Homebrew/extend/os/linux/system_config.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/extend/os/linux/system_config.rb b/Library/Homebrew/extend/os/linux/system_config.rb index 07fd6f82e2..bbc79a42fc 100644 --- a/Library/Homebrew/extend/os/linux/system_config.rb +++ b/Library/Homebrew/extend/os/linux/system_config.rb @@ -41,9 +41,9 @@ module SystemConfig end def wsl_version(kernel) - return "no" unless /-microsoft/i.match?(kernel) + return unless /-microsoft/i.match?(kernel) - return "2 (store)" if Version.new kernel[/Linux ([0-9.]*)-.*/, 1] > Version.new("5.15") + return "2 (Microsoft Store)" if Version.new(kernel[/Linux ([0-9.]*)-.*/, 1]) > Version.new("5.15") return "2" if /-microsoft/.match?(kernel) return "1" if /-Microsoft/.match?(kernel) end @@ -53,7 +53,9 @@ module SystemConfig dump_generic_verbose_config(out) out.puts "Kernel: #{kernel}" out.puts "OS: #{OS::Linux.os_version}" - out.puts "WSL: #{wsl_version(kernel)}" + if (wsl = wsl_version(kernel).presence) + out.puts "WSL: #{wsl}" + end out.puts "Host glibc: #{host_glibc_version}" out.puts "/usr/bin/gcc: #{host_gcc_version}" out.puts "/usr/bin/ruby: #{host_ruby_version}" if RUBY_PATH != HOST_RUBY_PATH