summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 54244a16b4219642c5020ac9ddaa70e53d0ee033 (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
# Maintainer: novakpetya

pkgname=linux-switch2
pkgver=0.1.0
pkgrel=1
pkgdesc="Linux kernel drivers for Nintendo Switch 2 controllers"
arch=('x86_64')
url='https://github.com/novakpetya/linux-switch2'
license=('GPL-2.0-or-later')

depends=(
    'linux'
    'systemd'
)

makedepends=(
    'git'
    'linux-headers'
)

optdepends=(
    'bluez-switch2: Bluetooth LE transport support for Nintendo Switch 2 Joy-Con controllers on Linux'
)

conflicts=(
    'hid-switch2-dkms'
)

install=linux-switch2.install

options=('!strip')

source=(
    "linux-switch2::git+https://github.com/novakpetya/linux-switch2.git"
)

sha256sums=(
    'SKIP'
)

pkgver() {
    cd "$srcdir/linux-switch2"

    printf 'r%s.%s' \
        "$(git rev-list --count HEAD)" \
        "$(git rev-parse --short HEAD)"
}

build() {
    local _kernver
    _kernver="$(uname -r)"

    cd "$srcdir/linux-switch2"

    make \
        -C "/usr/lib/modules/${_kernver}/build" \
        M="$PWD" \
        modules
}

package() {
    local _kernver
    _kernver="$(uname -r)"

    cd "$srcdir/linux-switch2"

    # Kernel modules
    install -Dm644 hid-switch2.ko \
        "$pkgdir/usr/lib/modules/${_kernver}/updates/switch2/hid-switch2.ko"

    install -Dm644 switch2-usb.ko \
        "$pkgdir/usr/lib/modules/${_kernver}/updates/switch2/switch2-usb.ko"

    # udev permissions for Joy-Con / Joy-Con 2 devices
    install -Dm644 udev/70-switch2.rules \
        "$pkgdir/usr/lib/udev/rules.d/70-switch2.rules"
}