add script for install with system-wide proton

This commit is contained in:
detiam 2023-11-01 14:43:50 +08:00
parent f121120c5a
commit 6a26defb93
No known key found for this signature in database
GPG key ID: 71C7925436B73ED0
4 changed files with 155 additions and 4 deletions

View file

@ -22,9 +22,11 @@ pkgbase = dxvk-gplasync-bin
source = https://raw.githubusercontent.com/doitsujin/dxvk/master/LICENSE
source = dxvk-gplasync-env.conf
source = setup_dxvk.sh
source = setup_dxvk_proton.sh
sha256sums = 1e1f6db95f4a7f02d372012f4a723a161d732a39b3b3efcf8159e03cdff2dc1e
sha256sums = 03ca4af84f5cd28cef3ed3f1ef4d17996992d35ccdbe82b29cc020ca02c16f3d
sha256sums = 2bce3bf5dc5a3c7312bbaae96daf82e0fe6c370e96017ce5a0c49f40901866e3
sha256sums = 0f688815530ab5e8cc89b9b45d9b1d66cd8cd5a7770fb8249339af555a30dfe7
sha256sums = 1bf20ca5901aaa43d10c794b28d22e3cf63a5c313c8e1e553da9d2780fd4ae85
pkgname = dxvk-gplasync-bin

3
.gitignore vendored
View file

@ -2,5 +2,6 @@
!.gitignore
!.SRCINFO
!setup_dxvk.sh
!setup_dxvk_proton.sh
!dxvk-gplasync-env.conf
!PKGBUILD
!PKGBUILD

View file

@ -17,14 +17,15 @@ options=(!strip !buildflags staticlibs)
source=("$url/-/raw/main/releases/dxvk-gplasync-v$pkgver-$pkgrel.tar.gz"
'https://raw.githubusercontent.com/doitsujin/dxvk/master/LICENSE'
'dxvk-gplasync-env.conf'
'setup_dxvk.sh')
setup_dxvk{,_proton}.sh)
sha256sums=('1e1f6db95f4a7f02d372012f4a723a161d732a39b3b3efcf8159e03cdff2dc1e'
'03ca4af84f5cd28cef3ed3f1ef4d17996992d35ccdbe82b29cc020ca02c16f3d'
'2bce3bf5dc5a3c7312bbaae96daf82e0fe6c370e96017ce5a0c49f40901866e3'
'0f688815530ab5e8cc89b9b45d9b1d66cd8cd5a7770fb8249339af555a30dfe7')
'0f688815530ab5e8cc89b9b45d9b1d66cd8cd5a7770fb8249339af555a30dfe7'
'1bf20ca5901aaa43d10c794b28d22e3cf63a5c313c8e1e553da9d2780fd4ae85')
package() {
cd "dxvk-gplasync-v$pkgver-$pkgrel"
cd "dxvk-gplasync-v$pkgver-$pkgrel" || exit 1
install -dm755 "$pkgdir/usr/share"
cp -dr --preserve=mode,timestamp . "$pkgdir/usr/share/dxvk"
@ -33,8 +34,10 @@ package() {
install -Dm644 "$srcdir/LICENSE" "$pkgdir/usr/share/licenses/dxvk-gplasync/LICENSE"
install -Dm 755 "$srcdir/setup_dxvk.sh" "$pkgdir/usr/share/dxvk/setup_dxvk.sh"
install -Dm 755 "$srcdir/setup_dxvk_proton.sh" "$pkgdir/usr/share/dxvk/setup_dxvk_proton.sh"
install -dm755 "$pkgdir/usr/bin"
ln -s /usr/share/dxvk/setup_dxvk.sh "$pkgdir/usr/bin/setup_dxvk"
ln -s /usr/share/dxvk/setup_dxvk_proton.sh "$pkgdir/usr/bin/setup_dxvk_proton"
install -dm755 "$pkgdir/etc/environment.d"
install -Dm644 "$srcdir/dxvk-gplasync-env.conf" "$pkgdir/etc/environment.d/dxvk-gplasync-env.conf"

145
setup_dxvk_proton.sh Normal file
View file

@ -0,0 +1,145 @@
#!/usr/bin/env bash
basedir="$(dirname "$(readlink -f "$0")")"
dlls=(dxgi.dll d3d9.dll d3d10core.dll d3d11.dll)
dxvk_lib32_path="$basedir/x32"
dxvk_lib64_path="$basedir/x64"
proton_dxvkpath=(/usr/share/steam/compatibilitytools.d/**/files/{lib,lib64}/wine/dxvk)
function pe64_or_not {
if ! exepa=$(realpath -es "$1" 2>/dev/null); then
echo "Path '$1' not exists"
exit 20
else
case $(file -L "$exepa") in
*PE32*x86-64*)
echo 64 ;;
*PE32*80386*)
return ;;
*)
echo "Not a supported executable"
exit 21 ;;
esac
fi
}
function InstallFile {
path=$1
file_name=$2
dstfile="$path/$file_name"
if [[ $(pe64_or_not "$dstfile") = 64 ]]; then
srcfile="$dxvk_lib64_path/$file_name"
else
srcfile="$dxvk_lib32_path/$file_name"
fi
if ! [ -f "$(realpath "${dstfile}")" ]; then
echo "${dstfile}: File not found. Skipping." >&2
return 1
fi
if ! [[ -f $(realpath "${dstfile}.old") ]]; then
mv "$dstfile" "${dstfile}.old"
echo "${dstfile}: Backed up."
else
rm -f "$dstfile"
fi
$file_cmd "$srcfile" "$dstfile"
}
function RestoreFile {
path=$1
file_name=$2
dstfile="$path/$file_name"
if ! [[ -f $(realpath "$dstfile") ]]; then
echo "${dstfile}: File not found. Skipping." >&2
return 1
elif ! [[ -f $(realpath "${dstfile}.old") ]]; then
echo "${dstfile}: File backup not found. Skipping." >&2
return 1
fi
mv -f "${dstfile}.old" "$dstfile"
echo "${dstfile}: Restored."
}
if [ "$(id -u)" != "0" ]; then
echo "You need run this script as root!"
exit 1
fi
# figure out which action to perform
action="$1"
case "$action" in
install)
;;
restore)
;;
*)
echo "Unrecognized action: $action"
echo "Usage: $0 [install|restore] [--symlink]"
exit 1
esac
# process arguments
shift
file_cmd="cp -v --reflink=auto"
while (($# > 0)); do
case "$1" in
"--symlink")
file_cmd="ln -s -v"
;;
esac
shift
done
for dir in "${proton_dxvkpath[@]}"; do
if [[ -d $dir ]]; then
dxvkpath+=("$dir")
fi
done
if [[ -s ${dxvkpath[1]} ]]; then
printf '%s\n' "${dxvkpath[@]}"
echo 'Do you wish to change the above dxvk?'
PS3="Enter a number: "
select yn in "Yes" "No"; do
case $yn in
Yes) echo; break;;
No ) exit;;
* ) echo -e '\nInvalid input'; exit 1;;
esac
done
else
echo 'No proton installed in "/usr/share/steam/compatibilitytools.d"'
exit 1
fi
install() {
file_name=$1
for path in "${dxvkpath[@]}"; do
InstallFile "$path" "$file_name"
done
}
restore() {
file_name=$1
for path in "${dxvkpath[@]}"; do
RestoreFile "$path" "$file_name"
done
}
for dll in "${dlls[@]}"; do
$action "$dll"
done