summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 209b5f4451d7074e2e4efd111ff72e5b1506771a (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
# Maintainer:  dreieck

## Based on: 'hidapi-git' PKGBUILD version 0.10.1.r18.g6fcb0bb, by
# Contributor: Richard Steinmetz <steinmetz.richard@googlemail.com>

_gitname="hidapi"
_pkgname="hidapi-testgui"
pkgname="${_pkgname}-git"
pkgver=0.14.0+41.r666.20241030.ff67c77
_pkgmajorver="$(awk -F. '{print $1}' <<<"${pkgver}")"
pkgrel=1
epoch=0
pkgdesc="'hidapi-hidraw-testgui' and 'hidapi-libusb-testgui' for hidapi."
arch=(
  "x86_64"
  "i686"
  "aarch64"
  "armv6h"
  "armv7h"
)
url='https://github.com/libusb/hidapi'
license=(
  'GPL-3.0-or-later'
  'BSD-3-Clause'
  'LicenseRef-HIDAPI'
)
depends=(
  'fox'
  # 'hidapi'
)
makedepends=(
  'autoconf' # for 'autoreconf'
  'automake'
  'bash'
  'git'
  'make'
  #'systemd'
  #'systemd-libs'
  'libusb'
  'libtool' # for 'libtoolize'
  'libudev.so'
)
optdepends=(
  'libusb: for the libusb backend -- hidapi-libusb.so'
  'libudev.so: for the hidraw backend -- hidapi-hidraw.so'
  "libhidapi-hidraw.so=${_pkgmajorver}: To use 'hidapi-hidraw-testgui'."
  "libhidapi-libusb.so=${_pkgmajorver}: To use 'hidapi-libusb-testgui'."
)
provides=(
  "${_pkgname}=${pkgver}"
)
conflicts=(
  "${_pkgname}"
)
source=(
  "${_gitname}::git+${url}.git"
)
sha256sums=(
  'SKIP'
)

prepare() {
  cd "${srcdir}/${_gitname}"

  git log > git.log
}

pkgver() {
  cd "${srcdir}/${_gitname}"

  _ver_versionfile="$(< 'VERSION')"
  _ver_gittags="$(git describe --tags | sed -E -e 's|^hidapi-||' -e 's|^[vV]||' -e 's|\-g[0-9a-f]*$||' | tr '-' '+')"
  _ver="${_ver_gittags}"
  _rev="$(git rev-list --count HEAD)"
  _date="$(git log -1 --date=format:"%Y%m%d" --format="%ad")"
  _hash="$(git rev-parse --short HEAD)"

  if [ -z "${_ver}" ]; then
    error "Version could not be determined."
    return 1
  else
    printf '%s' "${_ver}.r${_rev}.${_date}.${_hash}"
  fi
}

build() {
  cd "${srcdir}/${_gitname}"

  ./bootstrap
  ./configure \
    --prefix=/usr \
    --enable-shared \
    --disable-static \
    --enable-testgui

  make
}

package() {
  cd "${srcdir}/${_gitname}"

  make DESTDIR="${pkgdir}" install

  rm -fv "${pkgdir}/usr"/share/doc/"${_gitname}"/LICENSE*

  rm -fv "${pkgdir}/usr"/include/hidapi/{hidapi.h,hidapi_libusb.h}
  rm -fv "${pkgdir}/usr"/lib/{libhidapi-hidraw.so,libhidapi-hidraw.so.*,libhidapi-libusb.so,libhidapi-libusb.so.*,libhidapi-hidraw.la,libhidapi-libusb.la}
  rm -fv "${pkgdir}/usr"/lib/pkgconfig/{hidapi-hidraw.pc,hidapi-libusb.pc}
  rm -fv "${pkgdir}/usr"/share/doc/"${_gitname}"/{AUTHORS.txt,README.md}

  rmdir "${pkgdir}/usr"/{share/doc/${_gitname},include/hidapi,include,lib/pkgconfig,lib}

  # install -Dvm0755 -t "${pkgdir}/usr/bin" testgui/{hidapi-hidraw-testgui,hidapi-libusb-testgui}

  install -Dvm0644 -t "${pkgdir}/usr/share/doc/${_pkgname}" git.log AUTHORS.txt HACKING.txt README.md
  install -Dvm0644 -t "${pkgdir}/usr/share/licenses/${pkgname}" LICENSE.txt LICENSE-bsd.txt LICENSE-gpl3.txt LICENSE-orig.txt
}