mirror of https://github.com/nirenjan/libx52.git
Add udev rules to distribution
Prior to this change, a user had to manually install their own udev rules on Linux if they wanted to access the joystick without having to run as root. The most common usecase was on systems based on Debian, where the user would be a member of the plugdev group, and they would create their own rule to allow members of the group to write to the joystick. This change adds a validated udev rule to the distribution, so if the user compiles from source and does a make install, the rule to allow plugdev group members to access the joystick is installed.pull/22/head
parent
e5ce827d7e
commit
2db24e8759
|
@ -10,7 +10,7 @@ if USE_NLS
|
|||
po_SUBDIRS = po
|
||||
endif
|
||||
|
||||
SUBDIRS = $(po_SUBDIRS) lib utils tests
|
||||
SUBDIRS = $(po_SUBDIRS) lib utils tests udev
|
||||
|
||||
# Extra files that need to be in the distribution
|
||||
EXTRA_DIST = \
|
||||
|
|
20
configure.ac
20
configure.ac
|
@ -33,6 +33,25 @@ AC_SUBST([X52_INCLUDE], ["-I \$(top_srcdir)/lib/libx52"])
|
|||
# Check for pthreads
|
||||
ACX_PTHREAD
|
||||
|
||||
# make distcheck doesn't work if some files are installed outside $prefix.
|
||||
# Check for a prefix ending in /_inst, if this is found, we can assume this
|
||||
# to be a make distcheck, and disable some of the installcheck stuff.
|
||||
AS_CASE([$prefix], [*/_inst],
|
||||
[AC_MSG_NOTICE([[Prefix ends in /_inst; this looks like a 'make distcheck']])
|
||||
is_make_distcheck=yes])
|
||||
AM_CONDITIONAL([IS_MAKE_DISTCHECK], [test "x$is_make_distcheck" = xyes])
|
||||
AC_MSG_CHECKING([final decision IS_MAKE_DISTCHECK (running "make distcheck"?)])
|
||||
AM_COND_IF([IS_MAKE_DISTCHECK], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no])])
|
||||
|
||||
# udev support
|
||||
AX_PKG_CHECK_MODULES([UDEV], [udev], [], [have_udev=yes], [have_udev=no])
|
||||
AM_CONDITIONAL([HAVE_UDEV], [test "x$have_udev" = xyes])
|
||||
AC_ARG_WITH([udevrulesdir],
|
||||
AS_HELP_STRING([--with-udevrulesdir=DIR], [Directory for udev rules]),
|
||||
[udevrulesdir=$withval],
|
||||
[udevrulesdir=$($PKG_CONFIG --variable=udevdir udev)"/rules.d"])
|
||||
AC_SUBST([udevrulesdir], [$udevrulesdir])
|
||||
|
||||
# Doxygen Support
|
||||
AC_CHECK_PROGS([DOXYGEN], [doxygen])
|
||||
AM_CONDITIONAL([HAVE_DOXYGEN], [test -n "$DOXYGEN"])
|
||||
|
@ -47,6 +66,7 @@ AC_CONFIG_FILES([ po/Makefile.in
|
|||
lib/libx52/libx52.pc
|
||||
lib/libusbx52/Makefile
|
||||
lib/libx52util/Makefile
|
||||
udev/Makefile
|
||||
utils/Makefile
|
||||
utils/cli/Makefile
|
||||
utils/test/Makefile
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
# udev rules to give plugdev users permissions to:
|
||||
# - write to the X52/X52pro using libx52
|
||||
# - read from the hidraw interface
|
||||
ACTION!="add", GOTO="x52_rules_end"
|
||||
|
||||
# X52Pro flight control system
|
||||
SUBSYSTEM=="usb", ATTRS{idVendor}=="06a3", ATTRS{idProduct}=="0762", MODE="0664", GROUP="plugdev"
|
||||
SUBSYSTEM=="hidraw", ATTRS{idVendor}=="06a3", ATTRS{idProduct}=="0762", MODE="0640", GROUP="plugdev"
|
||||
|
||||
# X52 flight control system
|
||||
SUBSYSTEM=="usb", ATTRS{idVendor}=="06a3", ATTRS{idProduct}=="0255", MODE="0664", GROUP="plugdev"
|
||||
SUBSYSTEM=="hidraw", ATTRS{idVendor}=="06a3", ATTRS{idProduct}=="0255", MODE="0640", GROUP="plugdev"
|
||||
SUBSYSTEM=="usb", ATTRS{idVendor}=="06a3", ATTRS{idProduct}=="075c", MODE="0664", GROUP="plugdev"
|
||||
SUBSYSTEM=="hidraw", ATTRS{idVendor}=="06a3", ATTRS{idProduct}=="075c", MODE="0640", GROUP="plugdev"
|
||||
|
||||
LABEL="x52_rules_end"
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
# udev rules to make hidraw readable by users
|
||||
ACTION!="add", GOTO="x52pro_rules_end"
|
||||
SUBSYSTEM!="hidraw", GOTO="x52pro_rules_end"
|
||||
|
||||
# X52Pro flight control system
|
||||
ATTRS{idVendor}=="06a3", ATTRS{idProduct}=="0762", MODE="0644"
|
||||
|
||||
LABEL="x52pro_rules_end"
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
# udev rules installation
|
||||
#
|
||||
# Copyright (C) 2020 Nirenjan Krishnan (nirenjan@nirenjan.org)
|
||||
#
|
||||
# SPDX-License-Identifier: GPL-2.0-only WITH Classpath-exception-2.0
|
||||
|
||||
# Extra files that need to be in the distribution
|
||||
EXTRA_DIST = 60-saitek-x52-x52pro.rules
|
||||
|
||||
if HAVE_UDEV
|
||||
|
||||
# udev rules need to go to (typically) /lib/udev/rules.d. This location is only
|
||||
# writable by root, and if we're running make distcheck, we're most likely not
|
||||
# running as root. Therefore, disable this if we're running make distcheck
|
||||
if !IS_MAKE_DISTCHECK
|
||||
udevrules_DATA = 60-saitek-x52-x52pro.rules
|
||||
|
||||
# Update udev only if being installed by root
|
||||
install-data-hook:
|
||||
$(AM_V_at)if [ "$$(id -u)" = "0" ]; then \
|
||||
echo "Installing udev rules" && \
|
||||
udevadm control --reload-rules && \
|
||||
udevadm trigger --subsystem-match=usb --attr-match=idVendor=06a3 --action=add \
|
||||
;fi
|
||||
endif
|
||||
|
||||
endif
|
Loading…
Reference in New Issue