osxmidi / LinVst

Linux Windows vst wrapper/bridge
GNU General Public License v3.0
674 stars 41 forks source link

Ability to use different versions of wine (fix included) #220

Closed myrocketship closed 1 year ago

myrocketship commented 1 year ago

The following edited servertrack.exe allows the user to use different versions of wine for plugins located in their own wine directories. It has helped me with many plugins, when they only run (well) with a specific release, as I have increasing incompatibilities with the wine 6+7 releases, for example many softube, korg, old amplitube 32bit run best with wine 5.x or 6.x I currently have wine-staging as my main version of wine, plus four versions of wine-tkg for different purposes. I have used this now for a couple of months on different *buntu machines, and it has saved me a lot of grief, especially with many older projects, that no longer load properly.

My apologies, I don't really understand how to use git, so I will just list the edited shell wrapper here:

lin-vst-servertrack.exe

#!/bin/sh

appname="lin-vst-servertrack.exe.so"

# koala: get WINEPREFIX and WINEDIR. Use 'realpath' command to make sure we are using requested version of wine.  
# koala: Also using a clunky 'xargs dirname' pipe to remain compatible with non-bash users. 
# koala: You might want to make the IFS a global in the script, as I didn't account for spaces in this section.

if [ -x "$WINEPREFIX/wine/bin/wine" ]; then
    WINEDIR="$(realpath $WINEPREFIX/wine/bin/wine | xargs dirname | xargs dirname )"
else
   # fallback to system wine
    WINEDIR="$(which wine | xargs realpath | xargs dirname | xargs dirname )"
fi

# koala: set the relevant binaries and paths
# NOTE: this will only work if the directory structure follows the standard
WINESERVER=$WINEDIR/bin/wineserver
WINELOADER=$WINEDIR/bin/wine
WINEDLLPATH=$WINEDIR/lib/wine

# determine the application directory
appdir=''
case "$0" in
  */*)
    # $0 contains a path, use it
    appdir=`dirname "$0"`
    ;;
  *)
    # no directory in $0, search in PATH
    saved_ifs=$IFS
    IFS=:
    for d in $PATH
    do
      IFS=$saved_ifs
      if [ -x "$d/$appname" ]; then appdir="$d"; break; fi
    done
    ;;
esac

# figure out the full app path
if [ -n "$appdir" ]; then
    apppath="$appdir/$appname"

How to use: 1) Obviously we replace the old versions of the servertrack.exe files with the modified script

2) create wine prefix and install plugin WINEPREFIX=/home/foo/.wine-pluginX wine <install.exe>

3) link or copy a wine release into the tree (I prefer to copy to create a permanent/movable copy of the plugin) cp -a /usr/local/wine-tkg-staging-fsync-git-5.10.r0.g8648971f /home/foo/.wine-pluginX/wine

4) Done! Just use linvst as per normal.

osxmidi commented 1 year ago

The following edited servertrack.exe allows the user to use different versions of wine for plugins located in their own wine directories. It has helped me with many plugins, when they only run (well) with a specific release, as I have increasing incompatibilities with the wine 6+7 releases, for example many softube, korg, old amplitube 32bit run best with wine 5.x or 6.x I currently have wine-staging as my main version of wine, plus four versions of wine-tkg for different purposes. I have used this now for a couple of months on different *buntu machines, and it has saved me a lot of grief, especially with many older projects, that no longer load properly.

My apologies, I don't really understand how to use git, so I will just list the edited shell wrapper here:

lin-vst-servertrack.exe

#!/bin/sh

appname="lin-vst-servertrack.exe.so"

# koala: get WINEPREFIX and WINEDIR. Use 'realpath' command to make sure we are using requested version of wine.  
# koala: Also using a clunky 'xargs dirname' pipe to remain compatible with non-bash users. 
# koala: You might want to make the IFS a global in the script, as I didn't account for spaces in this section.

if [ -x "$WINEPREFIX/wine/bin/wine" ]; then
    WINEDIR="$(realpath $WINEPREFIX/wine/bin/wine | xargs dirname | xargs dirname )"
else
   # fallback to system wine
    WINEDIR="$(which wine | xargs realpath | xargs dirname | xargs dirname )"
fi

# koala: set the relevant binaries and paths
# NOTE: this will only work if the directory structure follows the standard
WINESERVER=$WINEDIR/bin/wineserver
WINELOADER=$WINEDIR/bin/wine
WINEDLLPATH=$WINEDIR/lib/wine

# determine the application directory
appdir=''
case "$0" in
  */*)
    # $0 contains a path, use it
    appdir=`dirname "$0"`
    ;;
  *)
    # no directory in $0, search in PATH
    saved_ifs=$IFS
    IFS=:
    for d in $PATH
    do
      IFS=$saved_ifs
      if [ -x "$d/$appname" ]; then appdir="$d"; break; fi
    done
    ;;
esac

# figure out the full app path
if [ -n "$appdir" ]; then
    apppath="$appdir/$appname"

How to use:

1. Obviously we replace the old versions of the servertrack.exe files with the modified script

2. create wine prefix and install plugin
   `WINEPREFIX=/home/foo/.wine-pluginX wine <install.exe>`

3. link or copy a wine release into the tree (I prefer to copy to create a permanent/movable copy of the plugin)
   `cp -a /usr/local/wine-tkg-staging-fsync-git-5.10.r0.g8648971f /home/foo/.wine-pluginX/wine`

4. Done! Just use linvst as per normal.

Good idea.

I've tested it out and it works, I'll see if I can add any finishing setup touches (and if you want to add anything) and then I'll put the script in it's own folder in the main directory

I think you forgot this bit at the end of the script

# figure out the full app path
if [ -n "$appdir" ]; then
    apppath="$appdir/$appname"
    WINEDLLPATH="$appdir:$WINEDLLPATH"
    export WINEDLLPATH
else
    apppath="$appname"
fi

# determine the WINELOADER
if [ ! -x "$WINELOADER" ]; then WINELOADER="wine"; fi

# and try to start the app
exec "$WINELOADER" "$apppath" "$@"
myrocketship commented 1 year ago

I've got some ideas to add at a later date, but if you're happy pop it into the git now, let people play with it.

osxmidi commented 1 year ago

I've put it in the wine-script folder.