summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: ff8f2125ebce37972eb79759c83b5eb4313d1802 (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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
# Maintainer:

## useful links:
# https://gitlab.winehq.org/wine/wine
# https://gitlab.winehq.org/wine/wine-staging

# options
: ${_build_staging:=true}
: ${_build_wow64:=true}
: ${_build_git:=true}

unset _pkgtype
[[ "${_build_staging::1}" == "t" ]] && _pkgtype+="-staging"
[[ "${_build_wow64::1}" == "t" ]] && _pkgtype+="-wow64"
[[ "${_build_git::1}" == "t" ]] && _pkgtype+="-git"

# basic info
_pkgname="wine"
pkgname="$_pkgname${_pkgtype:-}"
pkgver=9.3.r194.gc1b8db0c
pkgrel=1
pkgdesc="A compatibility layer for running Windows programs"
url="https://gitlab.winehq.org/wine/wine"
license=('LGPL-2.1-or-later')
arch=(x86_64)

# main package
_main_package() {
  depends=(
    alsa-lib              #lib32-alsa-lib
    fontconfig            #lib32-fontconfig
    freetype2             #lib32-freetype2
    gettext               #lib32-gettext
    gst-plugins-base-libs #lib32-gst-plugins-base-libs
    libpulse              #lib32-libpulse
    libxcomposite         #lib32-libxcomposite
    libxcursor            #lib32-libxcursor
    libxi                 #lib32-libxi
    libxinerama           #lib32-libxinerama
    libxrandr             #lib32-libxrandr
    opencl-icd-loader     #lib32-opencl-icd-loader
    pcsclite              #lib32-pcsclite
    sdl2                  #lib32-sdl2
    v4l-utils             #lib32-v4l-utils
    desktop-file-utils
    libgphoto2

    # with-wayland
    libxkbcommon
    wayland
  )
  local _spacehogs=(
    samba
    sane
  )
  makedepends=(
    libcups               #lib32-libcups
    libxxf86vm            #lib32-libxxf86vm
    mesa                  #lib32-mesa
    mesa-libgl            #lib32-mesa-libgl
    vulkan-icd-loader     #lib32-vulkan-icd-loader
    autoconf
    bison
    flex
    git
    mingw-w64-gcc
    opencl-headers
    perl
    vulkan-headers

    "${_spacehogs[@]}"
  )
  optdepends=(
    alsa-plugins          #lib32-alsa-plugins
    cups
    dosbox

    "${_spacehogs[@]}"
  )

  options=(staticlibs !lto)

  backup=("usr/lib/binfmt.d/wine.conf")

  # provides/depends
  _pkgdep="$pkgname"
  if [[ "$_pkgdep" =~ .*staging-wow64.* ]] ; then
    provides+=("wine-wow64=${pkgver%%.r*}")
    conflicts+=("wine-wow64")
  fi
  while [[ "$_pkgdep" =~ .*-.* ]] ; do
    _pkgdep="${_pkgdep%-*}"
    provides+=("${_pkgdep}=${pkgver%%.r*}")
    conflicts+=("${_pkgdep}")
  done

  # sources
  if [[ "${_build_git::1}" != "t" ]] ; then
    _main_stable
  else
    _main_git
  fi

  if [[ "${_build_staging::1}" == "t" ]] ; then
    source+=("git+https://gitlab.winehq.org/wine/wine-staging.git")
    sha256sums+=('SKIP')

    _prepare_staging() {
      pushd "$_pkgsrc"

      # apply wine-staging patchset
      "$srcdir/wine-staging/staging/patchinstall.py" --all "${_staging_options[@]}"

      popd
    }
  else
    _prepare_staging() {
      :
    }
  fi

  source+=(
    30-win32-aliases.conf
    wine-binfmt.conf
  )
  sha256sums+=(
    'SKIP'
    'SKIP'
  )
}

# stable package
_main_stable() {
  _pkgsrc="$_pkgname"
  source+=("$_pkgsrc"::"git+$url.git#tag=wine-${pkgver%%.r*}")
  sha256sums+=('SKIP')

  _prepare_main() {
    pushd "$_pkgsrc"

    _pkgver=$(
      git tag --list 'wine-[0-9]*.[0-9]*' \
        | sed -E 's/^[^0-9]+//;s/^.*[A-Za-z]{2}.*$//' \
        | sort -V | tail -1
    )

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

    if [[ "${_build_staging::1}" == "t" ]] ; then
      git -C "$srcdir/wine-staging" checkout -f "v$_pkgver"
      git -C "$srcdir/wine-staging" describe --tags --long
    fi

    popd
  }

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

# git package
_main_git() {
  _pkgsrc="$_pkgname"
  source+=("$_pkgsrc"::"git+$url.git")
  sha256sums+=('SKIP')

  _prepare_main() {
    _staging_options=(
      #-Wserver-PeekMessage
      #-Weventfd_synchronization
    )
  }

  pkgver() {
    cd "$_pkgsrc"
    local _version=$(
      git tag --list 'wine-[0-9]*.[0-9]*' \
        | sed -E 's/^[^0-9]+//;s/^.*[A-Za-z]{2}.*$//' \
        | sort -V | tail -1
    )
    local _revision=$(git rev-list --count --cherry-pick wine-$_version...HEAD)
    local _hash=$(git rev-parse --short=8 HEAD)
    printf '%s.r%s.g%s' "${_version:?}" "${_revision:?}" "${_hash:?}"
  }
}

# common functions
prepare() {
  _prepare_main
  _prepare_staging
}

build() {
  local _configure_options=(
    --disable-tests
    --prefix=/usr
    --libdir=/usr/lib
    --enable-archs=x86_64,i386
    --with-wayland
  )

  cd "$_pkgsrc"
  ./configure "${_configure_options[@]}"
  make
}

package() {
  cd "$_pkgsrc"

  make install \
    prefix="$pkgdir/usr" \
    libdir="$pkgdir/usr/lib" \
    dlldir="$pkgdir/usr/lib/wine"

  ln -sf wine "$pkgdir/usr/bin/wine64"

  # Font aliasing settings for Win32 applications
  install -Dm644 "$srcdir/30-win32-aliases.conf" -t "$pkgdir/usr/share/fontconfig/conf.avail/"

  install -d "$pkgdir/usr/share/fontconfig/conf.default"
  ln -s ../conf.avail/30-win32-aliases.conf "$pkgdir/usr/share/fontconfig/conf.default/30-win32-aliases.conf"

  # binfmt config
  install -Dm644 "$srcdir/wine-binfmt.conf" "$pkgdir/usr/lib/binfmt.d/wine.conf"
}

# execute
_main_package