Giter VIP home page Giter VIP logo

gentoo-wsl's Introduction

You can use Gentoo on Windows Kernel

Installation

  • install/enable WSL on Windows (Using Programs and Features)
  • download stage3 https://www.gentoo.org/downloads/
  • use https://github.com/RoliSoft/WSL-Distribution-Switcher and target stage3 tarball (for example run following from console C:\Python3\Python install.py stage3-amd64-20170413.tar.bz2)
  • set root as default login by running lxrun /setdefaultuser root from windows powershell
  • after login export TERM=xterm and add it to .bashrc
  • switch to no-multilib profile eselect profile set default/linux/amd64/13.0/no-multilib
  • put sys-apps/portage -ipc into /etc/portage/profile/package.use.force it doesn't work well with ipc

Resolved

Suggestions

  • Add an exception for windows antivirus or disable them during emerge processes

Known problems

at the moment anything works for me

gentoo-wsl's People

Contributors

cnd avatar

Stargazers

みづな れい avatar Literasi Bad Guy avatar Artem Vetrov avatar Bodrogi Viktor avatar liuyujielol avatar  avatar Nikita avatar Muhammad Ridwan Hakim avatar Jacoby avatar  avatar 梁永祥 avatar Gustavo Benedetto Papi Muñiz Costa avatar Daniel Douglas avatar Lleyton van Sambeeck avatar  avatar  avatar Dariusz Sieradzki avatar Russell Parks avatar  avatar  avatar Zorz avatar Norton avatar  avatar  avatar Sleeplessy avatar Mike Stanin avatar  avatar Pavel Kulyov avatar Xatory avatar Viacheslav N avatar  avatar ik5 avatar Popa Marius Adrian avatar Jason M. avatar eeL avatar Paul George avatar  avatar Daniel Tlamka avatar Adrien Gruson avatar James LL avatar Adrian Frühwirth avatar Keita Urashima avatar Oleg Höfling avatar Edward avatar Alex avatar Josh Elsasser avatar Eugene Lubarsky avatar Shih-Han Hung avatar John Duncan avatar Alex S. avatar DiGiTAL_CuRSe avatar Alexey Gorishny avatar Sergey avatar Tanabe Ken-ichi avatar  avatar

Watchers

John M. Drescher avatar James Cloos avatar  avatar みづな れい avatar Shih-Han Hung avatar Edward avatar

gentoo-wsl's Issues

Fixing emerge glibc

sys-libs/glibc won't compile without mounting /dev/pts with gid=5

The easiest solution I found is to emerge it with USE="suid", then the emerge pre-check process doesn't look for this to be mounted.

Fixing bad `ld` symlink

Just thought I'd leave some notes on my experiences following your instructions here:

I had problems with the symlink for ld, which prevented me from merging anything that required compiling. in /usr/x86_64-pc-linux-gnu/binutils-bin/2.25.1/ I found:

lrwxr-xr-x 1 root root 52 Jan 19 03:59 ld -> ./usr/x86_64-pc-linux-gnu/binutils-bin/2.25.1/ld.bfd

which was clearly bogus but nearly correct. I replaced it with

lrwxrwxrwx 1 root root 6 Jan 27 01:26 ld -> ld.bfd

which seems to have restored functionality.

The Portage patch PR50 also seems to no longer be required, I think it's been included now.
Also, I believe you should be able to use the no-multilib stage3 from the start if you want. It has the same ld issue.

Fixing login as root

If you just installed Gentoo on WSL you probably can't login as root by executing 'su' as your password will always fail.
An easy trick is to run 'lxrun /setdefaultuser root' on your cmd or powershell before opening your gentoo bash. After, you should delete the user you created on ubuntu on WSL and create it again using your gentoo bash in order to be able to login as the regular user. Then 'su' will run successfully accepting your password.

glibc-2.25-r9 for WSL

Attached file is a archive of glibc-2.25-r9 ebuild for WSL.
glibc-2.25-r9_ebuild.zip

Gentoo's glibc is glibc-2.25-r9 now but it had facilities that WSL does not support yet.
You might use glibc-2.23-r4 with masking new glibc but version 2.23 have another problems;

  1. it could not be built by new binutils-2.29.1-r1 without another glibc patch, so you should mask new binutils too
  2. compiling some guile modules makes BSOD on glibc-2.23-r4 -- I found this while comiling gnutls but guile itself, guile-2.0.14-r3 on gentoo or guile-2.0.11-r1 on funtoo, also makes BSOD.

So, it could be better to upgrade glibc with "Revert linux spawni.c simplify error reporting" patch.

Fixing "syntax error near unexpected token `newline'"

If while opening your bash you get an error message like "syntax error near unexpected token `newline'", this is because now your gentoo bash reads the .bashrc file originally from ubuntu. Check the line that is complaining by editing or commenting it, or create a new gentoo-based .bashrc file and you won't see the message anymore. Below I copy-pasted a working .bashrc file for gentoo.

# /etc/bash/bashrc
#
# This file is sourced by all *interactive* bash shells on startup,
# including some apparently interactive shells such as scp and rcp
# that can't tolerate any output.  So make sure this doesn't display
# anything or bad things will happen !


# Test for an interactive shell.  There is no need to set anything
# past this point for scp and rcp, and it's important to refrain from
# outputting anything in those cases.
if [[ $- != *i* ]] ; then
        # Shell is non-interactive.  Be done now!
        return
fi

# Bash won't get SIGWINCH if another process is in the foreground.
# Enable checkwinsize so that bash will check the terminal size when
# it regains control.  #65623
# http://cnswww.cns.cwru.edu/~chet/bash/FAQ (E11)
shopt -s checkwinsize

# Disable completion when the input buffer is empty.  i.e. Hitting tab
# and waiting a long time for bash to expand all of $PATH.
shopt -s no_empty_cmd_completion

# Enable history appending instead of overwriting when exiting.  #139609
shopt -s histappend

# Save each command to the history file as it's executed.  #517342
# This does mean sessions get interleaved when reading later on, but this
# way the history is always up to date.  History is not synced across live
# sessions though; that is what `history -n` does.
# Disabled by default due to concerns related to system recovery when $HOME
# is under duress, or lives somewhere flaky (like NFS).  Constantly syncing
# the history will halt the shell prompt until it's finished.
#PROMPT_COMMAND='history -a'

# Change the window title of X terminals
case ${TERM} in
        [aEkx]term*|rxvt*|gnome*|konsole*|interix)
                PS1='\[\033]0;\u@\h:\w\007\]'
                ;;
        screen*)
                PS1='\[\033k\u@\h:\w\033\\\]'
                ;;
        *)
                unset PS1
                ;;
esac

# Set colorful PS1 only on colorful terminals.
# dircolors --print-database uses its own built-in database
# instead of using /etc/DIR_COLORS.  Try to use the external file
# first to take advantage of user additions.
use_color=false
if type -P dircolors >/dev/null ; then
        # Enable colors for ls, etc.  Prefer ~/.dir_colors #64489
        LS_COLORS=
        if [[ -f ~/.dir_colors ]] ; then
                # If you have a custom file, chances are high that it's not the default.
                used_default_dircolors="no"
                eval "$(dircolors -b ~/.dir_colors)"
        elif [[ -f /etc/DIR_COLORS ]] ; then
                # People might have customized the system database.
                used_default_dircolors="maybe"
                eval "$(dircolors -b /etc/DIR_COLORS)"
        else
                used_default_dircolors="yes"
                eval "$(dircolors -b)"
        fi
        if [[ -n ${LS_COLORS:+set} ]] ; then
                use_color=true
        fi
        unset used_default_dircolors
else
        # Some systems (e.g. BSD & embedded) don't typically come with
        # dircolors so we need to hardcode some terminals in here.
        case ${TERM} in
        [aEkx]term*|rxvt*|gnome*|konsole*|screen|cons25|*color) use_color=true;;
        esac
fi

if ${use_color} ; then
        if [[ ${EUID} == 0 ]] ; then
                PS1+='\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] '
        else
                PS1+='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\] '
        fi

        alias ls='ls --color=auto'
        alias grep='grep --colour=auto'
        alias egrep='egrep --colour=auto'
        alias fgrep='fgrep --colour=auto'
else
        if [[ ${EUID} == 0 ]] ; then
                # show root@ when we don't have colors
                PS1+='\u@\h \W \$ '
        else
                PS1+='\u@\h \w \$ '
        fi
fi

for sh in /etc/bash/bashrc.d/* ; do
        [[ -r ${sh} ]] && source "${sh}"
done

# Try to keep environment pollution down, EPA loves us.
unset use_color sh

Tips for emacs

USE flags for emacs

Emacs works well unless using gtk3 and dbus. I have no idea why gtk3 making problem but it is.
So, it's my woking USE flags;

SUNJOONG-DESKTOP ~ # emerge -pv emacs
[ebuild   R    ] app-editors/emacs-24.5-r3:24::gentoo  USE="X gfile gtk inotify libxml2 png ssl svg toolkit-scroll-bars xft xpm zlib -Xaw3d -acl -alsa (-aqua) -athena -dbus -games -gconf -gif -gpm -gsettings -gtk3 -gzip-el -hesiod -imagemagick -jpeg -kerberos -livecd -m17n-lib -motif -pax_kernel (-selinux) -sound -source -tiff -wide-int" 0 KiB
SUNJOONG-DESKTOP ~ #

bash.exe shortcut

There is a shortcut of bash.exe named "Bash on Ubuntu on Windows" in your Start Menu like
"C:\Users\sunjoong\AppData\Roaming\Microsoft\Windows\Start Menu\Programs" directory.
You know, sunjoong is my user name, so do with your username in your case.
Change the shortcut name to "Bash on Gentoo on Windows" for looking good.

The target attribute of that shortcut is
C:\Windows\System32\bash.exe ~

Append "-l" option like this;
C:\Windows\System32\bash.exe ~ -l

Then, ~/.bash_profile file will work.

UPDATE: I heard bash.exe will launch bash login shell starting 16184, microsoft/WSL#2067 (comment) ; so you might not need to append -l option after then.

~/.bash_profile

This is my ~/.bash_profile;
SUNJOONG-DESKTOP ~ # cat ~/.bash_profile
# This file is sourced by bash for login shells. The following line
# runs your .bashrc and is recommended by the bash info pages.
if [[ -f ~/.bashrc ]] ; then
. ~/.bashrc
fi

~~/mnt/c/Windows/System32/tasklist.exe /fi 'imagename eq vcxsrv.exe' ~~
~~2> /dev/null ~~
| grep 'No tasks are running' > /dev/null
if [ $? -eq 0 ]; then
~~/mnt/c/Program\ Files/VcXsrv/vcxsrv.exe ~~
:0 -multiwindow -clipboard -wgl &> /dev/null &disown
fi
export DISPLAY=:0
SUNJOONG-DESKTOP ~ #

I had installed VcXsrv Windows X Server.
My ~/.bash_profile check whether X server be running and run X server if not running.

runemacs.exe

I'm using a modified runnig emacs wrapper. This is a source - runemacsWSL.zip.
This is a compiled binary - runemacs.zip. It acts like "bash.exe -l -c emacs".
So, I can run emacs by mouse double-clicking with this wrapper and ~/.bash_profile.

UPDATE: #3 (comment)
UPDATE: #3 (comment)

Microsoft Edge as emacs browse-url-browser-function

This is a part of my emacs init file;

(defun browse-url-edge (url &optional new-window)
  (shell-command
   (concat "/mnt/c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe "
           "start microsoft-edge:'\\\"" url "\\\"'")))

(custom-set-variables
 '(browse-url-browser-function 'browse-url-edge)
 '(inhibit-startup-screen t))

(setq default-directory "/mnt/c/Users/sunjoong/Desktop")

You could notice browse-url-edge function and browse-url-browser-function .
That makes set external web brower to Microsoft Edge.
The inhibit-startup-screen and default-directory make emacs looking other windows program.
You know, sunjoong is my user name, so do with your username in your case.

More simple method to aviod ipc lock error

Before I found your installation howto, I managed to install gentoo.
Just for an information...

  1. Install Ubuntu
    In Windows PowerShell;
PS C:\Users\sunjoong> lxrun /install /y
PS C:\Users\sunjoong> 
  1. Extract Gentoo stage3 tarball
    Run Bash on Ubuntu on Windows.
root@SUNJOONG-DESKTOP:~# mkdir --mode=755 /rootfs
root@SUNJOONG-DESKTOP:~# cd /rootfs
root@SUNJOONG-DESKTOP:/rootfs# wget http://distfiles.gentoo.org/releases/amd64/autobuilds/current-stage3-amd64/stage3-amd64-20170413.tar.bz2
root@SUNJOONG-DESKTOP:/rootfs# tar xvjpf stage3-amd64-20170413.tar.bz2
root@SUNJOONG-DESKTOP:/rootfs# echo 'USE_EXPAND_HIDDEN="ABI_X86"' >> /rootfs/etc/portage/make.conf
root@SUNJOONG-DESKTOP:/rootfs# echo 'MULTILIB_ABIS="amd64"' >> /rootfs/etc/portage/make.conf
root@SUNJOONG-DESKTOP:/rootfs# echo 'FEATURES="-parallel-fetch"' >> /rootfs/etc/portage/make.conf
root@SUNJOONG-DESKTOP:/rootfs# echo 'sys-libs/glibc suid' > /rootfs/etc/portage/package.use/glibc
root@SUNJOONG-DESKTOP:/rootfs# rm ~/.bashrc ~/.profile
root@SUNJOONG-DESKTOP:/rootfs# cp -a /rootfs/etc/skel/.bash* ~
root@SUNJOONG-DESKTOP:/rootfs# rm stage3-amd64-20170406.tar.bz2
root@SUNJOONG-DESKTOP:/rootfs# exit
  1. Replace rootfs to Gentoo
    In Windows PowerShell;
PS C:\Users\sunjoong> cd ${env:LOCALAPPDATA}/lxss
PS C:\Users\sunjoong\AppData\Local\lxss> move rootfs rootfs.old
PS C:\Users\sunjoong\AppData\Local\lxss> move rootfs.old\rootfs rootfs
PS C:\Users\sunjoong\AppData\Local\lxss> del -recurse rootfs.old
PS C:\Users\sunjoong\AppData\Local\lxss> 
  1. Update Gentoo
    Now, you got Gentoo.
    Run Bash on Ubuntu on Windows but the linux system is Gentoo.
SUNJOONG-DESKTOP ~ # emerge --sync
SUNJOONG-DESKTOP ~ # emerge -uND @world
SUNJOONG-DESKTOP ~ # 
  1. Add default user
SUNJOONG-DESKTOP ~ # emerge sudo
SUNJOONG-DESKTOP ~ # groupadd -g 1000 sunjoong
SUNJOONG-DESKTOP ~ # useradd -u 1000 -g 1000 sunjoong
SUNJOONG-DESKTOP ~ # passwd sunjoong
SUNJOONG-DESKTOP ~ # echo 'sunjoong ALL=(ALL) ALL' >> /etc/sudoers
SUNJOONG-DESKTOP ~ # exit

And in Windows PowerShell;

PS C:\Users\sunjoong\AppData\Local\lxss> lxrun /setdefaultuser sunjoong
PS C:\Users\sunjoong\AppData\Local\lxss> exit

You know, sunjoong is my username so you may change it,
and stage3 tarball filename was that of 2017-04-13.

Your howto said to edit AbstractEbuildProcess.py file,
but that matches 'FEATURES="-parallel-fetch"' of mine.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.