summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 385120e15244d67af275878329add54980449158 (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: Lennard Kittner <lennard@kittner.dev>
_sourceName="HyperHeadset"

pkgname="hyperheadset-git"
pkgver=1.5.1.r3.ga73023d
pkgrel=1
pkgdesc="A CLI and tray application for monitoring and managing HyperX headsets."
arch=('x86_64')
url="https://github.com/LennardKittner/HyperHeadset"
license=('MIT')
install=${pkgname}.install
depends=(
  dbus
  systemd-libs
)
makedepends=(
  git
  cargo
)
source=(
    "git+${url}.git#branch=main"
    "git+https://github.com/ruabmbua/hidapi-rs.git"
    "git+https://github.com/libusb/hidapi.git"
)
sha256sums=('SKIP' 'SKIP' 'SKIP')
validpgpkeys=()
provides=("hyperheadset")
conflicts=("hyperheadset" "hyperheadset-bin")

pkgver() {
  cd "${_sourceName}"
  git describe --long --abbrev=7 | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
}

prepare() {
    cd "${_sourceName}"
    git submodule init
    git config submodule.vendor/hidapi.url "$srcdir/hidapi-rs"
    git -c protocol.file.allow=always submodule update

    cd "vendor/hidapi"
    git submodule init
    git config submodule.etc/hidapi.url "$srcdir/hidapi"
    git -c protocol.file.allow=always submodule update

    cd "../.."
    export RUSTUP_TOOLCHAIN=stable
    cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
    cd "${_sourceName}"
    export RUSTUP_TOOLCHAIN=stable
    export CARGO_TARGET_DIR=target
    export CFLAGS="${CFLAGS//-flto=auto/}"
    export CXXFLAGS="${CXXFLAGS//-flto=auto/}"
    cargo build --frozen --release --bin hyper_headset --bin hyper_headset_cli
}

check() {
    cd "${_sourceName}"
    export RUSTUP_TOOLCHAIN=stable
    cargo test --frozen
}

package() {
  cd "${_sourceName}"
  find target/release \
      -maxdepth 1 \
      -executable \
      -type f \
      -exec install -Dm0755 -t "${pkgdir}/usr/bin/" {} +

  install -Dm644 99-HyperHeadset.rules "${pkgdir}/usr/lib/udev/rules.d/99-HyperHeadset.rules"

  install -Dm644 hyper-headset.desktop "${pkgdir}/usr/share/applications/hyper-headset.desktop"

  install -Dm644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}/"
}