summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 1c5fa14026672b6d5dc4604b803f98069ff07b53 (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
# Maintainer: Claudia Pellegrino <aur ät cpellegrino.de>

pkgname=moz-phab
_gitpkgname=review
pkgver=1.11.0
pkgrel=1
pkgdesc='Phabricator review submission/management tool'
arch=('any')
url='https://github.com/mozilla-conduit/review'
license=('MPL-2.0')
depends=(
  'python'
  'python-colorama'
  'python-distro'
  'python-hglib'
  'python-sentry_sdk'
  'python-setuptools'
  'python-packaging'
)
makedepends=(
  'python-build'
  'python-installer'
  'python-setuptools-scm'
  'python-wheel'
)
checkdepends=(
  'git'
  'hg-evolve'
  'mercurial'
  'python-immutabledict'
  'python-pytest'
)
optdepends=(
  'git: support for Git repositories'
  'hg-evolve: support for evolve, a Mercurial extension'
  'mercurial: support for Mercurial repositories'
)

source=(
  "${_gitpkgname}-${pkgver}.tar.gz::https://github.com/mozilla-conduit/review/archive/${pkgver}.tar.gz"
  'disable-auto-update.patch'
  'disable-exception-reporting.patch'
  'disable-telemetry.patch'
  'phabricator-D252875.patch'
  'phabricator-D254820.patch'
)

sha512sums=('ac277d96c7b1893d189a60389b16caa01580dbef0deef1a6b7502aa1875754ba5bf46ed5a5f93909678c6b28159c6fb2d08d0e9d00d748d440dfdfbf0a3fabf8'
            'dd5fd9467261866549596836f72dd7d28519f71bce6e838bb1a0de8f607fa7dd7407abd5ac3a02fd8ab139e8a53affef05a73f8597ba0367be15a4e78811ca54'
            '35087a5d373f7ec1c726204b272454e08b8e43469000eb415f218adeb5606e7f48d603191571f88f23295c15b97275866ac117a5d87d0ea9e7ffefc837fefe43'
            'd8ca129d5441282124599a74e5f0c898d28f4bde574ce0e6c792d492fdcd262c0bb40e3ed79611f603a3dde74fc18659b9b6303abd1022644ebe57031f993ef6'
            '4c8606a18f24a92574f81a839d0b4f2639fb49d545c7c1d6fe756a61b941d4c1b46345c8a6356c3348458d8ef5b66c5628294f1ad3422a0c035d1afe8d8e0396'
            '8e70c561f6ef347c1faefcda0ca35eb7d2f44783a60aedb16abbf8ed825377120c58ae7b470a4656748a9ba392379a7f43865ec4e56b1d44c0397a3b64f8d4a4')

prepare() {
  cd "${_gitpkgname}-${pkgver}"

  # Remove this patch once upstream has included D252875 and D254820
  # in a stable release.
  # See also:
  # - https://bugzilla.mozilla.org/show_bug.cgi?id=1970907
  # - https://phabricator.services.mozilla.com/D252875
  # - https://phabricator.services.mozilla.com/D254820
  echo >&2 'Applying patch to fix distracting warning'
  patch -p1 < ../phabricator-D252875.patch
  patch -p1 < ../phabricator-D254820.patch

  # Do not let the package upgrade itself
  patch -p1 < ../disable-auto-update.patch
  # Do not report exceptions to upstream project by default
  patch -p1 < ../disable-exception-reporting.patch
  # Do not send telemetry
  patch -p1 < ../disable-telemetry.patch
}

build() {
  cd "${_gitpkgname}-${pkgver}"
  echo >&2 'Building wheel'
  export SETUPTOOLS_SCM_PRETEND_VERSION="${pkgver}"
  python -m build --wheel --no-isolation
}

check() {
  cd "${_gitpkgname}-${pkgver}"
  python -m venv --system-site-packages test-env
  test-env/bin/python -m installer dist/*.whl

  echo >&2 'Running unit tests'
  # Exclude from pytest’s collection all Git/Mercurial integration
  # tests and submission tests, which rely on an unpackaged,
  # unmaintained dependency
  test-env/bin/python -m pytest \
    --ignore=tests/test_integration_git.py \
    --ignore=tests/test_integration_hg.py \
    --ignore=tests/test_submit.py \
    -k 'not test_style and not test_telemetry'

  echo >&2 'Testing the executable'
  test-env/bin/${pkgname} --version > actual.txt
  if ! grep -qF "MozPhab ${pkgver}" actual.txt; then
    printf >&2 '%s\n' 'Unexpected test output:' '==='
    cat >&2 actual.txt
    printf >&2 '\n%s\n' '==='
    exit 1
  fi
}

package() {
  cd "${_gitpkgname}-${pkgver}"

  echo >&2 'Packaging the wheel'
  python -I -m installer --destdir="${pkgdir}" dist/*.whl

  echo >&2 'Packaging the documentation'
  install -D -m 644 -t "${pkgdir}/usr/share/doc/${pkgname}" \
    README.md

  echo >&2 'Packaging the license'
  install -D -m 644 -t "${pkgdir}/usr/share/licenses/${pkgname}" \
    LICENSE
}