-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproton-ge-update.sh
executable file
·179 lines (176 loc) · 6.71 KB
/
proton-ge-update.sh
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
#!/bin/bash
#shellcheck disable=SC2164
#Downloads the latest Proton-GE release and extracts adds it to Steam and Lutris
#This code is made under the assumptions that Proton-GE's .tar.gz structure and naming scheme (along with GitHub) will stay the same
#So use it at your own risk (but, I mean, what's the worst that's gonna happen)
uDir="$(cd && pwd)"
sDir="${uDir}/.steam/root/compatibilitytools.d/"
lDir="${uDir}/.local/share/lutris/runners/wine/"
#I realized after finishing that that this could have been done better - no matter
#Cleanup - cleans up the temporary directories, but even if the user ^Cs the script
cleanup()
{
printf "Cleaning up..."
if [[ -d "${uDir}/.tmp.2" ]]
then
rm -rf "${uDir}/.tmp.2"
elif [[ -d "${uDir}/.tmp" ]]
then
rm -rf "${uDir}/.tmp"
fi
echo "done"
exit
}
trap "cleanup" EXIT
if [[ -d "${uDir}/.tmp" ]]
then
mkdir "${uDir}/.tmp.2"
cd "${uDir}/.tmp.2"
else
mkdir "${uDir}/.tmp"
cd "${uDir}/.tmp"
fi
#There's probably a way to do this (get the version) properly with the GitHub API, but whatever
if [[ ! $1 ]]
then
#This just gets the latest version, pre-release or not
version="$(curl -s -L https://github.com/GloriousEggroll/proton-ge-custom/releases/ | grep Proton | grep Released | head -1 | awk -F'>' '{print $2}' | awk -F' ' '{print $1}')"
#Please note that there are certain cases where this doesn't work, such as with Proton-GE release v7.2-GE-3-test-2
#This is because the version used in the .tar.gz's filename doesn't match, and actually is v7.2-GE-3-test-3, and apparently 7-14.
if [ "${version}" == "" ]
then
echo "Latest version could not be fetched. Please try running this script again with --alt"
exit
else
echo "Latest version: ${version}"
fi
elif [[ "$1" == "-a" ]] || [[ "$1" == "--alt" ]]
then
#Alternative way:
version="$(curl -s https://api.github.com/repos/GloriousEggroll/proton-ge-custom/releases | grep tag_name | head -1 | awk -F': "' '{print $2}' | awk -F'"' '{print $1}')"
#Alternatives to the alternative:
#Original alternative method:
#version="$(curl -s -L https://github.com/GloriousEggroll/proton-ge-custom/releases/latest | grep Proton | awk -Ftag/ '{print $2}' | awk -F'"' '{print $1}' | grep Proton | head -1)"
#Using GitHub API and some magic sed from gist lukechilds/a83e1d7127b78fef38c2914c4ececc3c:
#version="$(curl "https://api.github.com/repos/GloriousEggroll/proton-ge-custom/releases" | grep "tag_name" | sed -E 's/.*"([^"]+)".*/\1/' | head -1)"
echo "Latest version: ${version}"
elif [[ "$1" == "-l" || "$1" == "--list" ]]
then
if [[ "$(which tree)" == "tree not found" ]]
then
echo "tree needs to be installed for this feature"
else
echo "Versions of Proton-GE installed for Steam:"
tree "${sDir}" -L 1 -i | grep Proton | grep GE
echo "Versions of Proton-GE installed for Lutris:"
tree "${lDir}" -L 1 -i | grep Proton | grep GE
fi
exit
elif [[ "$1" == "-r" || "$1" == "--remove" ]]
then
#The if statements don't work if the 2>&1 is altered or removed
#I spent way too long finding a solution for that
if [[ "$(chmod 0755 -R ${sDir}/$2 2>&1 | head -c20)" == "chmod: cannot access" ]]
then
echo "$2 doesn't appear to be installed for Steam"
else
rm -r "${sDir}/$2"
echo "$2 successfully removed for Steam"
fi
if [[ "$(chmod 0755 -R ${lDir}/$2 2>&1 | head -c20)" == "chmod: cannot access" ]]
then
echo "$2 doesn't appear to be installed for Lutris"
else
rm -r "${lDir}/$2"
echo "$2 successfully removed for Lutris"
fi
exit
#The following is hacked in after I considered proton-update.sh 'complete'. That's why it re-uses code, because I never made this to be perfect, I made it to automate a 5-minute task
elif [[ "$1" == "-d" || "$1" == "--dxvk" ]]
then
version="$(curl -s -L https://github.com/doitsujin/dxvk/releases/ | grep Version | head -1 | awk -F'>' '{print $2}' | awk -F'<' '{print $1}' | awk -F' ' '{print $2}')"
echo "Latest version: ${version}"
if [[ ! -d "${uDir}/.wine" ]]
then
echo "Wineprefix not found for the current user"
exit 1
fi
echo "Starting download..."
curl -O -L "https://github.com/doitsujin/dxvk/releases/download/v${version}/dxvk-${version}.tar.gz"
tar -xf "dxvk-${version}.tar.gz" -C ./ || exit 1
echo "Installing ${version}"
mv dxvk-${version}/x32/*.dll "${uDir}/.wine/drive_c/windows/syswow64/"
mv dxvk-${version}/x64/*.dll "${uDir}/.wine/drive_c/windows/system32/"
exit 0
elif [[ "$(echo $1 | head -c1)" == "-" ]]
then
echo "$1 is not an understood argument"
echo "Understood arguments are as follows:"
echo "{version} Installs a specific version of Proton-GE"
echo "-a/--alt Fetches (alternative method) and installs the latest version of Proton-GE"
echo "-l/--list Lists installed versions of Proton-GE"
echo "-r/--remove {version} Removes a specified installed version of Proton-GE"
echo "-d/--dxvk Installs the latest version of DXVK, doesn't touch wine overrides"
exit
else
version="$1"
echo "Version: ${version}"
fi
#Allow older versions to still be used:
if [[ "$(echo ${version} | head -c2)" == "GE" ]]
then
proton="${version}"
else
proton="Proton-${version}"
fi
#Check if $version of Proton-GE is already installed before downloading:
#If it's (1) installed for Steam and Lutris OR (2) installed for Steam and Lutris doesn't exist OR (3) is installed for Lutris and Steam doesn't exist
if [[ -d "${sDir}/${proton}" && -d "${lDir}/${proton}" ]] || [[ -d "${sDir}/${proton}" && ! -d "${uDir}/.local/share/lutris" ]] || [[ -d "${lDir}/${proton}" && ! -d "${uDir}/.steam/root" ]]
then
echo "Already installed: ${version}"
elif [[ ! -d "${uDir}/.steam/root" ]] && [[ ! -d "${uDir}/.local/share/lutris" ]]
then
echo "Neither Steam nor Lutris appear to be installed under the current user's account"
else
echo "Starting download..."
curl -O -L "https://github.com/GloriousEggroll/proton-ge-custom/releases/download/${version}/${proton}.tar.gz"
if [[ -d "${uDir}/.steam/root" ]]
then
if [[ ! -d "${sDir}" ]]
then
mkdir "${sDir}"
fi
if [[ -d "${sDir}/${proton}" ]]
then
echo "${proton} is already present for Steam"
else
echo "Installing ${proton} for Steam"
tar -xf "${proton}.tar.gz" -C "${sDir}"
fi
else
echo "Steam does not appear to be installed"
fi
if [[ -d "${uDir}/.local/share/lutris" ]]
then
if [[ ! -d "${uDir}/.local/share/lutris/runners" ]]
then
mkdir "${uDir}/.local/share/lutris/runners"
mkdir "${lDir}" #${uDir}/.local/share/lutris/runners/wine
elif [[ ! -d "${lDir}" ]]
then
mkdir "${lDir}"
fi
if [[ -d "${lDir}/${proton}" ]]
then
echo "${proton} is already present for Lutris"
else
echo "Installing ${proton} for Lutris"
tar -xf "${proton}.tar.gz" -C "${lDir}"
echo "Patching ${proton} for Lutris"
cd "${lDir}/${proton}"
mv files/* ./
fi
else
echo "Lutris does not appear to be installed"
fi
fi