Download a default wine runner if system wine does not meet reqs

This commit is contained in:
the-sane 2024-10-23 17:27:46 -04:00
parent 86f3b3b1f6
commit ca39caf92b

View File

@ -210,6 +210,11 @@ runner_sources=(
"RawFox" "https://api.github.com/repos/starcitizen-lug/raw-wine/releases"
)
# Set the default runner to install when the system wine doesn't meet requirements
# default_runner_source corresponds to an even number index in runner_sources above
default_runner="wine-9.20-amd64.tar.xz"
default_runner_source=0
######## DXVK ##############################################################
# Lutris native dxvk directory
@ -977,10 +982,18 @@ lutris_detect() {
}
# Check the system Wine version
# Tells the preflight check whether or not wine is installed
# Additionally sets system_wine_ok if system wine meets the minimum version requirement
wine_check() {
# Initialize variable
system_wine_ok="false"
# Is wine installed?
if [ ! -x "$(command -v wine)" ]; then
preflight_fail+=("Wine does not appear to be installed.\nPlease refer to our Quick Start Guide:\n$lug_wiki")
return 1
else
preflight_pass+=("Wine is installed on your system.")
fi
# Get the current wine version
@ -988,12 +1001,17 @@ wine_check() {
# Check it against the required version
if [ -z "$wine_current" ]; then
preflight_fail+=("Unable to detect Wine version info.\nVersion $wine_required or newer is required.")
system_wine_ok="false"
elif [ "$wine_required" != "$wine_current" ] &&
[ "$wine_current" = "$(printf "%s\n%s" "$wine_current" "$wine_required" | sort -V | head -n1)" ]; then
preflight_fail+=("Wine is out of date.\nVersion $wine_required or newer is required.")
system_wine_ok="false"
else
preflight_pass+=("Wine is installed and sufficiently up to date.")
system_wine_ok="true"
fi
# Check for wow64 wines
if [ ! -x "$(command -v wine-preloader)" ] || [ -L "$(command -v wine64-preloader)" ]; then
system_wine_ok="false"
fi
}
@ -1410,8 +1428,7 @@ dxvk_manage_lutris() {
# - download_type (string)
# - download_dirs (array)
download_select_install() {
# This function expects an element number for the sources array
# to be passed in as an argument
# This function expects an element number for the sources array to be passed in as an argument
if [ -z "$1" ]; then
debug_print exit "Script error: The download_select_install function expects a numerical argument. Aborting."
fi
@ -1841,6 +1858,8 @@ download_install() {
debug_print continue "Cleaning up $tmp_dir/$download_filename..."
rm --interactive=never "${tmp_dir:?}/$download_filename"
rm -r "${tmp_dir:?}/$download_basename"
return 0
}
# List installed items for deletion. Called by download_manage()
@ -2621,7 +2640,7 @@ install_game_wine() {
return 1
fi
# Call the preflight check
# Call the preflight check and confirm the user is ready to proceed
preflight_check "wine"
if [ "$?" -eq 1 ]; then
# There were errors
@ -2630,8 +2649,11 @@ install_game_wine() {
# No errors
install_question="Before proceeding, please refer to our Quick Start Guide:\n$lug_wiki\n\nAll Preflight Checks have passed\nAre you ready to continue?"
fi
if ! message question "$install_question"; then
return 1
fi
if message question "$install_question"; then
# Get the install path from the user
if message question "Would you like to use the default install path?\n\n$HOME/Games/star-citizen"; then
# Set the default install path
install_dir="$HOME/Games/star-citizen"
@ -2695,9 +2717,35 @@ install_game_wine() {
# Create the game path
mkdir -p "$install_dir"
# If we can't use the system wine, we'll need to have the user select a custom wine runner to use
wine_bin="wine"
if [ "$system_wine_ok" = "true" ]; then
debug_print continue "Your system Wine does not meet the minimum requirements for Star Citizen!"
debug_print continue "A custom wine runner will be automatically downloaded and used."
download_dirs=("wine" "$install_dir/runners")
# Install the default wine runner into the prefix
download_wine
# Make sure the wine download worked
if [ "$?" -eq 1 ]; then
message error "Something went wrong while installing ${default_runner}!\nGame installation cannot proceed."
return 1
fi
wine_bin="$install_dir/runners/$downloaded_item_name/bin/wine"
fi
# Download winetricks
download_winetricks
# Abort if the winetricks download failed
if [ "$?" -eq 1 ]; then
message error "Unable to install Star Citizen without winetricks. Aborting."
return 1
fi
# Download RSI installer to tmp
download_file "$rsi_installer_url" "$rsi_installer" "installer"
# Sanity check
if [ ! -f "$tmp_dir/$rsi_installer" ]; then
# Something went wrong with the download and the file doesn't exist
@ -2705,18 +2753,8 @@ install_game_wine() {
return 1
fi
# Download winetricks
download_winetricks
# Abort if the winetricks download failed
if [ "$?" -eq 1 ]; then
message error "Unable to install Star Citizen without winetricks. Aborting."
return 1
fi
# Create a temporary log file
tmp_install_log="$(mktemp --suffix=".log" -t "lughelper-install-XXX")"
debug_print continue "Installation log file created at $tmp_install_log"
# Create the new prefix and install powershell
@ -2734,11 +2772,11 @@ install_game_wine() {
fi
# Add registry key that prevents wine from creating unnecessary file type associations
wine reg add "HKEY_CURRENT_USER\Software\Wine\FileOpenAssociations" /v Enable /d N /f >>"$tmp_install_log" 2>&1
"$wine_bin" reg add "HKEY_CURRENT_USER\Software\Wine\FileOpenAssociations" /v Enable /d N /f >>"$tmp_install_log" 2>&1
# Run the installer
debug_print continue "Installing the launcher. Please wait; this will take a moment..."
wine "$tmp_dir/$rsi_installer" /S >>"$tmp_install_log" 2>&1
"$wine_bin" "$tmp_dir/$rsi_installer" /S >>"$tmp_install_log" 2>&1
if [ "$?" -eq 1 ]; then
# User cancelled or there was an error
@ -2776,6 +2814,12 @@ install_game_wine() {
# Update WINEPREFIX in game launch script
sed -i "s|^export WINEPREFIX.*|export WINEPREFIX=\"$install_dir\"|" "$installed_launch_script"
# Update Wine binary in game launch script
if [ "$wine_bin" != "wine" ]; then
post_download_sed_string="wine_exec="
sed -i "s|^${post_download_sed_string}.*|${post_download_sed_string}\"${wine_bin}\"|" "$installed_launch_script"
fi
# Modify the .desktop files installed by wine to exec the game launch script
debug_print continue "Updating .desktop files installed by wine..."
@ -2830,6 +2874,39 @@ install_game_wine() {
fi
message info "Installation has finished. The install log was written to $tmp_install_log\n\nTo start the RSI Launcher, run the following launch script in a terminal\nEdit the environment variables in the script as needed:\n $installed_launch_script\n\nYou may also start the RSI Launcher using the following .desktop files:\n $home_desktop_file\n $localshare_desktop_file"
}
# Download a default wine runner for use by the non-lutris installer
# Expects download_dirs to be set before calling
download_wine() {
if [ "${#download_dirs[@]}" -eq 0 ]; then
debug_print exit "Script error: The array 'download_dirs' was not set before calling the download_wine function. Aborting."
fi
# Set up variables needed for the download functions, quick and dirty
# For more details, see their usage in the download_select_install and download_install functions
declare -n download_sources=runner_sources
download_type="runner"
download_versions=("$default_runner")
contributor_name="${download_sources[$default_runner_source]}"
contributor_url="${download_sources[$default_runner_source+1]}"
case "$contributor_url" in
https://api.github.com/*)
download_url_type="github"
;;
https://gitlab.com/api/v4/projects/*)
download_url_type="gitlab"
;;
*)
debug_print exit "Script error: Unknown api/url format in ${download_type}_sources array. Aborting."
;;
esac
# Call the download_install function with the above options to install the default wine runner
download_install 0
if [ "$?" -eq 1 ]; then
return 1
fi
}