Skip to content

Commit

Permalink
Merge pull request #1085 from yast/detect_wsl2_backport
Browse files Browse the repository at this point in the history
Backport WSL2 detection to SLE-15-SP2
  • Loading branch information
teclator committed Jul 27, 2020
2 parents 75af2db + 79341e1 commit d35a4b4
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
6 changes: 5 additions & 1 deletion library/general/src/modules/Arch.rb
Expand Up @@ -498,7 +498,11 @@ def x11_setup_needed
#
# @return [Boolean] true if runs on WSL; false otherwise
def is_wsl
SCR.Read(path(".target.string"), "/proc/sys/kernel/osrelease").to_s.include?("-Microsoft")
# As of 2020-07-24 /proc/sys/kernel/osrelease contains
# "4.4.0-19041-Microsoft" on wsl1 and
# "4.19.104-microsoft-standard" on wsl2.
# Match on lowercase "-microsoft"
SCR.Read(path(".target.string"), "/proc/sys/kernel/osrelease").to_s.downcase.include?("-microsoft")
end

publish function: :architecture, type: "string ()"
Expand Down
12 changes: 10 additions & 2 deletions library/general/test/arch_test.rb
Expand Up @@ -52,8 +52,16 @@
.and_return(osrelease)
end

context "when it runs on a Microsoft kernel" do
let(:osrelease) { "5.3.11-Microsoft" }
context "when it runs on a Microsoft kernel under WSL1" do
let(:osrelease) { "4.4.0-19041-Microsoft" }

it "returns true" do
expect(Yast::Arch.is_wsl).to eq(true)
end
end

context "when it runs on a Microsoft kernel under WSL2" do
let(:osrelease) { "4.19.104-microsoft-standard" }

it "returns true" do
expect(Yast::Arch.is_wsl).to eq(true)
Expand Down
7 changes: 7 additions & 0 deletions package/yast2.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Fri Jul 24 08:06:27 UTC 2020 - Jeff Kowalczyk <jkowalczyk@suse.com>

- update is_wsl function to match wsl1 and wsl2 osrelease spellings
(boo#1174183)
- 4.2.87

-------------------------------------------------------------------
Tue Jul 7 09:48:04 CEST 2020 - schubi@suse.de

Expand Down
2 changes: 1 addition & 1 deletion package/yast2.spec
Expand Up @@ -17,7 +17,7 @@


Name: yast2
Version: 4.2.86
Version: 4.2.87
Release: 0
Summary: YaST2 Main Package
License: GPL-2.0-only
Expand Down

0 comments on commit d35a4b4

Please sign in to comment.