summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 4cee0a1d56d9d584dbc8b769facc8d9b19e4aca1 (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
# Maintainer:

# options
: ${CARGO_HOME:=$SRCDEST/cargo-home}

: ${_build_git:=true}

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

# basic info
_pkgname="mozillavpn"
pkgname="$_pkgname${_pkgtype:-}"
pkgver=2.20.0.r89.g9e2c028
pkgrel=1
pkgdesc="Fast, secure, and easy to use VPN from the makers of Firefox"
url="https://github.com/mozilla-mobile/mozilla-vpn-client"
license=('MPL-2.0')
arch=('x86_64')

# main package
_main_package() {
  depends=(
    'dbus'
    'freetype2'
    'hicolor-icon-theme'
    'libtiff'
    'libxcb'
    'libxdmcp'
    'libxmu'
    'libxrender'
    'polkit'
    'qt6-5compat'
    'qt6-charts'
    'qt6-declarative'
    'qt6-imageformats'
    'qt6-networkauth'
    'qt6-shadertools'
    'qt6-svg'
    'qt6-websockets'
    'wireguard-tools'
  )
  makedepends=(
    'cargo'
    'clang'
    'cmake'
    'git'
    'go'
    'python-glean-parser'
    'python-lxml'
    'python-yaml'
    'qt6-tools'
    'yamllint'
  )
  optdepends=(
    'qt6-wayland: for Wayland support'
  )

  options=('!lto')
  install="$_pkgname.install"

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

  _source_getsentry_sentry_native
  _source_mozillavpn
}

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

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

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

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

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

# git package
_main_git() {
  provides=("$_pkgname=${pkgver%%.r*}")
  conflicts=("$_pkgname")

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

  _prepare() {
    :
  }

  pkgver() {
    cd "$_pkgsrc"
    local _tag=$(git tag | sort -rV | head -1)
    local _revision=$(git rev-list --count --cherry-pick $_tag...HEAD)
    local _hash=$(git rev-parse --short=7 HEAD)

    local _pkgver=$(
      printf '%s.r%s.g%s' \
        "${_tag#v}" \
        "$_revision" \
        "$_hash"
    )
    echo "${_pkgver:?}"
  }
}

# submodules
_source_mozillavpn() {
  source+=(
    #'kdab.android_openssl'::'git+https://github.com/KDAB/android_openssl.git'
    'adjust.android_sdk'::'git+https://github.com/adjust/android_sdk.git'
    'adjust.ios_sdk'::'git+https://github.com/adjust/ios_sdk.git'
    'getsentry.sentry-native'::'git+https://github.com/getsentry/sentry-native.git'
    'mozilla-l10n.mozilla-vpn-client-l10n'::'git+https://github.com/mozilla-l10n/mozilla-vpn-client-l10n.git'
    'mozilla.glean'::'git+https://github.com/mozilla/glean.git'
    'wireguard.wireguard-apple'::'git+https://github.com/WireGuard/wireguard-apple.git'
    'wireguard.wireguard-go'::'git+https://github.com/WireGuard/wireguard-go.git'
    'wireguard.wireguard-tools'::'git+https://github.com/WireGuard/wireguard-tools.git'
  )
  sha256sums+=(
    #'SKIP'
    'SKIP'
    'SKIP'
    'SKIP'
    'SKIP'
    'SKIP'
    'SKIP'
    'SKIP'
    'SKIP'
  )

  _prepare_mozillavpn() (
    cd "$srcdir/$_pkgsrc"
    local -A _submodules=(
      #['kdab.android_openssl']='3rdparty/openSSL'
      ['adjust.android_sdk']='3rdparty/adjust-android-sdk'
      ['adjust.ios_sdk']='3rdparty/adjust-ios-sdk'
      ['getsentry.sentry-native']='3rdparty/sentry'
      ['mozilla-l10n.mozilla-vpn-client-l10n']='src/translations/i18n'
      ['mozilla.glean']='3rdparty/glean'
      ['wireguard.wireguard-apple']='3rdparty/wireguard-apple'
      ['wireguard.wireguard-go']='3rdparty/wireguard-go'
      ['wireguard.wireguard-tools']='3rdparty/wireguard-tools'
    )
    _submodule_update
  )
}

_source_getsentry_sentry_native() {
  source+=(
    'chromium.googlesource.com.linux-syscall-support'::'git+https://chromium.googlesource.com/linux-syscall-support.git'
    'getsentry.breakpad'::'git+https://github.com/getsentry/breakpad.git'
    'getsentry.crashpad'::'git+https://github.com/getsentry/crashpad.git'
    'getsentry.libunwindstack-ndk'::'git+https://github.com/getsentry/libunwindstack-ndk.git'
  )
  sha256sums+=(
    'SKIP'
    'SKIP'
    'SKIP'
    'SKIP'
  )

  _prepare_getsentry_sentry_native() (
    cd "$srcdir/$_pkgsrc"
    cd "3rdparty/sentry"
    local -A _submodules=(
      ['chromium.googlesource.com.linux-syscall-support']='external/third_party/lss'
      ['getsentry.breakpad']='external/breakpad'
      ['getsentry.crashpad']='external/crashpad'
      ['getsentry.libunwindstack-ndk']='external/libunwindstack-ndk'
    )
    _submodule_update
  )
}

# common functions
prepare() {
  _prepare

  _submodule_update() {
    for key in ${!_submodules[@]} ; do
      git submodule init "${_submodules[${key}]}"
      git submodule set-url "${_submodules[${key}]}" "${srcdir}/${key}"
      git -c protocol.file.allow=always submodule update "${_submodules[${key}]}"
    done
  }

  _prepare_mozillavpn
  _prepare_getsentry_sentry_native
}

build() {
  local _cmake_options=(
    -B build
    -S "$_pkgsrc"
    -DCMAKE_BUILD_TYPE=None
    -DCMAKE_INSTALL_PREFIX='/usr'
    -Wno-dev
  )

  cmake "${_cmake_options[@]}"
  cmake --build build
}

package() {
  DESTDIR="$pkgdir" cmake --install build
}

# execute
_main_package