summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 00ba3ad7f7034db600be3cefe6d2d1e7e5c34b1c (plain)
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
# Maintainer: username227 < gfrank227 [at] gmail [dot] com >
# Contributor: HurricanePootis <hurricanepootis@protonmail.com>
# Contributor: Marco Rubin <marco.rubin@protonmail.com>

## options
if [ -z "$_srcinfo" ] && [ -z "$_pkgver" ]; then
  : ${_autoupdate:=true}
fi

: ${_install_path:=usr/lib}

## basic info
_pkgname="ryujinx-git"
pkgname="$_pkgname"
pkgver=r3579.d404a8b05
pkgrel=1
pkgdesc="Experimental Nintendo Switch Emulator written in C#"
url="https://github.com/GreemDev/Ryujinx"
license=('MIT')
arch=('x86_64')

depends=(
  'gcc-libs'
  'zlib'
)
makedepends=(
  'desktop-file-utils'
  'dotnet-sdk-bin' # aur/dotnet-core-bin
  'git'
)

options=('!strip' '!debug')

_source_ryujinx() {
  _pkgsrc="Ryujinx"
  _pkgext="tar.gz"
  source=("git+https://github.com/GreemDev/Ryujinx")
  sha256sums=('SKIP')
}

pkgver() {
	cd "$srcdir/Ryujinx"
	printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

build() (
  export HOME="$SRCDEST/nuget-home"
  export DOTNET_CLI_TELEMETRY_OPTOUT=1

  local _args=(
    -c Release
    -p:DebugType=none
    -o build
  )
  dotnet build "${_args[@]}" "$_pkgsrc/src/Ryujinx"


  echo "Shutting down dotnet build server in background."
  (timeout -k 45 30 dotnet build-server shutdown) > /dev/null 2>&1 &
)

package() {
  # program
  install -dm755 "$pkgdir/$_install_path/ryujinx"
  install -dm755 "$pkgdir/$_install_path/Ryujinx.Headless.SDL2"
  cp -a --update=none --reflink=auto $srcdir/build/* "$pkgdir/$_install_path/ryujinx/"

  # symlinks
  install -dm755 "$pkgdir/usr/bin"
  ln -s "/$_install_path/ryujinx/Ryujinx" "$pkgdir/usr/bin/ryujinx"

  # .desktop
  install -Dm644 "$_pkgsrc"/distribution/linux/Ryujinx.desktop "$pkgdir/usr/share/applications/ryujinx.desktop"

  # icon
  install -Dm644 "$_pkgsrc"/distribution/misc/Logo.svg "$pkgdir/usr/share/pixmaps/ryujinx.svg"

  # mimetype
  install -Dm644 "$_pkgsrc"/distribution/linux/mime/Ryujinx.xml "$pkgdir/usr/share/mime/packages/ryujinx.xml"

  # license
  install -Dm644 "$_pkgsrc"/LICENSE.txt "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  # fix permissions
  find "$pkgdir" -type d -exec chmod 755 {} \;
  find "$pkgdir" -type f -exec chmod 644 {} \;
  chmod 755 "$pkgdir/$_install_path/ryujinx/Ryujinx"
  chmod 755 "$pkgdir/$_install_path/ryujinx/Ryujinx.sh"

  # fix desktop file
  desktop-file-edit --set-key="Exec" --set-value="ryujinx %f" "$pkgdir/usr/share/applications/ryujinx.desktop"
  desktop-file-edit --set-icon="ryujinx" "$pkgdir/usr/share/applications/ryujinx.desktop"
}

_update_version() {
  : ${_pkgver:=$pkgver}

  if [[ "${_autoupdate::1}" != "t" ]]; then
    return
  fi

  local _response _tag _pkgver_new
  _response=$(curl -Ssf "$url/releases")
  _tag=$(
    printf '%s' "$_response" \
      | grep -E '/tree/([0-9\.]+)"' \
      | sed -E 's&^.*/tree/([0-9\.]+)".*$&\1&' \
      | sort -rV | head -1
  )
  _pkgver_new="${_tag#v}"

  if [ "$_pkgver" != "${_pkgver_new:?}" ]; then
    _pkgver="${_pkgver_new:?}"
  fi
}

_update_version
_source_ryujinx