PortWINE/portwine_run_scripts/runlib
2019-11-30 19:52:17 +03:00

255 lines
6.1 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# Author: PortWINE-Linux.ru
[ $(id -u) -eq 0 ] && echo "Do not run this script as root!" && zenity --error --text "Do not run this script as root!" && exit 1
for PROGS in "xterm" "wget" "curl"
do
if [ ! -x "`which "${PROGS}" 2>/dev/null`" ]
then
zenity --info --text "You need to install: ${PROGS}"
fi
done
cd "$(dirname "`readlink -f "$0"`")"
export link="$(pwd)"
cd "${link}/../../"
export PORT_WINE_PATH="$(pwd)"
cd "${link}"
. "${link}"/vars
export config_path="${PORT_WINE_PATH}/data/tmp"
if [ ! -d "${config_path}" ]
then
mkdir -p "${config_path}"
fi
if [ ! -e "${config_path}/${portname}_loc" ]
then
SET_LANG=`zenity --title "Install $portname" --text "Select the language\nВыберите язык" --list --radiolist \
--column="Set (Выбор)" --column "Language (Язык):" \
TRUE "RUS" \
FALSE "ENG" `
echo "${SET_LANG}" > "${config_path}/${portname}_loc"
fi
if [ ! -e "${config_path}/${portname}_ver" ]
then
echo "10" > "${config_path}/${portname}_ver"
fi
if [ "${update_loc}" = "RUS" ]
then
LC_COLLATE_old="${LC_COLLATE}"
LC_CTYPE_old="${LC_CTYPE}"
LC_ALL_old="${LC_ALL}"
export LC_COLLATE=ru_RU.UTF-8
export LC_CTYPE=ru_RU.UTF-8
export LC_ALL=ru_RU.UTF-8
fi
export LD_LIBRARY_PATH_OLD="${LD_LIBRARY_PATH}"
export LD_PRELOAD_OLD="${LD_PRELOAD}"
export PATH_OLD="$PATH"
. "${link}"/lang
########################################################################
GLIBC_REQUIRED=2.23
GLIBC_VERSION="$(ldd --version | head -n1 | sed 's/\(.*\) //g' | sed 's/\.[^.]*//2g')"
if [ "$(echo ${GLIBC_VERSION} | sed 's/\.//g')" -lt "$(echo ${GLIBC_REQUIRED} | sed 's/\.//g')" ]
then
WINEDIR="${PORT_WINE_PATH}"/data/wine_glibc_223
else
WINEDIR="${PORT_WINE_PATH}"/data/wine_glibc_227
fi
echo "Used WINE: ${WINEDIR}"
########################################################################
if [ ! -d "${WINEDIR}/lib64" ]
then
export WINEARCH=win32
export WINELOADER="${WINEDIR}/bin/wine"
export WINEDLLPATH="${WINEDIR}/lib/wine"
if [ "$runtime_libs" -eq "1" ]
then
export LD_LIBRARY_PATH=${WINEDIR}/runtime-lib_i386:${WINEDIR}/lib:${LD_LIBRARY_PATH}
else
export LD_LIBRARY_PATH=${WINEDIR}/lib:${LD_LIBRARY_PATH}
fi
else
export WINEARCH=win64
export WINELOADER="${WINEDIR}/bin/wine64"
export WINEDLLPATH="${WINEDIR}/lib64/wine"
if [ "$runtime_libs" -eq "1" ]
then
export LD_LIBRARY_PATH=${WINEDIR}/runtime-lib_x86_64:${WINEDIR}/runtime-lib_i386:${WINEDIR}/lib64:${WINEDIR}/lib:${LD_LIBRARY_PATH}
else
export LD_LIBRARY_PATH=${WINEDIR}/lib64:${WINEDIR}/lib:${LD_LIBRARY_PATH}
fi
fi
if [ ! -e "${WINEDIR}/share/wine/smb.conf" ]
then
export us_dir="$USER"
export STAGING_WRITECOPY=1
else
export us_dir="crossover"
fi
export WINESERVER="${WINEDIR}/bin/wineserver"
export WINECFG="${WINEDIR}/bin/winecfg"
export WINEREG="${WINEDIR}/bin/regedit"
export WINEOPEN="${WINEDIR}/bin/winefile"
export WINEBOOT="${WINEDIR}/bin/wineboot"
export WINECMD="${WINEDIR}/bin/wineconsole"
export WINEPREFIX="${PORT_WINE_PATH}/data/prefix"
export PATH="${WINEDIR}/bin":${PATH}
export WINESTART="C:\\windows\\command\\start.exe"
export urlg="http://portwine-linux.ru/donate"
#export CORES="$(getconf _NPROCESSORS_ONLN)"
export WINEFSYNC=1
export PROTON_NO_FSYNC=0
# Check if Wine has PBA or ESYNC features
if grep PBA "${WINEDIR}/lib/wine/wined3d.dll.so" &>/dev/null || grep PBA "${WINEDIR}/lib64/wine/wined3d.dll.so" &>/dev/null
then
PBA_ENABLE=1
else
PBA_ENABLE=0
fi
#if grep ESYNC "${WINEDIR}/lib/wine/ntdll.dll.so" &>/dev/null || grep ESYNC "${WINEDIR}/lib64/wine/ntdll.dll.so" &>/dev/null
#then
# if ! ulimit -n 500000 &>/dev/null
# then
export WINEESYNC=0
# else
# export WINEESYNC=1
# fi
#fi
########################################################################
START_PORTWINE ()
{
chown -R "$USER" "$WINEPREFIX/drive_c"
chown -R "$USER" "$WINEPREFIX"/*.reg
gpu="0"
export DRI_PRIME=1
export optirun_on=env
if [ -x "`which primusrun 2>/dev/null`" ]
then
export optirun_on="primusrun"
gpu="1"
elif [ -x "`which optirun 2>/dev/null`" ]
then
export optirun_on="optirun -b primus"
gpu="1"
fi
if [ -x "`which nvidia-settings 2>/dev/null`" ]
then
nvidia-settings -a [gpu:"${gpu}"]/GPUPowerMizerMode=1 > /dev/null
export VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/nvidia_icd.json
fi
sh "${link}"/port_update
#rm -f "$WINEPREFIX/dosdevices/z:"
for x in "$WINEPREFIX/drive_c/users/${us_dir}/"*
do
if test -h "$x" && test -d "$x"
then
rm -f "$x"
mkdir -p "$x"
fi
done
for x in "$WINEPREFIX/drive_c/users/${us_dir}/Desktop/"*
do
if test -h "$x" && test -d "$x"
then
rm -f "$x"
mkdir -p "$x"
fi
done
#"$WINE" regedit /d 'HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\Namespace\{9D20AAE8-0625-44B0-9CA7-71889C2254D9}'
echo disable > "$WINEPREFIX/.update-timestamp"
ADD_IN_START_PORTWINE
}
########################################################################
OPENGL_SET ()
{
if [ -e "${config_path}/dxvk" ]
then
bash "${link}/setup_dxvk.sh" "uninstall"
rm -f "${config_path}/dxvk"
else
echo "DXVK is disabled"
fi
export PROTON_USE_WINED3D=1
export PROTON_USE_D9VK=0
export DXVK_STATE_CACHE=0
export __GL_SHADER_DISK_CACHE_PATH="${PATH_TO_GAME}"
export __GL_SHADER_DISK_CACHE=1
export mesa_glthread="true"
}
########################################################################
VULKAN_SET ()
{
if [ -e "${config_path}/dxvk" ]
then
echo "DXVK is enabled"
else
sh "${link}/winetricks" -q --force dxvk
echo "DXVK is enabled" > "${config_path}/dxvk"
fi
export PROTON_USE_WINED3D=0
export __GL_SHADER_DISK_CACHE=0
export DXVK_STATE_CACHE_PATH="${PATH_TO_GAME}"
export DXVK_STATE_CACHE=1
export mesa_glthread="false"
}
########################################################################
STOP_PORTWINE ()
{
echo " "
sleep 5
while [ $(pgrep wineserver)>'0' ]
do
sleep 5
done
if [ "${update_loc}" = "RUS" ]
then
export LC_COLLATE="${LC_COLLATE_old}"
export LC_CTYPE="${LC_CTYPE_old}"
export LC_ALL="${LC_ALL_old}"
fi
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH_OLD}"
export LD_PRELOAD="${LD_PRELOAD_OLD}"
export PATH="$PATH_OLD"
if [ -x "`which nvidia-settings 2>/dev/null`" ]
then
nvidia-settings -a [gpu:"${gpu}"]/GPUPowerMizerMode=0 > /dev/null
fi
ADD_IN_STOP_PORTWINE
rm -f "${PORT_WINE_PATH}"/0
rm -f "${link}"/0
exit 0
}