| 1 | From: Jakub Jirutka <[email protected]>
|
| 2 | Date: Sat, 11 Sep 2021 22:52:03 +0200
|
| 3 | Subject: [PATCH] Hack fprint-list-udev-hwdb to generate udev rules
|
| 4 |
|
| 5 | hwdb is systemd/udev specific, it's not widely supported. Let me quote
|
| 6 | author of libudev-zero:
|
| 7 |
|
| 8 | > Udev hwdb is yet another illustration of systemd-like approach. What the
|
| 9 | > hell "userspace /dev" has to do with parsing hardware
|
| 10 | > database(pci.ids, usb.ids) and setting/remapping buttons? Udev smells
|
| 11 | > like systemd by trying to implement all possible functionality in the
|
| 12 | > single daemon/code base. Standalone UNIX-way programs much better
|
| 13 | > suited for such purposes.
|
| 14 |
|
| 15 | This patch adds hacky support for generating classic udev rules (same as
|
| 16 | in the older versions) into fprint-list-udev-hwdb program - if environment
|
| 17 | variable HACK_GEN_RULES is present, it outputs udev rules instead of hwdb
|
| 18 | entries.
|
| 19 |
|
| 20 | See https://gitlab.freedesktop.org/libfprint/libfprint/-/issues/336
|
| 21 |
|
| 22 | diff --git a/libfprint/fprint-list-udev-hwdb.c b/libfprint/fprint-list-udev-hwdb.c
|
| 23 | index dadb303..d2c4ada 100644
|
| 24 | |
| 25 | |
| 26 | @@ -20,6 +20,7 @@
|
| 27 | */
|
| 28 |
|
| 29 | #include <config.h>
|
| 30 | +#include <stdlib.h>
|
| 31 |
|
| 32 | #include "fpi-context.h"
|
| 33 | #include "fpi-device.h"
|
| 34 | @@ -119,6 +120,8 @@
|
| 35 |
|
| 36 | GHashTable *printed = NULL;
|
| 37 |
|
| 38 | +static int HACK_gen_rules = 0;
|
| 39 | +
|
| 40 | static void
|
| 41 | print_driver (const FpDeviceClass *cls)
|
| 42 | {
|
| 43 | @@ -161,12 +164,19 @@
|
| 44 | g_print ("\n# Known unsupported devices\n");
|
| 45 | }
|
| 46 |
|
| 47 | + if (!HACK_gen_rules) {
|
| 48 | g_print ("usb:v%04Xp%04X*\n",
|
| 49 | entry->vid, entry->pid);
|
| 50 | + } else {
|
| 51 | + g_print ("SUBSYSTEM==\"usb\", ATTRS{idVendor}==\"%04x\", ATTRS{idProduct}==\"%04x\", ATTRS{dev}==\"*\", TEST==\"power/control\", ATTR{power/control}=\"auto\"\n",
|
| 52 | + entry->vid, entry->pid);
|
| 53 | + g_print ("SUBSYSTEM==\"usb\", ATTRS{idVendor}==\"%04x\", ATTRS{idProduct}==\"%04x\", ENV{LIBFPRINT_DRIVER}=\"%s\"\n",
|
| 54 | + entry->vid, entry->pid, cls->full_name);
|
| 55 | + }
|
| 56 | num_printed++;
|
| 57 | }
|
| 58 |
|
| 59 | - if (num_printed > 0)
|
| 60 | + if (num_printed > 0 && !HACK_gen_rules)
|
| 61 | {
|
| 62 | g_print (" ID_AUTOSUSPEND=1\n");
|
| 63 | g_print (" ID_PERSIST=0\n");
|
| 64 | @@ -190,6 +200,7 @@
|
| 65 | guint i;
|
| 66 |
|
| 67 | program_name = g_path_get_basename (argv[0]);
|
| 68 | + HACK_gen_rules = getenv ("HACK_GEN_RULES") != NULL;
|
| 69 |
|
| 70 | g_print ("# SPDX-License-Identifier: LGPL-2.1-or-later\n");
|
| 71 | g_print ("# This file has been generated using %s with all drivers enabled\n",
|