Skip to content

Instantly share code, notes, and snippets.

@shmerl shmerl/wine_env.sh
Last active Mar 6, 2019

Embed
What would you like to do?
#!/bin/bash
# Helper script for wine_run.sh / winetricks_run.sh
# Sets environment and detects prefix arch. See wine_run.sh for details
# on configurable variables usage.
function get_wine_arch() {
local prefix="${WINEPREFIX:-"${HOME}/.wine"}"
local registry_winearch=$(perl -ne 'print $1 if /#arch=(win\d+)/' "${prefix}/system.reg" 2>/dev/null)
wine_arch=${WINEARCH:-"$registry_winearch"}
if [[ "$wine_arch" == "" ]]; then
# WINEARCH was not set and prefix has no info, using win64 as default.
wine_arch="win64"
elif [[ "$wine_arch" != "win64" ]] && [[ "$wine_arch" != "win32" ]]; then
echo "Unexpected Wine arch ${wine_arch} encountered. Aborting!"
echo "WINEARCH='${WINEARCH}', registry_winearch='${registry_winearch}'"
exit 1
fi
printf $wine_arch
}
export wine_arch=$(get_wine_arch)
arch_suffix=""
if [[ "$wine_arch" == "win64" ]]; then
arch_suffix="64"
fi
export wine_bin=${wine_bin:-"wine${arch_suffix}"}
if [[ "${WINEPATH+isset}" ]]; then
export PATH=${WINEPATH}/bin:$PATH
export LD_LIBRARY_PATH="${WINEPATH}/lib${arch_suffix}:${LD_LIBRARY_PATH}"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.