Snap Wine based application

Hello,

I use a lot an Open Source project called Adventure Game Studio. Unfortunately, it was built with Windows in mind for the editor a long time ago, but it’s usable through Wine (I use it everyday for the past 1 and half years on Ubuntu 16.04).

Is it possible to snap something that depends on Wine?

On a sidenote, here is a game made on it, is it possible to snap it? https://eri0o.itch.io/dungeon-hands

Yes! Totally. https://snapcraft.io/notepad-plus-plus is an example of such an application. The config that made this happen is on https://github.com/mmtrt/notepad-plus-plus

Thanks @popey ! This is amazing. On a sidenote, that specific application maybe depends on dotnet40 package in playonlinux, so I will probably need to sort this when making the snap. But at least I can snap games!

One thing to caveat, is some wine api calls require ptrace capability which is currently not allowed by snapd, so you may find that your particular app fails while others work fine.

1 Like

This is something on the list for next cycle for me to look at more deeply. New enough kernels it is ok to ptrace oneself, so I’d like to explore options with probing the kernel and utilizing system-key. It’s tricky though, cause that would mean it works some places but not others.

Regardless of all that, do you have a specific snap that displays the issue?

1 Like

This replicates it quite nicely with a freshly compiled wine - you need to run the snap which will successfully run a windows-side installer wizard to install the game and then you need to try playing the installed game which will leave your session with an invisible X11 full screen window (alt+tab to get somewhere else - be sure you’ve got a terminal in the background so you can switch to it to run xkill and click anywhere other than the terminal window to kill the fullscreen window).

name: cncredalert
version: '1.0'
summary: Command & Conquer Red Alert
description: Command & Conquer Red Alert

grade: stable
confinement: strict

apps:
  cncredalert:
    command: desktop-launch alsa-launch wine-launch $SNAP/usr/games/cncredalert
    environment:
      HOME: $SNAP_USER_COMMON
    plugs:
    - desktop
    - desktop-legacy
    - network
    - network-bind
    - opengl
    - process-control
    - pulseaudio
    - wayland
    - x11

parts:
  add-architecture:
    plugin: nil
    prepare: |
      if [ "$(uname -m)" = "x86_64" ]; then
        dpkg --add-architecture i386
        apt-get update
        apt-get install -yqq \
          'libcapi20-dev:i386' \
          'libcups2-dev:i386' \
          'libdbus-1-dev:i386' \
          'libfontconfig-dev:i386' \
          'libfreetype6-dev:i386' \
          'libgl-dev:i386' \
          'libglu-dev:i386' \
          'libgnutls-dev:i386' \
          'libgphoto2-dev:i386' \
          'libgsm1-dev:i386' \
          'libgstreamer1.0-dev:i386' \
          'libgstreamer-plugins-base1.0-dev:i386' \
          'libjpeg-dev:i386' \
          'libjson-c-dev:i386' \
          'libkrb5-dev:i386' \
          'liblcms2-dev:i386' \
          'libldap2-dev:i386' \
          'libmpg123-dev:i386' \
          'libncurses5-dev:i386' \
          'libnet1-dev:i386' \
          'libopenal-dev:i386' \
          'libosmesa6-dev:i386' \
          'libpng12-dev:i386' \
          'libpulse-dev:i386' \
          'libsane-dev:i386' \
          'libtiff-dev:i386' \
          'libv4l-dev:i386' \
          'libx11-dev:i386' \
          'libxcomposite-dev:i386' \
          'libxcursor-dev:i386' \
          'libxext-dev:i386' \
          'libxi-dev:i386' \
          'libxinerama-dev:i386' \
          'libxml2-dev:i386' \
          'libxrandr-dev:i386' \
          'libxrender-dev:i386' \
          'libxslt1-dev:i386' \
          'libxt-dev:i386' \
          'libxxf86vm-dev:i386' \
          lib32ncurses5-dev \
          'ocl-icd-opencl-dev:i386' \
          'pkg-config:i386' \
          'unixodbc-dev:i386'
      fi

  alsa-lib:
    after: [add-architecture]
    source: git://git.alsa-project.org/alsa-lib.git
    source-tag: 'v1.1.5'
    configflags:
    - --prefix=/usr
    - --sysconfdir=/etc
    - --libexec=/usr/lib
    - --libdir=/usr/lib
    - --localstatedir=/var
    - --with-configdir=/snap/$SNAPCRAFT_PROJECT_NAME/current/usr/share/alsa
    - --with-plugindir=/snap/$SNAPCRAFT_PROJECT_NAME/current/usr/lib/alsa-lib
    - --disable-alisp
    - --disable-aload
    - --disable-mixer
    - --disable-python
    - --disable-rawmidi
    - --disable-static
    - --disable-topology
    - --disable-ucm
    - --enable-symbolic-functions
    - --host=i386-linux-gnu
    - CFLAGS=-m32
    - CXXFLAGS=-m32
    - LDFLAGS=-m32

  alsa-plugins:
    after: [add-architecture, alsa-lib]
    source: git://git.alsa-project.org/alsa-plugins.git
    source-tag: 'v1.1.5'
    configflags:
    - --prefix=/usr
    - --sysconfdir=/etc
    - --libexec=/usr/lib
    - --libdir=/usr/lib
    - --localstatedir=/var
    - --disable-arcamav
    - --disable-avcodec
    - --disable-jack
    - --disable-mix
    - --disable-oss
    - --disable-usbstream
    - --with-plugindir=/snap/$SNAPCRAFT_PROJECT_NAME/current/usr/lib/alsa-lib
    - --disable-static
    - --host=i386-linux-gnu
    - CFLAGS=-m32
    - CXXFLAGS=-m32
    - LDFLAGS=-m32 -L$SNAPCRAFT_STAGE/usr/lib

  alsa:
    after: [alsa-plugins, alsa-lib]
    build: |
      sed -i 's|ARCH="amd64-linux-gnu"|ARCH="i386-linux-gnu"|' alsa-launch

  wine:
    after: [add-architecture, alsa]
    plugin: autotools
    source: https://dl.winehq.org/wine/source/3.0/wine-3.0.tar.xz
    prepare: |
      # wget https://dl.winehq.org/wine/wine-mono/4.7.1/wine-mono-4.7.1.msi

      cat > wine-launch <<EOF
      #!/bin/bash
      if [ "\$SNAP_ARCH" = "amd64" ]; then
        ARCH="x86_64-linux-gnu"
      elif [ "\$SNAP_ARCH" = "armhf" ]; then
        ARCH="arm-linux-gnueabihf"
      elif [ "\$SNAP_ARCH" = "arm64" ]; then
        ARCH="aarch64-linux-gnu"
      else
        ARCH="\$SNAP_ARCH-linux-gnu"
      fi

      WINEARCH="i386-linux-gnu"

      if [ "\$ARCH" != "\$WINEARCH" ]; then
        if [ -d "\$SNAP/lib/\$WINEARCH" ]; then
          export LD_LIBRARY_PATH="\$SNAP/lib/\$WINEARCH:\$LD_LIBRARY_PATH"
        fi
        if [ -d "\$SNAP/usr/lib/\$WINEARCH" ]; then
          export LD_LIBRARY_PATH="\$SNAP/usr/lib/\$WINEARCH:\$LD_LIBRARY_PATH"
        fi
        if [ -d "\$SNAP/usr/lib/\$WINEARCH/mesa" ]; then
          export LD_LIBRARY_PATH="\$SNAP/usr/lib/\$WINEARCH/mesa:\$LD_LIBRARY_PATH"
        fi
        if [ -d "\$SNAP/usr/lib/\$WINEARCH/samba" ]; then
          export LD_LIBRARY_PATH="\$SNAP/usr/lib/\$WINEARCH/samba:\$LD_LIBRARY_PATH"
        fi
        if [ -d "\$SNAP/usr/lib/\$WINEARCH/pulseaudio" ]; then
          export LD_LIBRARY_PATH="\$SNAP/usr/lib/\$WINEARCH/pulseaudio:\$LD_LIBRARY_PATH"
        fi
      fi

      export LD_LIBRARY_PATH="\$SNAP/usr/lib/\$ARCH/mesa:\$LD_LIBRARY_PATH"
      export LD_LIBRARY_PATH="\$SNAP/usr/lib/\$ARCH/samba:\$LD_LIBRARY_PATH"
      export LD_LIBRARY_PATH="\$SNAP/usr/lib/\$ARCH/pulseaudio:\$LD_LIBRARY_PATH"

      exec "\$@"
      EOF
    install: |
      # install -m644 -D -t $SNAPCRAFT_PART_INSTALL/share/wine wine-mono-4.7.1.msi
      install -m755 -D -t $SNAPCRAFT_PART_INSTALL/bin wine-launch
    build-packages:
    - bison
    - desktop-file-utils
    - docbook-to-man
    - docbook-utils
    - docbook-xsl
    - flex
    - fontforge
    - gcc-multilib
    - gettext
    - prelink
    - on i386:
      - libasyncns-dev
      - libcapi20-dev
      - libcups2-dev
      - libdbus-1-dev
      - libfontconfig-dev
      - libfreetype6-dev
      - libgif-dev
      - libgl-dev
      - libglu-dev
      - libgnutls-dev
      - libgphoto2-dev
      - libgsm1-dev
      - libgstreamer1.0-dev
      - libgstreamer-plugins-base1.0-dev
      - libjpeg-dev
      - libjson-c-dev
      - libkrb5-dev
      - liblcms2-dev
      - libldap2-dev
      - libmpg123-dev
      - libncurses5-dev
      - libnet1-dev
      - libopenal-dev
      - libosmesa6-dev
      - libpng12-dev
      - libpulse-dev
      - libsane-dev
      - libtiff-dev
      - libv4l-dev
      - libx11-dev
      - libxcomposite-dev
      - libxcursor-dev
      - libxext-dev
      - libxi-dev
      - libxinerama-dev
      - libxml2-dev
      - libxrandr-dev
      - libxrender-dev
      - libxslt1-dev
      - libxt-dev
      - libxxf86vm-dev
      - linux-kernel-headers
      - ocl-icd-opencl-dev
      - unixodbc-dev
      - x11proto-xinerama-dev
    stage-packages:
    - winbind
    - on i386:
      - gstreamer1.0-plugins-base
      - libcapi20-3
      - libcups2
      - libdbus-1-3
      - libfontconfig1
      - libfreetype6
      - libgl1
      - libglu1-mesa
      - libgnutls30
      - libgphoto2-6
      - libgsm1
      - libgstreamer1.0-0
      - libgstreamer-plugins-base1.0-0
      - libjpeg-turbo8
      - libjson-c2
      - libkrb5-3
      - liblcms2-2
      - libldap-2.4-2
      - libmpg123-0
      - libncurses5
      - libnet1
      - libodbc1
      - libopenal1
      - libosmesa6
      - libpng12-0
      - libpulse0
      - libsane
      - libtiff5
      - libv4l-0
      - libx11-6
      - libxcursor1
      - libxext6
      - libxinerama1
      - libxml2
      - libxrandr2
      - libxrender1
      - libxslt1.1
      - libxt6
      - libxxf86vm1
      - ocl-icd-libopencl1
    - on amd64:
      - gstreamer1.0-plugins-base:i386
      - libcapi20-3:i386
      - libcups2:i386
      - libdbus-1-3:i386
      - libfontconfig1:i386
      - libfreetype6:i386
      - libgl1:i386
      - libglu1-mesa:i386
      - libgnutls30:i386
      - libgphoto2-6:i386
      - libgsm1:i386
      - libgstreamer1.0-0:i386
      - libgstreamer-plugins-base1.0-0:i386
      - libjpeg-turbo8:i386
      - libjson-c2:i386
      - libkrb5-3:i386
      - liblcms2-2:i386
      - libldap-2.4-2:i386
      - libmpg123-0:i386
      - libncurses5:i386
      - libnet1:i386
      - libodbc1:i386
      - libopenal1:i386
      - libosmesa6:i386
      - libpng12-0:i386
      - libpulse0:i386
      - libsane:i386
      - libtiff5:i386
      - libv4l-0:i386
      - libx11-6:i386
      - libxcursor1:i386
      - libxext6:i386
      - libxinerama1:i386
      - libxml2:i386
      - libxrandr2:i386
      - libxrender1:i386
      - libxslt1.1:i386
      - libxt6:i386
      - libxxf86vm1:i386
      - ocl-icd-libopencl1:i386

  cncredalert:
    after: [desktop-glib-only]
    plugin: dump
    source: https://downloads.cncnet.org/cncredalert_1.0_all.deb
    prepare: |
      sed -i 's|/usr/share/games|$SNAP/usr/share/games|' usr/games/cncredalert

Just to mention that from @popey indication of the notepad-plus-plus wine snap, I forked and started to give a shot on getting a working Adventure Game Studio snap on this repo - it’s still a little far from working, but I hope to be able to figure out stuff at some point.

Right now it’s failing on permission denied error when running dpkg --add-architecture i386, during build process, which I haven’t added, so I guess I can’t reproduce notepadplusplus build.

Just FYI, if you want to give this another shot, I created a thread to gather all of the info about snapping a wine application here: [Archived] WineSnap: Creating snaps for Windows applications

You might want to try restarting from the SteamForWindows snap.

Hello! I installed this app, downloaded the game I wanted from Steam, downloaded it, but at the time of playing it does not run. Any tips?
The game is Age of Empires 2 HD.
thankful

You should open a new thread for this and also attach some logging output (i.e. the output in a terminal when you use snap run to start it)

tanx a lot, ill try.

We’ve got a medical app that relies on Java, .NET, Acrobat and some certificates. It also communicates with a Microsoft SQL server on another computer. If anybody can make this work I’ll pay cash.

I don’t know if it’s better to resurrect an old thread or start a new one, but I’m starting here. I’ve tried to snap a few apps for my organization that run under WINE. They also rely on .NET 4. Invariably I get everything to work in devmode, but confinement blocks the apps from working properly. The blocker I have repeatedly seen is a call to System.Diagnostics.NtProcessManager.GetModuleInfos(), which apparently uses ptrace according to snappy-debug.

So I would love for there to be some kind of interface available that would allow a WINE-based app to handle this and similar ptrace-based calls. Just for thoroughness’ sake, I’ve tried using pretty much every interface that mentions processes, and they’ve not helped.

Are you willing to help to get such thing build, if yes am working on such thing and i need some help, so if someone helps which rarely happens it may be possible at-least in the near future ??

I’m willing and somewhat available, but I don’t know if my skills match the need. Do you have a repo I can take a look at?

Sure, we can also try to build wine from source later --> https://github.com/CapeCrusader321/Wine-Latest-Snap