32 bit chroot environment for Wine

From Funtoo
Revision as of 00:20, October 11, 2019 by Stamasd (talk | contribs)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

In Funtoo 1.4, 32-bit applications cannot run directly, including 32-bit Wine. However, 32-bit Wine is required to run legacy Windows applications. There are several methods for using x86 applications on a "pure" 64-bit system such as Funtoo 1.4. You can use containers like LXD for instance. Here is another method, which I have tested and works.

The idea is to install a 32-bit Linux distribution in a chroot-ed environment, and redirect its graphical output to the host system. You can use the distribution of your choice, but in this example I use 32-bit Gentoo as it's quite similar to install and use to Funtoo.

You can put the chroot folder anywhere you want, but I think it's a good idea to put it in your regular user's home directory. Download in that folder a x86 Gentoo stage3 tarball from http://distfiles.gentoo.org/releases/x86/autobuilds/current-stage3-i686/ (at the time of this article's creation, http://distfiles.gentoo.org/releases/x86/autobuilds/current-stage3-i686/stage3-i686-20191008T214502Z.tar.xz )

   
$ mkdir ~/gentoo
$ cd ~/gentoo
$ wget <stage3_URL>

Become root from now on, or else the stage3 won't decompress properly. Then follow the installation procedure according to the Gentoo manual.

   
$ sudo su
# tar xpf <stage3>
# cp /etc/resolv.conf /home/<username>/gentoo/etc
# mount -t proc none proc
# mount --rbind /sys sys
# mount --rbind /dev dev
# env -i HOME=/root TERM=$TERM /bin/chroot . bash -l
# export PS1="(chroot) $PS1"
(chroot)# emerge-webrsync
(chroot)# emerge --sync
(chroot)# eselect profile list

and select a desktop profile. For me it was #5, default/linux/x86/17.0/desktop (stable). The desktop profile brings in Xorg which will be needed later for wine anyway.

   
(chroot)# eselect profile set 5

Edit make.conf to add the correct MAKEOPTS ("-j7" worked for me) then do a world update, and go do something else for a couple of hours.

   
(chroot)# emerge -avuDN @world

Once done, set up Xserver redirection in chroot so it displays the image on the host.

On the host in another terminal:

   
hostname:$ xauth list

will show you the "magic" cookie of your host display. Put it into .Xauthority on the chroot:

   
hostname:$ sudo xauth extract <path_to_chroot>/root/.Xauthority <hostname>/unix:0

...where <hostname> is the name of your host machine. Back to the chroot, and verify that the cookie is set correctly:

   
(chroot)# xauth list

should show the same cookie as on the host.

Next set the DISPLAY variable in chroot:

   
hostname:$ echo $DISPLAY

should show ":0.0"

   
(chroot)# export DISPLAY=":0.0"

You can add the above line to /etc/profile in Gentoo so it gets automatically set every time you enter the chroot.

Verify that it works. In chroot run xcalc (you may have to install xcalc first), and it should display on the host.

   
(chroot)# xcalc

If no errors, emerge wine in the chroot and configure it. You should have a 32-bit wine now, ready to run 32-bit Windows binaries (minus configuring, figuring out missing libs etc - but this is beyond the scope of this writeup)

   
(chroot)# emerge wine

Final size of the chroot Gentoo on my disk was close to 4.5GB. Of course you can use the chroot x86 Gentoo for other things that require a 32-bit environment, not only Wine.