From: Jakub Jirutka Date: Sat, 11 Sep 2021 22:52:03 +0200 Subject: [PATCH] Hack fprint-list-udev-hwdb to generate udev rules hwdb is systemd/udev specific, it's not widely supported. Let me quote author of libudev-zero: > Udev hwdb is yet another illustration of systemd-like approach. What the > hell "userspace /dev" has to do with parsing hardware > database(pci.ids, usb.ids) and setting/remapping buttons? Udev smells > like systemd by trying to implement all possible functionality in the > single daemon/code base. Standalone UNIX-way programs much better > suited for such purposes. This patch adds hacky support for generating classic udev rules (same as in the older versions) into fprint-list-udev-hwdb program - if environment variable HACK_GEN_RULES is present, it outputs udev rules instead of hwdb entries. See https://gitlab.freedesktop.org/libfprint/libfprint/-/issues/336 diff --git a/libfprint/fprint-list-udev-hwdb.c b/libfprint/fprint-list-udev-hwdb.c index dadb303..d2c4ada 100644 --- a/libfprint/fprint-list-udev-hwdb.c +++ b/libfprint/fprint-list-udev-hwdb.c @@ -20,6 +20,7 @@ */ #include +#include #include "fpi-context.h" #include "fpi-device.h" @@ -119,6 +120,8 @@ GHashTable *printed = NULL; +static int HACK_gen_rules = 0; + static void print_driver (const FpDeviceClass *cls) { @@ -161,12 +164,19 @@ g_print ("\n# Known unsupported devices\n"); } + if (!HACK_gen_rules) { g_print ("usb:v%04Xp%04X*\n", entry->vid, entry->pid); + } else { + g_print ("SUBSYSTEM==\"usb\", ATTRS{idVendor}==\"%04x\", ATTRS{idProduct}==\"%04x\", ATTRS{dev}==\"*\", TEST==\"power/control\", ATTR{power/control}=\"auto\"\n", + entry->vid, entry->pid); + g_print ("SUBSYSTEM==\"usb\", ATTRS{idVendor}==\"%04x\", ATTRS{idProduct}==\"%04x\", ENV{LIBFPRINT_DRIVER}=\"%s\"\n", + entry->vid, entry->pid, cls->full_name); + } num_printed++; } - if (num_printed > 0) + if (num_printed > 0 && !HACK_gen_rules) { g_print (" ID_AUTOSUSPEND=1\n"); g_print (" ID_PERSIST=0\n"); @@ -190,6 +200,7 @@ guint i; program_name = g_path_get_basename (argv[0]); + HACK_gen_rules = getenv ("HACK_GEN_RULES") != NULL; g_print ("# SPDX-License-Identifier: LGPL-2.1-or-later\n"); g_print ("# This file has been generated using %s with all drivers enabled\n",