summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 430067b1be446ec9a04dd5860ccf3046217dbc40 (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
# Maintainer: a821 mail de
# Contributor: kpcyrd <kpcyrd[at]archlinux[dot]org>

pkgname=python-mitmproxy-rs-git
_pyname=mitmproxy_rs
pkgver=0.12.6.r2.g25a0851
pkgrel=1
pkgdesc="Python bindings for mitmproxy's Rust code"
arch=('x86_64')
url='https://github.com/mitmproxy/mitmproxy_rs'
license=('MIT')
depends=(
  'gcc-libs'
  'glibc'
  'python'
)
makedepends=(
  'bpf-linker'
  'cargo-nightly'
  'git'
  'maturin'
  'python-installer'
)
conflicts=("${pkgname%-git}")
provides=("${pkgname%-git}")
options=(!lto)
source=("git+${url}")
sha256sums=('SKIP')

pkgver() {
  cd mitmproxy_rs
  git describe --long --tags --match='v*.*.*' | sed -e 's/^v//;s/-/.r/;s/-/./g'
}

prepare() {
  export RUSTUP_TOOLCHAIN=nightly
  rustup component add rust-src --toolchain nightly-x86_64-unknown-linux-gnu
}

build() {
  export RUSTUP_TOOLCHAIN=nightly
  cd mitmproxy_rs/mitmproxy-rs
  maturin build --release --strip
  cd ../mitmproxy-linux
  maturin build --release --strip
}

check() {
  local _site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd mitmproxy_rs
  for wheel in target/wheels/*.whl ; do
    python -m installer --destdir=test_dir "$wheel"
  done
  export PYTHONPATH="test_dir/${_site_packages}:${PYTHONPATH}"
  python -c 'import mitmproxy_rs'
}

package() {
  cd mitmproxy_rs
  for wheel in target/wheels/*.whl ; do
    python -m installer --destdir="${pkgdir}" "$wheel"
  done
  install -Dm0644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}

# vim: ts=2 sw=2 et: