Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make build work under WSL (Windows services for Linux) #2649

Closed
wants to merge 1 commit into from
Closed

Make build work under WSL (Windows services for Linux) #2649

wants to merge 1 commit into from

Conversation

tobiaswaldvogel
Copy link

In order to avoid using a VM under Windows for building LibreElec, I figured out that actually
only a few changes are required to make it work with WSL (Windows services for Linux).
Tested with Debian running on WSL

  • fakeroot: Use tcp instead of ipc as it is still not implemented in WSL
  • openssl: Clear execstack bit on libcrypto after host build when running on WSL
  • checkdeps: Add execstack to dependencies if WSL is detected (Checking for "Microsoft" in /proc/version)

- fakeroot: Use tcp instead of ipc as it is still not implemented in WSL
- openssl: Clear execstack bit on libcrypto after host build
- checkdeps: Add execstack to dependencies if WSL is detected (Checking for "Microsoft" in /proc/version)
@MilhouseVH
Copy link
Contributor

MilhouseVH commented Apr 14, 2018

How about adding an is_wsl() function in config/functions, just in case the check ever needs to change and we can then change it in one place?

is_wsl() {
  grep -q  Microsoft /proc/version 2>/dev/null
}

then use:

+  if is_wsl; then

However as it's only used in two places it's kind of not a big deal, but I would suggest simplifying the check by replacing:

+  WSL=$(grep Microsoft /proc/version)
+  if [ ! -z "$WSL" ]; then

with:

+  if grep -q  Microsoft /proc/version 2>/dev/null; then

Of course this assumes that grep in WSL functions the way it does in every other GNU/Linux...

@MilhouseVH
Copy link
Contributor

Also, what does uname -a, uname -s, and uname -o give under WSL?

@MilhouseVH
Copy link
Contributor

It looks like uname under WSL is pretty useless:

microsoft/WSL#1090
https://stackoverflow.com/questions/38859145/detect-ubuntu-on-windows-vs-native-ubuntu-from-bash-script

in which case grepping /proc/version is probably the best we can do for now. Placing the check in a simple is_wsl() function would make it easier to update in future should Microsoft start returning sensible results in uname, or there's a better solution.

@tobiaswaldvogel
Copy link
Author

Thanks for your thoughts.
I agree that it would be better to introduce a function is_wsl() as it might be necessary to change the detection method in future or that more fixes might be required. I also had thought in something like this but didn't know which would be a good place to put it.

On my computer uname -a gives
"Linux DESKTOP-3IVI4ER 4.4.0-43-Microsoft #1-Microsoft Wed Dec 31 14:42:53 PST 2014 x86_64 GNU/Linux"
but according to the link you provided it doesn't seem reliable, so I will stick with grepping /proc/version then.

I will rework it next week and present a new pull request.

@CvH
Copy link
Member

CvH commented Apr 14, 2018

just as info

cvh@DESKTOP$ uname -r
4.4.0-43-Microsoft
cvh@DESKTOP$ uname -a
Linux DESKTOP-E3FAQC7 4.4.0-43-Microsoft #1-Microsoft Wed Dec 31 14:42:53 PST 2014 x86_64 x86_64 x86_64 GNU/Linux
cvh@DESKTOP$ uname -s
Linux
cvh@DESKTOP$ uname -o
GNU/Linux

@MilhouseVH
Copy link
Contributor

Thanks @CvH. In which case this should suffice as the function:

is_wsl() {
  [[ $(uname -r) =~ Microsoft ]] && return 0 || return 1
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants