Skip to content

Commit

Permalink
Update windows post
Browse files Browse the repository at this point in the history
Signed-off-by: Anne Isabelle "Anya" Macedo <[email protected]>
  • Loading branch information
retpolanne committed Dec 30, 2024
1 parent 863db9c commit 7f2be1b
Showing 1 changed file with 34 additions and 3 deletions.
37 changes: 34 additions & 3 deletions _posts/2024-12-29-windows-convoluted-madness.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ Anyways, what I'm doing:
yaml:

```yaml
vmType: "vz"
rosetta:
# Enable Rosetta for Linux.
# Hint: try `softwareupdate --install-rosetta` if Lima gets stuck at `Installing rosetta...`
enabled: true
# Register rosetta to /proc/sys/fs/binfmt_misc
binfmt: true
ssh:
forwardX11: true
forwardX11Trusted: true
Expand All @@ -41,15 +48,17 @@ xeyes
sudo apt install gpg
sudo mkdir -pm755 /etc/apt/keyrings
wget -O - https://dl.winehq.org/wine-builds/winehq.key | sudo gpg --dearmor -o /etc/apt/keyrings/winehq-archive.key -
# Bullseye debian src
sudo wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/debian/dists/bullseye/winehq-bullseye.sources
# Bookworm debian src
sudo wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/debian/dists/bookworm/winehq-bookworm.sources

# rather annoying, but needed
sudo dpkg --add-architecture i386
sudo dpkg --add-architecture amd64

sudo apt update

sudo apt install --install-recommends winehq-stable
# Staging gives us amd64
sudo apt install --install-recommends winehq-staging
```

4. If you're on your shiny Apple Silicon, do this:
Expand All @@ -60,11 +69,33 @@ sudo apt install --install-recommends winehq-stable
# then:
# https://github.com/tonistiigi/binfmt
sudo docker run --privileged --rm tonistiigi/binfmt --install x86_64,i386
# Uninstall other emulators so we can just use rosetta
sudo docker run --privileged --rm tonistiigi/binfmt --uninstall qemu-x86_64
sudo docker run --privileged --rm tonistiigi/binfmt --uninstall qemu-i386
```

This last step uses [binfmt_misc](https://docs.kernel.org/admin-guide/binfmt-misc.html) that allows us
to bind an executable with a file type, in a way that we can tell it to emulate whatever we need with qemu/wine behind.

Quite interesting, that's pretty much how Docker for desktop amd64 emulation works as well on Apple Silicon.

I found out that I can install wine amd64 actually:

```sh
sudo apt install --install-recommends winehq-staging:amd64
```

If you want to use rosetta for i386:

```sh
# A handy list of magics here
# https://gitlab.com/pantacor/pv-platforms/wifi-connect/-/blob/master/files/opt/binfmt-misc/qemu-binfmt-conf.sh
sudo /usr/sbin/update-binfmts --install rosetta-i386 /mnt/lima-rosetta/rosetta \
--magic "\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00" \
--mask "\xff\xff\xff\xff\xff\xfe\xfe\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff" \
--credentials yes --preserve no
```

Too bad... rosetta hates i386 :(

See ya next time.

0 comments on commit 7f2be1b

Please sign in to comment.