-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathportproton
executable file
·210 lines (204 loc) · 8.85 KB
/
portproton
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
#!/usr/bin/env bash
# Author: Mikhail Tergoev (linux-gaming.ru)
# Adapted for Flatpak: Boris Yumankulov (Boria138)
# License MIT
########################################################################
unset PW_AUTOPLAY PW_SET_LANG PW_SILENT_INSTALL
export port_ver=1.7.1
########################################################################
cd "$(dirname "$(readlink -f "$0")")"
script_path="$(pwd)"
def_path="${HOME}/PortProton"
########################################################################
fatal () {
echo -e "\n${1}\n"
exit 1
}
########################################################################
if [[ "$(id -u)" == "0" ]] ; then
fatal "Do not run the script from the superuser!"
fi
########################################################################
if grep -i "SteamOS" /etc/os-release &>/dev/null
then fatal "You will need to install flatpak version of PortProton: appstream://ru.linux_gaming.PortProton\n\nhttps://flathub.org/apps/ru.linux_gaming.PortProton\n"
elif ! command -v yad &>/dev/null
then fatal "You will need to install \"yad\" to your system!"
else yad_gui="yad --window-icon=ru.linux_gaming.PortProton --borders=10 --center --text-align=center"
fi
########################################################################
check_flatpak () {
if [[ ! -z "$FLATPAK_IN_USE" ]]
then [[ "$FLATPAK_IN_USE" == 1 ]] && return 0 || return 1
fi
if grep -i "flatpak" /etc/os-release &>/dev/null ; then
export FLATPAK_IN_USE=1
return 0
else
export FLATPAK_IN_USE=0
return 1
fi
}
########################################################################
case "$LANG" in
ru_RU*)
PW_SET_LANG="Russian"
loc_use_flatpak="Не используйте нативную и flatpak версии PortProton в одной системе!"
loc_install="Установка PortProton"
loc_choose_path="Выберите путь для установки (обновления) PortProton,\nили оставьте его по умолчанию.\n\nВнимание:\nУстанавливать необходимо на файловую систему Linux (ext4, btrfs и прочие)."
loc_set="Выбор"
loc_path="Путь:"
loc_other_path="Другой путь..."
loc_set_path="Выберите путь..."
;;
es_ES*)
PW_SET_LANG="Spanish"
loc_use_flatpak="¡No utilice flatpak y la versión nativa de PortProton al mismo tiempo!"
loc_install="Instalar PortProton"
loc_choose_path="Selecciona la ruta de instalación (actualización) PortProton,\no déjalo en el valor predeterminado. \n\nAtención:\nInstala en un sistema de archivos Linux (ext4, btrfs, etc.)."
loc_set="Elección"
loc_path="Camino"
loc_other_path="Otro camino..."
loc_set_path="Selecciona el camino..."
;;
*)
PW_SET_LANG="English"
loc_use_flatpak="\nDo not use flatpak and the native version of PortProton at the same time!"
loc_install="Install PortProton"
loc_choose_path="Select the installation path (update) PortProton,\nor leave it in default. \n\nAttention:\nInstall on a Linux file system (ext4, btrfs, etc.)"
loc_set="Set"
loc_path="Path:"
loc_other_path="Other path..."
loc_set_path="Select the path..."
;;
esac
########################################################################
if command -v flatpak &>/dev/null \
&& flatpak list | grep "PortProton" &>/dev/null
then
$yad_gui --error --title="PortProton" --text "$loc_use_flatpak" 2>/dev/null
fatal "Do not use flatpak and the native version of PortProton at the same time!"
fi
########################################################################
[[ -z "${XDG_DATA_HOME}" ]] && export XDG_DATA_HOME="$HOME/.local/share"
if ! check_flatpak ; then
PP_CONFIG_FILE="${HOME}/.config/PortProton.conf"
if [[ -f "${XDG_DATA_HOME}/PortWINE/PortProton/data/scripts/start.sh" ]] ; then
echo "${XDG_DATA_HOME}/PortWINE/PortProton" > "${PP_CONFIG_FILE}"
elif [[ -f "${HOME}/PortWINE/PortProton/data/scripts/start.sh" ]] ; then
echo "${HOME}/PortWINE/PortProton" > "${PP_CONFIG_FILE}"
elif [[ -f "${HOME}/PortProton/data/scripts/start.sh" ]] ; then
echo "${HOME}/PortProton" > "${PP_CONFIG_FILE}"
fi
if [[ "$script_path" == "/usr/bin" ]] \
&& [[ -f "${PP_CONFIG_FILE}" ]]
then
export PORT_WINE_PATH="$(cat "${PP_CONFIG_FILE}" | head -n 1)"
if [[ -f "${PORT_WINE_PATH}/data/scripts/start.sh" ]] ; then
if [[ "$1" == "--repair" ]] ; then
export PORT_WINE_DATA_PATH="${PORT_WINE_PATH}/data"
else
echo "${port_ver}" > "${PORT_WINE_PATH}/data/tmp/PortProton_ver"
/usr/bin/env bash "${PORT_WINE_PATH}/data/scripts/start.sh" "$@"
exit 0
fi
else
rm -f "${PP_CONFIG_FILE}"
fi
fi
else
if [ "$script_path" == "/app/bin" ] ; then
export PORT_WINE_PATH="${XDG_DATA_HOME}"
if [ -f "${PORT_WINE_PATH}/scripts/start.sh" ] ; then
if [[ "$1" == "--repair" ]] ; then
export PORT_WINE_DATA_PATH="${XDG_DATA_HOME}"
else
echo "${port_ver}" > "${PORT_WINE_PATH}/tmp/PortProton_ver"
/usr/bin/env bash "${PORT_WINE_PATH}/scripts/start.sh" "$@"
exit 0
fi
fi
fi
fi
########################################################################
export PW_AUTOPLAY=1
export INSTALLING_PORT=1
########################################################################
if [[ "$1" != "--repair" ]] ; then
if ! check_flatpak ; then
inst1=$($yad_gui --title "$loc_install" --text "$loc_choose_path" --list --radiolist \
--width=600 --height=200 --column="$loc_set" --column "$loc_path" \
TRUE "${def_path}" \
FALSE "$loc_other_path")
[ "$?" != "0" ] && exit 1
inst1="$(echo $inst1 | awk -F'|' '{print $2}')"
case $inst1 in
"${def_path}")
D_PATH="${def_path}" ;;
"$loc_other_path")
D_PATH="$($yad_gui --file --directory --title="$loc_set_path" --width=800 --height=800)" ;;
esac
[[ -z "${D_PATH}" ]] && fatal
echo "${D_PATH}" | grep -i "PortProton" 2>/dev/null || D_PATH="${D_PATH}/PortProton"
export PORT_WINE_DATA_PATH="${D_PATH}/data"
export PORT_WINE_PATH="${D_PATH}"
if [[ ! -z "$PORT_WINE_PATH" ]]
then echo "${PORT_WINE_PATH}" > "${PP_CONFIG_FILE}"
fi
else
export PORT_WINE_DATA_PATH="${XDG_DATA_HOME}"
fi
elif [[ -f "$PORT_WINE_PATH/data/user.conf" ]] ; then
sed -i 's/="devel"/="master"/g' "$PORT_WINE_PATH/data/user.conf"
fi
if [[ ! -d "${PORT_WINE_DATA_PATH}" ]] ; then
mkdir -p "$PORT_WINE_DATA_PATH" || fatal "Cannot create a directory: $PORT_WINE_PATH"
elif [[ "$1" == "--repair" ]] ; then
rm -f "${PORT_WINE_DATA_PATH}/scripts/"* 2>/dev/null
else
rm -fr "${PORT_WINE_DATA_PATH}/tmp"
rm -f "${PORT_WINE_DATA_PATH}/scripts/"* 2>/dev/null
fi
########################################################################
mkdir -p "${PORT_WINE_DATA_PATH}/tmp"
echo "${port_ver}" > "${PORT_WINE_DATA_PATH}/tmp/PortProton_ver"
case "${PW_SET_LANG}" in
"Russian") echo "ru" > "${PORT_WINE_DATA_PATH}/tmp/PortProton_loc" ;;
"Spanish") echo "es" > "${PORT_WINE_DATA_PATH}/tmp/PortProton_loc" ;;
"English") echo "en" > "${PORT_WINE_DATA_PATH}/tmp/PortProton_loc" ;;
esac
########################################################################
export PORT_WINE_TMP_PATH="${PORT_WINE_DATA_PATH}/tmp"
if ! check_flatpak
then cd "${D_PATH}"
else cd "${PORT_WINE_DATA_PATH}"
fi
$yad_gui --progress --pulsate --title="$loc_install" --text="$loc_install" \
--close-on-unfocus --no-buttons --skip-taskbar --width=500 &>/dev/null &
sleep 1
echo -e "\nTry download scripts from gitlab.eterfund.ru..."
if ! curl -f -# -A "Mozilla/5.0 (compatible; Konqueror/2.1.1; X11)" -H 'Cache-Control: no-cache, no-store' -H 'Pragma: no-cache' \
-L "https://gitlab.eterfund.ru/Castro-Fidel/PortWINE/-/archive/master/PortWINE-master.tar.gz" \
-o "${PORT_WINE_TMP_PATH}/PortWINE-master.tar.gz"
then
echo -e "\nError.\nTry download scripts from github.com..."
curl -f -# -A "Mozilla/5.0 (compatible; Konqueror/2.1.1; X11)" -H 'Cache-Control: no-cache, no-store' -H 'Pragma: no-cache' \
-L "https://github.com/Castro-Fidel/PortWINE/archive/refs/heads/master.tar.gz" \
-o "${PORT_WINE_TMP_PATH}/PortWINE-master.tar.gz"
[ "$?" != "0" ] && fatal "Critical error during file download!"
fi
echo "Try unpacking scripts..."
tar -xvzf "${PORT_WINE_TMP_PATH}/PortWINE-master.tar.gz" -C "${PORT_WINE_TMP_PATH}"
if [ "$?" = "0" ] ; then
[ ! -d "${PORT_WINE_DATA_PATH}" ] && mkdir "${PORT_WINE_DATA_PATH}"
cp -fr "${PORT_WINE_TMP_PATH}/PortWINE-master/data_from_portwine/"* "${PORT_WINE_DATA_PATH}"
rm -f "${PORT_WINE_TMP_PATH}/PortWINE-master.tar.gz"
rm -fr "${PORT_WINE_TMP_PATH}/PortWINE-master/"
export scripts_current_ver=$(cat "${PORT_WINE_DATA_PATH}/scripts/var" | grep SCRIPTS_NEXT_VERSION | awk -F "=" '{print $2}')
echo "${scripts_current_ver}" > "${PORT_WINE_TMP_PATH}/scripts_ver"
else
rm -f "${PORT_WINE_TMP_PATH}/PortWINE-master.tar.gz"
[ "$?" != "0" ] && fatal "Critical error during file unpacking!"
fi
########################################################################
cd "${PORT_WINE_DATA_PATH}/scripts"
/usr/bin/env bash "${PORT_WINE_DATA_PATH}/scripts/setup.sh" && exit 0