summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 9120f052b3dfa4eeb3616ad9e0e4d3cfd29fc675 (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
118
119
# Maintainer: Luca Weiss <luca (at) z3ntu (dot) xyz>
# Maintainer: Gabriele Musco <emaildigabry@gmail.com>

# This PKGBUILD is configured to only build razer-driver-dkms, razer-daemon & python-razer by default.
# Kernel modules for the stock kernel (package "linux") can be built into a package by setting the variable "build_kernel_modules" to "true".
build_kernel_modules=false

# Furthermore it is possible to build the package from a specific git commit by uncommenting the variable "_commit" and setting it to a valid commit. pkgrel should be bumped up too then.

_newname=openrazer
pkgbase=razer-drivers
pkgname=('python-razer' 'razer-daemon' 'razer-driver-dkms' 'openrazer-meta')
if $build_kernel_modules; then
    # For kernel update: Update the two variables and the .install file!
    _linux_current=4.12
    _linux_next=4.13
    pkgname+=('razer-driver-arch')
fi
pkgver=1.1.16
#_commit=6ae1f7d55bf10cc6b5cb62a5ce99ff22c43e0701
pkgrel=1
pkgdesc="An entirely open source driver and user-space daemon that allows you to manage your Razer peripherals on GNU/Linux."
arch=('any')
url="https://github.com/openrazer/openrazer"
license=('GPL2')
makedepends=('make' 'python' 'python-setuptools')
if $build_kernel_modules; then
    makedepends+=("linux-headers>=$_linux_current" "linux-headers<$_linux_next" "linux>=$_linux_current" "linux<$_linux_next")
fi
if [ -z $_commit ]; then
  source=("https://github.com/openrazer/openrazer/archive/v$pkgver.tar.gz")
else
  source=("https://github.com/openrazer/openrazer/archive/$_commit.tar.gz")
fi
sha256sums=('dd1d934c3b1a50182fa1fca92ab853c2ad761b94a2925eb6ee71f060f233a00f')

package_python-razer() {
  pkgdesc="Python library for accessing the Razer daemon from Python."
  depends=('razer-daemon' 'python' 'python-dbus' 'python-numpy')
  if [ -z $_commit ]; then
    cd $srcdir/$_newname-$pkgver
  else
    cd $srcdir/$_newname-$_commit
  fi
  make DESTDIR=$pkgdir python_library_install
}

package_razer-daemon() {
  pkgdesc="Userspace daemon that abstracts access to the kernel driver. Provides a DBus service for applications to use."
  depends=('razer-driver-dkms' 'python-dbus' 'python-gobject' 'python-setproctitle' 'xautomation' 'xdotool' 'libdbus' 'python-notify2' 'python-pyudev' 'gtk3' 'dbus-glib')
  # gtk3 for "gi.require_version('Gdk', '3.0')"
  install=razer-daemon.install

  if [ -z $_commit ]; then
    cd $srcdir/$_newname-$pkgver
  else
    cd $srcdir/$_newname-$_commit
  fi
  make DESTDIR=$pkgdir daemon_install
}

package_razer-driver-dkms() {
  pkgdesc="Kernel driver for Razer devices (DKMS-variant)"
  depends=('dkms' 'udev')
  provides=('OPENRAZER-MODULES')
  conflicts=('OPENRAZER-MODULES')
  install=razer-driver-dkms.install
  
  if [ -z $_commit ]; then
    cd $srcdir/$_newname-$pkgver
  else
    cd $srcdir/$_newname-$_commit
  fi
  make DESTDIR=$pkgdir setup_dkms udev_install
}

package_openrazer-meta() {
  pkgdesc="Meta package for installing all required openrazer packages."
  depends=('razer-driver-dkms' 'razer-daemon' 'python-razer')
  optdepends=('polychromatic: frontend'
              'razergenie: qt frontend'
              'razercommander: gtk frontend')
 }

if $build_kernel_modules; then
_extramodules=extramodules-$_linux_current-ARCH

build() {
  if [ -z $_commit ]; then
    cd $srcdir/$_newname-$pkgver
  else
    cd $srcdir/$_newname-$_commit
  fi

  _kernver="$(cat /usr/lib/modules/${_extramodules}/version)"

  make DESTDIR=$pkgdir KERNELDIR=/usr/lib/modules/$_kernver/build driver
}

package_razer-driver-arch() {
  pkgdesc="Kernel driver for Razer devices (for stock 'linux' kernel)"
  depends=('udev')
  depends=("linux>=$_linux_current" "linux<$_linux_next")
  provides=('OPENRAZER-MODULES' 'razer-driver-dkms')
  conflicts=('OPENRAZER-MODULES' 'razer-driver-dkms')
  install=razer-driver-arch.install

  if [ -z $_commit ]; then
    cd $srcdir/$_newname-$pkgver
  else
    cd $srcdir/$_newname-$_commit
  fi
  install -dm755 $pkgdir/usr/lib/modules/$_extramodules/
  make DESTDIR=$pkgdir MODULEDIR=/usr/lib/modules/$_extramodules/ driver_install_packaging udev_install

  # compress each module individually
  find "$pkgdir" -name '*.ko' -exec gzip -9 {} +
}
fi