summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: c4c8f354caaced744598f5dabbd9387d2fb49f99 (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
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# Maintainer: xiota / aur.chaotic.cx
# Contributor: Benjamin Landis <bmlandis2010@gmail.com>

# options
if [ "${_srcinfo::1}" == "t" ] ; then
  : ${_autoupdate:=false}
elif [ -z "$_pkgver" ] ; then
  : ${_autoupdate:=true}
else
  : ${_autoupdate:=false}
fi

: ${_build_git:=true}

[[ "${_build_git::1}" == "t" ]] && _pkgtype+="-git"

# basic info
_gitname="mpv"
_pkgname="$_gitname-vapoursynth"
pkgname="$_pkgname${_pkgtype:-}"
pkgver=0.37.0.r114.g17be6e1990
pkgrel=1
pkgdesc='a free, open source, and cross-platform media player'
url='https://github.com/mpv-player/mpv'
arch=('i686' 'x86_64' 'armv6h' 'armv7h' 'aarch64')
license=('GPL-2.0-or-later')

# main package
_main_package() {
  depends=(
    'libarchive'
    'libcdio-paranoia'
    'libdvdnav'
    'libxkbcommon'
    'libxpresent'
    'libxrandr'
    'libxss'
    'luajit'
    'mujs'
    'rubberband'
    'uchardet'
    'vapoursynth'

    ## implicit
    #alsa-lib
    #bash
    #gcc-libs
    #glibc
    #hicolor-icon-theme
    #lcms2
    #libass
    #libbluray
    #libcdio
    #libdrm
    #libglvnd
    #libjpeg-turbo
    #libpipewire
    #libpulse
    #libva
    #libvdpau
    #libx11
    #libxext
    #libxv
    #mesa
    #pipewire-jack
    #vulkan-icd-loader
    #wayland
    #zimg
    #zlib
  )
  makedepends=(
    'ffnvcodec-headers'
    'git'
    'ladspa'
    'meson'
    'python-docutils'
    'vulkan-headers'
    'wayland-protocols'
  )
  optdepends=(
    'yt-dlp: for video-sharing websites playback'
    'youtube-dl: for video-sharing websites playback'
  )

  provides=("mpv=${pkgver%%.r*}")
  conflicts=('mpv')

  options=('!emptydirs')
  validpgpkeys=('145077D82501AA20152CACCE8D769208D5E31419') # sfan5 <sfan5@live.de>

  if [ x"$pkgname" == x"$_pkgname" ] ; then
    _main_stable
  else
    _main_git
  fi
}

# stable package
_main_stable() {
  : ${_pkgver:=${pkgver%%.r*}}

  depends+=(
    'ffmpeg'
    'libplacebo'
  )

  _pkgsrc="$_gitname"
  source=("$_pkgsrc"::"git+$url.git#tag=v$_pkgver")
  sha256sums=('SKIP')

  prepare() {
    cd "$_pkgsrc"

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

    local _tag=$(git tag | grep -Ev '^.*[A-Za-z]{2}.*$' | sort -V | tail -1)
    _pkgver="${_tag#v}"

    if [[ "${_pkgver:?}" != "${pkgver%%.r*}" ]] ; then
      git checkout -f "$_tag"
      git describe --long --tags
    fi
  }

  pkgver() {
    echo "${_pkgver:?}"
  }
}

# git package
_main_git() {
  depends+=(
    'ffmpeg-git'
    'libplacebo-git'
  )

  _pkgsrc="$_gitname"
  source=("$_pkgsrc"::"git+$url.git")
  sha256sums=('SKIP')

  pkgver() (
    cd "$_pkgsrc"
    local _pkgver=$(
      git describe --long --tags --exclude='*[a-zA-Z][a-zA-Z]*' 2>/dev/null \
        | sed -E 's/^v//;s/([^-]*-g)/r\1/;s/-/./g'
    )

    echo "${_pkgver:?}"
  )
}

# common functions
build() {
  local _meson_options=(
    --auto-features auto

    -Dlibmpv=true

    -Dcaca=disabled
    -Dcdda=enabled
    -Ddvbin=enabled
    -Ddvdnav=enabled
    -Dlibarchive=enabled

    -Dbuild-date=false
    -Dvapoursynth=enabled
  )

  arch-meson "$_pkgsrc" build "${_meson_options[@]}"

  meson compile -C build
}

check() {
  meson test -C build || true
}

package() {
  provides+=('libmpv.so')

  meson install -C build --destdir "${pkgdir:?}"

  # delete private entries only required for static linking
  sed -i -e '/Requires.private/d' -e '/Libs.private/d' "${pkgdir:?}/usr/lib/pkgconfig/mpv.pc"

  install -Dm0644 "$_pkgsrc/DOCS"/{encoding.rst,tech-overview.txt} \
    -t "${pkgdir:?}/usr/share/doc/mpv"

  install -Dm0644 "$_pkgsrc/TOOLS/lua"/* \
    -t "${pkgdir:?}/usr/share/mpv/scripts"
}

# execute
_main_package