summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 3c79064f13993568b43be8ef5e66f65eecdf0ae8 (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
# Maintainer: David Runge <dvzrv@archlinux.org>

pkgbase=libusbsio
pkgname=(
  libusbsio
  python-libusbsio
)
pkgver=2.1.11
pkgrel=4
pkgdesc="Library for USB-HID communication over SPI, I2C or GPIO"
arch=(x86_64)
url="https://www.nxp.com/design/software/development-software/library-for-windows-macos-and-ubuntu-linux:LIBUSBSIO"
license=(
  BSD-3-Clause
  BSD-3-Clause
)
makedepends=(
  hidapi
  libusb
  python-build
  python-installer
  python-setuptools
  python-wheel
  systemd
)
source=(https://www.nxp.com/downloads/en/libraries/$pkgbase-$pkgver-src.zip)
sha512sums=('200717be44cdb2bb7cc7eeba29afb6aed8a88a72e7664377c1abf8c1d1f88f7de1ed05c9a7d6c960ae53e4b9420889c252d51fd807b1534396430004138518a0')
b2sums=('711b7b59cec79ebc37f42eab7a7c377d6cf15ccc50982dfcacd4e8f6b0c4107ebf14f758a41ee9edad9d2d6d789c99376f1b181e37b5dfea8e543cf06f7b566a')

prepare() {
  cd $pkgbase-$pkgver-src
  # remove prebuilt shared libs
  rm -frv bin/*

  # extract sources for python package for PEP517 build
  cd python/dist
  tar xvzf $pkgbase-$pkgver.tar.gz
  # remove prebuilt shared libs from sdist tarball
  rm -frv $pkgbase-$pkgver/$pkgbase/bin/*
}

build() {
  cd $pkgbase-$pkgver-src
  make
  cd python/dist/$pkgbase-$pkgver
  python -m build --wheel --skip-dependency-check --no-isolation
}

package_libusbsio() {
  depends=(
    glibc
    systemd-libs libudev.so
  )

  cd $pkgbase-$pkgver-src
  install -vDm 755 bin/linux_$CARCH/$pkgbase.so -t "$pkgdir/usr/lib/"
  install -vDm 644 license/*.txt -t "$pkgdir/usr/share/licenses/$pkgname/"
}

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

  pkgdesc+=" - Python bindings"
  depends=(
    libusbsio=$pkgver
    python
  )

  cd $pkgbase-$pkgver-src
  (
    cd python/dist/$pkgbase-$pkgver
    python -m installer --destdir="$pkgdir" dist/*.whl
    install -vdm 755 "$pkgdir/$_site_packages/$pkgbase/bin/linux_$CARCH"
    ln -fsv /usr/lib/$pkgbase.so "$pkgdir/$_site_packages/$pkgbase/bin/linux_$CARCH/$pkgbase.so"
  )
  install -vDm 644 license/*.txt -t "$pkgdir/usr/share/licenses/$pkgname/"
  install -vDm 644 python/README.md -t "$pkgdir/usr/share/doc/$pkgname/"
  install -vDm 644 python/examples/*.py -t "$pkgdir/usr/share/doc/$pkgname/"
}