Skip to content

Commit

Permalink
Add maa-wpf wine experimentally
Browse files Browse the repository at this point in the history
  • Loading branch information
horror-proton committed Jul 8, 2024
1 parent 9bd5ca1 commit 62c8902
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 1 deletion.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

*/*.pkg.*
*/*.tar.*
*/*.sh

*/*.sig
*/*.sign
Expand Down
71 changes: 71 additions & 0 deletions maa-wpf-gui-wine/PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Maintainer: Your Name <[email protected]>
# shellcheck disable=SC2164
pkgname=maa-wpf-gui-wine
pkgver=0
pkgrel=1
pkgdesc=""
arch=("x86_64")
url="https://github.com/MaaAssistantArknights/MaaAssistantArknights"
license=('AGPL-3.0-only')
depends=(cmake wine)
makedepends=(
# dotnet-sdk-8.0 # Microsoft.NET.Sdk.WindowsDesktop missing
)
checkdepends=()
optdepends=()
provides=()
conflicts=()
replaces=()
backup=()
options=()
install=
changelog=
source=("$url/archive/pull/8960/merge.tar.gz"
"https://download.visualstudio.microsoft.com/download/pr/bf435b42-3f28-45db-a666-6e95c4faefe7/23e0b703124347b51f53faf64c829287/dotnet-sdk-8.0.204-win-x64.zip"
"https://download.visualstudio.microsoft.com/download/pr/0a1b3cbd-b4af-4d0d-9ed7-0054f0e200b4/4bcc533c66379caaa91770236667aacb/dotnet-sdk-8.0.204-linux-x64.tar.gz"
)
noextract=("${source[-1]##*/}" "${source[-2]##*/}")
sha256sums=('SKIP' 'SKIP' 'SKIP')
validpgpkeys=()

prepare() {
mkdir -p dotnet
bsdtar -xf dotnet-sdk-8.0.204-win-x64.zip -C dotnet
bsdtar -xf dotnet-sdk-8.0.204-linux-x64.tar.gz -C dotnet
# cp -r /usr/share/dotnet .
cd MaaAssistantArknights-pull-8960-merge
cd src/MaaWpfGui
sed -i -e 's/UpdateCheck, bool\.TrueString/UpdateCheck, bool\.FalseString/g' ViewModels/UI/SettingsViewModel.cs
}

_args=(
--runtime win-x64
-p "Platform=x64;Configuration=RelWithDebInfo"
)

_dotnet() {
export NUGET_PACKAGES="${srcdir?}"/.nuget/packages
export DOTNET_ROOT="$srcdir"/dotnet
"$DOTNET_ROOT"/dotnet "$@"
}

build() {
cd MaaAssistantArknights-pull-8960-merge

_dotnet build src/MaaWpfGui/MaaWpfGui.csproj "${_args[@]}"

pushd src/MaaWineBridge
cmake -B "$srcdir"/build -DCMAKE_TOOLCHAIN_FILE=winegcc.cmake
cmake --build "$srcdir"/build --verbose
popd
}

package() {
cd MaaAssistantArknights-pull-8960-merge

_dotnet publish src/MaaWpfGui/MaaWpfGui.csproj "${_args[@]}" \
-o "${pkgdir?}"/opt/maa-wpf-gui-wine

cp -v "$srcdir"/build/MaaCore.dll "${pkgdir?}"/opt/maa-wpf-gui-wine/MaaCore.dll
exit 1
}
48 changes: 48 additions & 0 deletions maa-wpf-gui-wine/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env bash
set -e

if test -z "$MAA_WINEPREFIX"; then
export WINEPREFIX=${XDG_DATA_HOME:-$HOME/.local/share/maa-wpf-gui-wine/wineprefix}
else
export WINEPREFIX="${MAA_WINEPREFIX?}"
fi

export WINEPREFIX=/tmp/maa/wineprefix

export MAA_WPF_FILES=/tmp/makepkg/maa-wpf-gui-wine/pkg/opt/maa-wpf-gui-wine
export MAA_WPF_ROOT=/tmp/maa/MAA
export WINE_INSTALL=/usr

runtime_url='https://download.visualstudio.microsoft.com/download/pr/c1d08a81-6e65-4065-b606-ed1127a954d3/14fe55b8a73ebba2b05432b162ab3aa8/windowsdesktop-runtime-8.0.4-win-x64.exe'
runtime_sha512sum='8a0b1ab3a774c33f46cd042783cf785c33f2d9e0bdeee4ff8bf96cfa90a2101a5711231840ef93eab101409e7f3f3770d86e1a55bd52709af08d1a6c908cc194'

bootstrap_wineprefix() {
"$WINE_INSTALL"/bin/wineboot -u
}

install_runtime() {
#local tmpdir="$(mktemp --directory)"
local tmpdir=/tmp/installer
mkdir -p "$tmpdir"
pushd "$tmpdir"
wget "$runtime_url"
if ! wine ./windowsdesktop-runtime-*-win-x64.exe /install /quiet; then
popd
rm -rf "$tmpdir"
exit 1
fi
popd
rm -rf "$tmpdir"
}

start() {
mkdir -p "$WINEPREFIX"
if test ! -f "$WINEPREFIX"/.update-timestamp; then
bootstrap_wineprefix
fi
if test ! -d "$WINEPREFIX"'/drive_c/Program Files/dotnet/shared/Microsoft.WindowsDesktop.App'; then
install_runtime
fi
}

start

0 comments on commit 62c8902

Please sign in to comment.