Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PKGBUILD and DKMS to make it easier for arch users.. #36

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
CC=gcc
DRIVERDIR?=`pwd`/driver
KDIR?=/lib/modules/`uname -r`/build

MODULEDIR?=/lib/modules/`uname -r`/kernel/drivers/usb

Expand All @@ -10,7 +9,7 @@ debug: EXTRA_CFLAGS := -DDEBUG
debug: default

build:
$(MAKE) CC=$(CC) EXTRA_CFLAGS=$(EXTRA_CFLAGS) -C $(KDIR) M=$(DRIVERDIR)
$(MAKE) -C $(DRIVERDIR)

debug_install: debug install

Expand Down Expand Up @@ -62,4 +61,4 @@ udev_trigger:
udevadm trigger --subsystem-match=usb --subsystem-match=input --subsystem-match=hid --attr-match=bInterfaceClass=03 --attr-match=bInterfaceSubClass=01 --attr-match=bInterfaceProtocol=02

clean:
rm -rf $(DRIVERDIR)/.*.cmd $(DRIVERDIR)/*.ko $(DRIVERDIR)/*.mod $(DRIVERDIR)/*.mod.* $(DRIVERDIR)/*.symvers $(DRIVERDIR)/*.order $(DRIVERDIR)/*.o
$(MAKE) -C $(DRIVERDIR) clean
47 changes: 47 additions & 0 deletions PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
pkgname=maccel-dkms
_pkgname="${pkgname%-*}"
pkgver=0.2.1
pkgrel=1
pkgdesc='Mouse acceleration driver and kernel module for Linux.'
arch=('x86_64')
url='https://www.maccel.org/'
license=('GPL-2.0-or-later')

depends=("curl" "git" "dkms")
install=${_pkgname}.install

source=("git+https://github.com/pxlsec/maccel")
sha256sums=('SKIP')

build() {
# Build the CLI
cd $srcdir/maccel
make build_cli
}

package() {
# Add group
install -Dm644 ${srcdir}/maccel/maccel.sysusers ${pkgdir}/usr/lib/sysusers.d/${_pkgname}.conf

# Install Driver
install -Dm644 ${srcdir}/maccel/dkms.conf ${pkgdir}/usr/src/${_pkgname}-${pkgver}/dkms.conf

# Set name and version
sed -e "s/@_PKGNAME@/${_pkgname}/" \
-e "s/@PKGVER@/${pkgver}/" \
-i "${pkgdir}/usr/src/${_pkgname}-${pkgver}/dkms.conf"

# Copy sources (including Makefile)
cp -r ${srcdir}/maccel/driver/* ${pkgdir}/usr/src/${_pkgname}-${pkgver}/

# Install CLI
install -Dm 755 $srcdir/maccel/cli/target/release/maccel ${pkgdir}/usr/local/bin/maccel
install -Dm 755 $srcdir/maccel/cli/usbmouse/target/release/maccel-driver-binder ${pkgdir}/usr/local/bin/maccel-driver-binder
pxlsec marked this conversation as resolved.
Show resolved Hide resolved

# Install udev rules
install -Dm 644 ${srcdir}/maccel/udev_rules/99-maccel.rules ${pkgdir}/usr/lib/udev/rules.d/99-maccel.rules
install -Dm 755 ${srcdir}/maccel/udev_rules/maccel_param_ownership_and_resets ${pkgdir}/usr/lib/udev/maccel_param_ownership_and_resets

# Install License
install -Dm644 ${srcdir}/maccel/LICENSE ${pkgdir}/usr/share/licenses/${_pkgname}/LICENSE
}
7 changes: 7 additions & 0 deletions dkms.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
PACKAGE_NAME="@_PKGNAME@"
PACKAGE_VERSION="@PKGVER@"
MAKE[0]="make KVER=$kernelver"
CLEAN="make clean"
BUILT_MODULE_NAME[0]="@_PKGNAME@"
DEST_MODULE_LOCATION[0]="/kernel/drivers/usb"
AUTOINSTALL="yes"
9 changes: 9 additions & 0 deletions driver/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
obj-m += maccel.o

KVER ?= $(shell uname -r)
KDIR ?= /lib/modules/$(KVER)/build

build:
$(MAKE) -C $(KDIR) M=$(CURDIR)

clean:
$(MAKE) -C $(KDIR) M=$(CURDIR) clean

test:
@mkdir -p tests/snapshots
@gcc tests/test.c -o accel_test -g
Expand Down
19 changes: 19 additions & 0 deletions maccel.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
post_install() {
udevadm control --reload-rules
udevadm trigger --subsystem-match=usb --subsystem-match=input --subsystem-match=hid --attr-match=bInterfaceClass=03 --attr-match=bInterfaceSubClass=01 --attr-match=bInterfaceProtocol=02

echo ' Add yourself to the "maccel" group\n'
echo ' usermod -aG maccel $USER\n'
}

post_uprgade() {
pxlsec marked this conversation as resolved.
Show resolved Hide resolved
udevadm control --reload-rules
}

pre_remove() {
maccel driver unbindall
}

post_remove() {
udevadm control --reload-rules
}
1 change: 1 addition & 0 deletions maccel.sysusers
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
g maccel - -
2 changes: 2 additions & 0 deletions udev_rules/99-maccel.rules
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ACTION=="add", SUBSYSTEM=="module", DEVPATH="/module/maccel", RUN+="maccel_param_ownership_and_resets"

ACTION=="remove", GOTO="maccel_end"
SUBSYSTEMS=="usb|input|hid", ATTRS{bInterfaceClass}=="03", ATTRS{bInterfaceSubClass}=="01", ATTRS{bInterfaceProtocol}=="02", RUN+="maccel_param_ownership_and_resets"

Expand Down