Attempt to make wine installations more robust.

This commit is contained in:
Storm Dragon committed 2026-04-26 02:41:06 -04:00
1 parent 6a05a2e385
commit 20811bba1e
1 file changed
+85 -18
@@ -317,9 +317,65 @@ prepare_wine_game_dirs() {
done done
} }
wine_dependency_state_dir() {
printf '%s\n' "${WINEPREFIX}/.stormux-installed-winetricks"
}
wine_dependency_marker() {
local dependency="$1"
local safeDependency
safeDependency="${dependency//[^[:alnum:]._-]/_}"
printf '%s/%s.done\n' "$(wine_dependency_state_dir)" "$safeDependency"
}
wine_dependency_installed() {
local dependency="$1"
[[ -f "$(wine_dependency_marker "$dependency")" ]]
}
mark_wine_dependencies_installed() {
local dependency
local stateDir
stateDir="$(wine_dependency_state_dir)"
mkdir -p "$stateDir"
for dependency in "$@"; do
: > "$(wine_dependency_marker "$dependency")"
done
}
install_missing_wine_dependencies() {
local progressMessage="$1"
local forceWinetricks="${2:-false}"
local dependency
local missingDeps=()
shift 2
for dependency in "$@"; do
if ! wine_dependency_installed "$dependency"; then
missingDeps+=("$dependency")
fi
done
if [[ "${#missingDeps[@]}" -eq 0 ]]; then
return 0
fi
if [[ "$forceWinetricks" == "true" ]]; then
WINETRICKS_FORCE=1 winetricks -q "${missingDeps[@]}" \
| ui_progressbox "Wine Setup" "$progressMessage"
else
winetricks -q "${missingDeps[@]}" \
| ui_progressbox "Wine Setup" "$progressMessage"
fi
mark_wine_dependencies_installed "${missingDeps[@]}"
}
install_wine_bottle() { install_wine_bottle() {
local dep local dep
local newBottle=false local missingCommonDeps=()
local regularDeps=() local regularDeps=()
local needsSpeechsdk=false local needsSpeechsdk=false
local winetricksOptions=() local winetricksOptions=()
@@ -340,20 +396,23 @@ install_wine_bottle() {
mkdir -p "$WINEPREFIX" mkdir -p "$WINEPREFIX"
if [[ ! -f "${WINEPREFIX}/system.reg" ]]; then if [[ ! -f "${WINEPREFIX}/system.reg" ]]; then
newBottle=true
ui_progressbox "Wine Setup" "Initializing Wine bottle" < /dev/null ui_progressbox "Wine Setup" "Initializing Wine bottle" < /dev/null
DISPLAY="${DISPLAY:-}" wine wineboot -u DISPLAY="${DISPLAY:-}" wine wineboot -u
fi fi
prepare_wine_game_dirs prepare_wine_game_dirs
if [[ "$newBottle" == "true" ]]; then for dep in isolate_home corefonts vcrun2019; do
winetricks -q isolate_home corefonts vcrun2019 win10 \ if ! wine_dependency_installed "$dep"; then
missingCommonDeps+=("$dep")
fi
done
if [[ "${#missingCommonDeps[@]}" -gt 0 ]]; then
winetricks -q "${missingCommonDeps[@]}" win10 \
| ui_progressbox "Wine Setup" "Installing common Wine dependencies" | ui_progressbox "Wine Setup" "Installing common Wine dependencies"
env DISPLAY="${DISPLAY:-:0}" WINETRICKS_FORCE=1 winetricks -q speechsdk \ mark_wine_dependencies_installed "${missingCommonDeps[@]}"
| ui_progressbox "Wine Setup" "Installing Wine speech support"
winetricks -q win10 \
| ui_progressbox "Wine Setup" "Restoring Wine Windows version"
fi fi
install_missing_wine_dependencies "Installing Wine speech support" true speechsdk
install_missing_wine_dependencies "Restoring Wine Windows version" false win10
for dep in "$@"; do for dep in "$@"; do
case "$dep" in case "$dep" in
@@ -361,9 +420,7 @@ install_wine_bottle() {
needsSpeechsdk=true needsSpeechsdk=true
;; ;;
corefonts|vcrun2019|isolate_home) corefonts|vcrun2019|isolate_home)
if [[ "$newBottle" != "true" ]]; then regularDeps+=("$dep")
regularDeps+=("$dep")
fi
;; ;;
win7|win8|win10) win7|win8|win10)
: :
@@ -379,15 +436,25 @@ install_wine_bottle() {
fi fi
if [[ "${#regularDeps[@]}" -gt 0 ]]; then if [[ "${#regularDeps[@]}" -gt 0 ]]; then
winetricks -q isolate_home "${regularDeps[@]}" "${winetricksOptions[@]}" \ local missingRegularDeps=()
| ui_progressbox "Wine Setup" "Installing Wine dependencies" for dep in "${regularDeps[@]}"; do
if ! wine_dependency_installed "$dep"; then
missingRegularDeps+=("$dep")
fi
done
if [[ "${#missingRegularDeps[@]}" -gt 0 ]]; then
winetricks -q isolate_home "${missingRegularDeps[@]}" "${winetricksOptions[@]}" \
| ui_progressbox "Wine Setup" "Installing Wine dependencies"
mark_wine_dependencies_installed isolate_home "${missingRegularDeps[@]}"
fi
elif [[ "${#winetricksOptions[@]}" -gt 0 ]]; then
winetricks -q "${winetricksOptions[@]}" \
| ui_progressbox "Wine Setup" "Applying Wine settings"
fi fi
if [[ "$needsSpeechsdk" == "true" && "$newBottle" != "true" ]]; then if [[ "$needsSpeechsdk" == "true" ]]; then
env DISPLAY="${DISPLAY:-:0}" WINETRICKS_FORCE=1 winetricks -q speechsdk \ install_missing_wine_dependencies "Installing Wine speech support" true speechsdk
| ui_progressbox "Wine Setup" "Installing Wine speech support" install_missing_wine_dependencies "Restoring Wine Windows version" false win10
winetricks -q win10 \
| ui_progressbox "Wine Setup" "Restoring Wine Windows version"
fi fi
if [[ -n "${winVer:-}" ]]; then if [[ -n "${winVer:-}" ]]; then