Skip to content

Commit a264dfe

Browse files
committed
fix: ensure wine install with correct file owner
Signed-off-by: ZHANG Yuntian <[email protected]>
1 parent e754cf0 commit a264dfe

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

src/usr/lib/rsetup/cli/steam.sh

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ EOF
3737
chmod +x /usr/local/bin/winetricks
3838
chmod +x /usr/local/bin/wineserver
3939
chmod +x /usr/local/bin/wine
40-
mkdir -p "${user_home}/.local/share/applications/"
41-
cat <<EOF > "${user_home}/.local/share/applications/wine-config.desktop"
40+
sudo -u "$(logname)" mkdir -p "${user_home}/.local/share/applications/"
41+
cat <<EOF | sudo -u "$(logname)" tee "${user_home}/.local/share/applications/wine-config.desktop"
4242
[Desktop Entry]
4343
Version=1.0
4444
Type=Application
@@ -49,7 +49,7 @@ box86 Exec=/usr/local/bin/wine winecfg
4949
Categories=Game;
5050
Terminal=false
5151
EOF
52-
cat <<EOF > "${user_home}/.local/share/applications/wine-desktop.desktop"
52+
cat <<EOF | sudo -u "$(logname)" tee "${user_home}/.local/share/applications/wine-desktop.desktop"
5353
[Desktop Entry]
5454
Version=1.0
5555
Type=Application
@@ -61,24 +61,21 @@ Categories=Game;
6161
Terminal=false
6262
EOF
6363

64-
mkdir "${user_home}/wine/"
65-
mkdir "${user_home}/wine/lib/"
64+
sudo -u "$(logname)" mkdir -p "${user_home}/wine/lib/"
6665
# cp libwine.so ${user_home}/wine/lib/
6766
# cp libwine.so.1 ${user_home}/wine/lib/
68-
pushd "${user_home}/wine/" || return 1
67+
local wine_pkg
68+
wine_pkg="$(sudo -u "$(logname)" mktemp -d)"
69+
pushd "$wine_pkg" || return 1
6970
latest_version="$(basename "$(curl -ILs -o /dev/null -w "%{url_effective}" https://github.com/Kron4ek/Wine-Builds/releases/latest)")"
70-
curl -Ls "https://github.com/Kron4ek/Wine-Builds/releases/download/$latest_version/wine-$latest_version-x86.tar.xz" > "wine-latest-x86.tar.xz"
71-
xz -d wine-latest-x86.tar.xz
72-
tar -xf wine-latest-x86.tar
71+
curl -Lso "wine-$latest_version-x86.tar.xz" "https://github.com/Kron4ek/Wine-Builds/releases/download/$latest_version/wine-$latest_version-x86.tar.xz"
72+
sudo -u "$(logname)" tar xf "wine-$latest_version-x86.tar.xz"
7373
popd || return 1
74-
pushd "${user_home}/wine/wine-$latest_version-x86/" || return 1
75-
cp -R ./* "${user_home}/wine"
74+
sudo -u "$(logname)" cp -R "$wine_pkg/wine-$latest_version-x86"/* "${user_home}/wine"
7675
# ln -s "${user_home}/wine/bin/wine" /usr/local/bin/wine
7776
# ln -s "${user_home}/wine/bin/winecfg" /usr/local/bin/winecfg
7877
# ln -s "${user_home}/wine/bin/wineserver" /usr/local/bin/wineserver
79-
# #try to chown using either sudo_user or pkexec_uid
80-
chown -R "${SUDO_USER:-${PKEXEC_UID}}" "${user_home}/wine"
81-
popd || return 1
78+
rm -rf "$wine_pkg"
8279
echo "Run wine winecfg to let wine configure itself"
8380
}
8481

0 commit comments

Comments
 (0)