diff mbox series

[2/2] package/libinput: remove python tools scripts if python is missing

Message ID 20220809132730.232111-2-romain.naour@smile.fr
State Accepted
Headers show
Series [1/2] package/phython-libevdev: new package | expand

Commit Message

Romain Naour Aug. 9, 2022, 1:27 p.m. UTC
Some libinput tools are actually python scripts and requires
at least tree python modules: libevdev, pyudev and pyyaml:

libinput]$ file *
libinput-analyze:                   ELF 32-bit LSB pie executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-uClibc.so.0, stripped
libinput-analyze-per-slot-delta:    Python script, UTF-8 Unicode text executable
libinput-analyze-recording:         Python script, UTF-8 Unicode text executable
libinput-analyze-touch-down-state:  Python script, UTF-8 Unicode text executable
libinput-debug-events:              ELF 32-bit LSB pie executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-uClibc.so.0, stripped
libinput-debug-tablet:              ELF 32-bit LSB pie executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-uClibc.so.0, stripped
libinput-list-devices:              ELF 32-bit LSB pie executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-uClibc.so.0, stripped
libinput-measure:                   ELF 32-bit LSB pie executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-uClibc.so.0, stripped
libinput-measure-fuzz:              Python script, UTF-8 Unicode text executable
libinput-measure-touchpad-pressure: Python script, UTF-8 Unicode text executable
libinput-measure-touchpad-size:     Python script, UTF-8 Unicode text executable
libinput-measure-touchpad-tap:      Python script, UTF-8 Unicode text executable
libinput-measure-touch-size:        Python script, UTF-8 Unicode text executable
libinput-quirks:                    ELF 32-bit LSB pie executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-uClibc.so.0, stripped
libinput-record:                    ELF 32-bit LSB pie executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-uClibc.so.0, stripped
libinput-replay:                    Python script, UTF-8 Unicode text executable

To avoid adding a python interpreter dependency on libinput package,
add a new libinput option to keep these tools (installed by
default) only when python is available on the target. Otherwise
remove them from the target.

Signed-off-by: Romain Naour <romain.naour@smile.fr>
Cc: Yann E. MORIN <yann.morin.1998@free.fr>
---
libinput install unconditionally python scripts without checking if python is available.
It's not really nice to have to remove them from .mk.
---
 package/libinput/Config.in   | 22 ++++++++++++++++++++++
 package/libinput/libinput.mk | 20 ++++++++++++++++++++
 2 files changed, 42 insertions(+)
diff mbox series

Patch

diff --git a/package/libinput/Config.in b/package/libinput/Config.in
index 14e4e70f96..1a8fcc7ed4 100644
--- a/package/libinput/Config.in
+++ b/package/libinput/Config.in
@@ -13,5 +13,27 @@  config BR2_PACKAGE_LIBINPUT
 
 	  http://freedesktop.org/wiki/Software/libinput/
 
+if BR2_PACKAGE_LIBINPUT
+
+config BR2_PACKAGE_LIBINPUT_PYTHON_TOOLS
+	bool "install python tools "
+	depends on BR2_PACKAGE_PYTHON3
+	select BR2_PACKAGE_PYTHON_LIBEVDEV # runtime
+	select BR2_PACKAGE_PYTHON_PYUDEV # runtime
+	select BR2_PACKAGE_PYTHON_PYYAML # runtime
+	help
+	  Install python tools:
+	  libinput-analyze-per-slot-delta,
+	  libinput-analyze-recording,
+	  libinput-analyze-touch-down-state,
+	  libinput-measure-fuzz,
+	  libinput-measure-touchpad-pressure,
+	  libinput-measure-touchpad-size,
+	  libinput-measure-touchpad-tap,
+	  libinput-measure-touch-size,
+	  libinput-replay
+
+endif
+
 comment "libinput needs udev /dev management"
 	depends on !BR2_PACKAGE_HAS_UDEV
diff --git a/package/libinput/libinput.mk b/package/libinput/libinput.mk
index a66b0afde5..8c8e0a49a3 100644
--- a/package/libinput/libinput.mk
+++ b/package/libinput/libinput.mk
@@ -30,4 +30,24 @@  else
 LIBINPUT_CONF_OPTS += -Ddebug-gui=false
 endif
 
+ifeq ($(BR2_PACKAGE_LIBINPUT_PYTHON_TOOLS),)
+LIBINPUT_PYTHON_TOOLS = libinput-analyze-per-slot-delta \
+	libinput-analyze-recording \
+	libinput-analyze-touch-down-state \
+	libinput-measure-fuzz \
+	libinput-measure-touchpad-pressure \
+	libinput-measure-touchpad-size \
+	libinput-measure-touchpad-tap \
+	libinput-measure-touch-size \
+	libinput-replay
+
+define LIBINPUT_REMOVE_UNNEEDED_FILES
+	for i in $(LIBINPUT_PYTHON_TOOLS) ; do \
+		rm -f $(TARGET_DIR)/usr/libexec/libinput/$$i ; \
+	done
+endef
+
+LIBINPUT_POST_INSTALL_TARGET_HOOKS += LIBINPUT_REMOVE_UNNEEDED_FILES
+endif
+
 $(eval $(meson-package))