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

: ${CARGO_HOME:=$SRCDEST/cargo-home}
: ${CARGO_TARGET_DIR:=target}
: ${RUSTUP_TOOLCHAIN:=stable}

export CARGO_HOME CARGO_TARGET_DIR RUSTUP_TOOLCHAIN

_pkgname="mozillavpn"
pkgname="$_pkgname-git"
pkgver=2.25.0.r88.g0dd8fc8
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')

depends=(
  'hicolor-icon-theme'
  'libsecret'
  'qt6-5compat'
  'qt6-declarative'
  'qt6-networkauth'
  'qt6-svg'
  'qt6-websockets'
  'wireguard-tools'
)
makedepends=(
  'cargo'
  'clang'
  'cmake'
  'git'
  'go'
  'ninja'
  'python-glean-parser' # AUR
  'python-lxml'
  'python-yaml'
  'qt6-tools'
  'yamllint'
)
optdepends=(
  'qt6-wayland: for Wayland support'
)

options=('!lto')

install="$_pkgname.install"

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

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

_source_mozillavpn() {
  local _sources_add=(
    #'adjust.android_sdk'::'git+https://github.com/adjust/android_sdk.git'
    #'adjust.ios_sdk'::'git+https://github.com/adjust/ios_sdk.git'
    'c-ares'::'git+https://github.com/c-ares/c-ares.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'
    #'mozilla.wireguard-apple'::'git+https://github.com/mozilla/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'
  )

  local _p
  for _p in ${_sources_add[@]}; do
    source+=("$_p")
    sha256sums+=('SKIP')
  done

  _prepare_mozillavpn() (
    cd "$srcdir/$_pkgsrc"
    local _submodules=(
      #'adjust.android_sdk'::'3rdparty/adjust-android-sdk'
      #'adjust.ios_sdk'::'3rdparty/adjust-ios-sdk'
      'c-ares'::'3rdparty/c-ares'
      'getsentry.sentry-native'::'3rdparty/sentry'
      'mozilla-l10n.mozilla-vpn-client-l10n'::'3rdparty/i18n'
      'mozilla.glean'::'3rdparty/glean'
      #'mozilla.wireguard-apple'::'3rdparty/wireguard-apple'
      'wireguard.wireguard-go'::'3rdparty/wireguard-go'
      'wireguard.wireguard-tools'::'3rdparty/wireguard-tools'
    )
    _submodule_update
  )
}

_source_getsentry_sentry_native() {
  local _sources_add=(
    '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'
  )

  local _p
  for _p in ${_sources_add[@]}; do
    source+=("$_p")
    sha256sums+=('SKIP')
  done

  _prepare_getsentry_sentry_native() (
    cd "$srcdir/$_pkgsrc"
    cd "3rdparty/sentry"
    local _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'
    )

    git checkout master
    _submodule_update
  )
}

_source_main
_source_mozillavpn
_source_getsentry_sentry_native

prepare() {
  _submodule_update() {
    local _module
    for _module in "${_submodules[@]}"; do
      git submodule init "${_module##*::}"
      git submodule set-url "${_module##*::}" "$srcdir/${_module%::*}"
      git -c protocol.file.allow=always submodule update "${_module##*::}"
      echo
    done
  }

  _run_if_exists _prepare_mozillavpn
  _run_if_exists _prepare_getsentry_sentry_native

  cd "$_pkgsrc"
  cargo update
  cargo fetch --locked --target "$(rustc -vV | sed -n 's/host: //p')"
}

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)

  printf '%s.r%s.g%s' \
    "${_tag#v}" \
    "$_revision" \
    "$_hash"
}

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

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

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

_run_if_exists() {
  if declare -F "$1" > /dev/null; then
    eval "$1"
  fi
}