make udev rules more robust (#243953)

This commit is contained in:
Nils Philippsen 2007-08-08 11:42:18 +00:00
parent 221b0f84f4
commit 4201f50a16
3 changed files with 82 additions and 23 deletions

View File

@ -1,11 +1,83 @@
--- sane-backends-1.0.18/tools/sane-desc.c.udev-098 2007-07-22 23:23:51.000000000 +0200 --- sane-backends-1.0.18/tools/sane-desc.c.udev-098 2007-08-07 14:56:03.000000000 +0200
+++ sane-backends-1.0.18/tools/sane-desc.c 2007-07-22 23:24:37.000000000 +0200 +++ sane-backends-1.0.18/tools/sane-desc.c 2007-08-08 12:45:27.000000000 +0200
@@ -3187,7 +3187,7 @@ print_udev (void) @@ -3153,14 +3153,14 @@ print_udev_header (void)
("#\n"
"# udev rules file for supported USB devices\n"
"#\n"
- "# To add a USB device, add a rule to the list below between the SUBSYSTEM...\n"
- "# and LABEL... lines.\n"
+ "# To add support for a USB device, add rules to the \"usb\" and \"usb_device\"\n"
+ "# lists below between their respective \"# BEGIN ...\" and \"# END ...\" lines.\n"
"#\n"
"# To run a script when your device is plugged in, add RUN=\"/path/to/script\"\n"
- "# to the appropriate rule.\n");
+ "# to the appropriate rules.\n");
printf
("#\n"
- "# The following list already contains a lot of scanners. If your scanner\n"
+ "# The following lists already contains a lot of scanners. If your scanner\n"
"# isn't mentioned there, add it as explained above and mail the entry to\n"
"# the sane-devel mailing list (sane-devel@lists.alioth.debian.org).\n"
"#\n");
@@ -3169,11 +3169,44 @@ print_udev_header (void)
static void
print_udev (void)
{
- usbid_type *usbid = create_usbids_table ();
+ usbid_type *usbid_first = create_usbids_table ();
+ usbid_type *usbid = usbid_first;
print_udev_header ();
+
printf ("\nACTION!=\"add\", GOTO=\"libsane_rules_end\"\n");
- printf ("SUBSYSTEM!=\"usb_device\", GOTO=\"libsane_rules_end\"\n\n");
+ printf ("\nATTR{dev}!=\"?*\", GOTO=\"libsane_rules_end\"\n");
+ printf ("SUBSYSTEM==\"usb\", GOTO=\"libsane_usb_rules\"\n");
+ printf ("SUBSYSTEM==\"usb_device\", GOTO=\"libsane_usb_device_rules\"\n\n");
+ printf ("GOTO=\"libsane_rules_end\"\n\n");
+
+ /* SUBSYSTEM=="usb" -> ATTR{} */
+ printf ("LABEL=\"libsane_usb_rules\"\n\n");
+ printf ("# BEGIN scanner rules for SUBSYSTEM==\"usb\"\n");
+ while (usbid)
+ {
+ manufacturer_model_type * name = usbid->name;
+
+ printf ("# ");
+ while (name)
+ {
+ if (name != usbid->name)
+ printf (" | ");
+ printf ("%s", name->name);
+ name = name->next;
+ }
+ printf ("\n");
+ printf ("ATTR{idVendor}==\"%s\", ATTR{idProduct}==\"%s\", SYMLINK+=\"scanner-%%k\"\n",
+ usbid->usb_vendor_id + 2, usbid->usb_product_id + 2);
+ usbid = usbid->next;
+ }
+ printf ("# END scanner rules for SUBSYSTEM==\"usb\"\n");
+ printf ("GOTO=\"libsane_rules_end\"\n\n");
+
+ /* SUBSYSTEM=="usb_device" -> ATTRS{} */
+ printf ("LABEL=\"libsane_usb_device_rules\"\n\n");
+ printf ("# BEGIN scanner rules for SUBSYSTEM==\"usb_device\"\n");
+ usbid = usbid_first;
while (usbid)
{
manufacturer_model_type * name = usbid->name;
@@ -3187,10 +3220,13 @@ print_udev (void)
name = name->next; name = name->next;
} }
printf ("\n"); printf ("\n");
- printf ("SYSFS{idVendor}==\"%s\", SYSFS{idProduct}==\"%s\", SYMLINK+=\"scanner-%%k\"\n", - printf ("SYSFS{idVendor}==\"%s\", SYSFS{idProduct}==\"%s\", SYMLINK+=\"scanner-%%k\"\n",
+ printf ("ATTR{idVendor}==\"%s\", ATTR{idProduct}==\"%s\", SYMLINK+=\"scanner-%%k\"\n", + printf ("ATTRS{idVendor}==\"%s\", ATTRS{idProduct}==\"%s\", SYMLINK+=\"scanner-%%k\"\n",
usbid->usb_vendor_id + 2, usbid->usb_product_id + 2); usbid->usb_vendor_id + 2, usbid->usb_product_id + 2);
usbid = usbid->next; usbid = usbid->next;
} }
+ printf ("# END scanner rules for SUBSYSTEM==\"usb_device\"\n");
+ printf ("GOTO=\"libsane_rules_end\"\n");
+
printf ("\nLABEL=\"libsane_rules_end\"\n");
}

View File

@ -1,14 +0,0 @@
--- sane-backends-1.0.18/tools/sane-desc.c.udev-new-kernels 2007-07-24 18:34:10.000000000 +0200
+++ sane-backends-1.0.18/tools/sane-desc.c 2007-07-24 18:37:08.000000000 +0200
@@ -3173,7 +3173,10 @@ print_udev (void)
print_udev_header ();
printf ("\nACTION!=\"add\", GOTO=\"libsane_rules_end\"\n");
- printf ("SUBSYSTEM!=\"usb_device\", GOTO=\"libsane_rules_end\"\n\n");
+ printf ("SUBSYSTEM==\"usb\", GOTO=\"libsane_rules\"\n");
+ printf ("SUBSYSTEM==\"usb_device\", GOTO=\"libsane_rules\"\n\n");
+ printf ("GOTO=\"libsane_rules_end\"\n\n");
+ printf ("LABEL=\"libsane_rules\"\n\n");
while (usbid)
{
manufacturer_model_type * name = usbid->name;

View File

@ -24,7 +24,7 @@
Summary: Scanner access software Summary: Scanner access software
Name: sane-backends Name: sane-backends
Version: 1.0.18 Version: 1.0.18
Release: 13%{?dist} Release: 14%{?dist}
License: GPL (programs), relaxed LGPL (libraries), and public domain (docs) License: GPL (programs), relaxed LGPL (libraries), and public domain (docs)
Group: System Environment/Libraries Group: System Environment/Libraries
Source0: ftp://ftp.sane-project.org/pub/sane/%{name}-%{version}/%{name}-%{version}.tar.gz Source0: ftp://ftp.sane-project.org/pub/sane/%{name}-%{version}/%{name}-%{version}.tar.gz
@ -36,8 +36,7 @@ Patch4: sane-backends-1.0.17-pkgconfig.patch
Patch5: sane-backends-1.0.18-logical_vs_binary.patch Patch5: sane-backends-1.0.18-logical_vs_binary.patch
Patch6: sane-backends-1.0.18-usb_reset.patch Patch6: sane-backends-1.0.18-usb_reset.patch
Patch7: sane-backends-1.0.18-udev-symlink.patch Patch7: sane-backends-1.0.18-udev-symlink.patch
Patch8: sane-backends-1.0.18-udev-new-kernels.patch Patch8: sane-backends-1.0.18-udev-098.patch
Patch9: sane-backends-1.0.18-udev-098.patch
URL: http://www.sane-project.org URL: http://www.sane-project.org
BuildRoot: %{_tmppath}/%{name}-%{version}-root-%(%__id_u -n) BuildRoot: %{_tmppath}/%{name}-%{version}-root-%(%__id_u -n)
BuildRequires: tetex-latex libusb-devel libieee1284-devel libjpeg-devel BuildRequires: tetex-latex libusb-devel libieee1284-devel libjpeg-devel
@ -124,10 +123,9 @@ want to access digital cameras.
%patch5 -p1 -b .logical_vs_binary %patch5 -p1 -b .logical_vs_binary
%patch6 -p1 -b .usb_reset %patch6 -p1 -b .usb_reset
%patch7 -p1 -b .udev-symlink %patch7 -p1 -b .udev-symlink
%patch8 -p1 -b .udev-new-kernels
%if %udev_098 %if %udev_098
%patch9 -p1 -b .udev-098 %patch8 -p1 -b .udev-098
%endif %endif
for i in agfafocus avision coolscan2 umax_pp; do for i in agfafocus avision coolscan2 umax_pp; do
@ -248,6 +246,9 @@ rm -rf %{buildroot}
%{_libdir}/pkgconfig/sane-backends.pc %{_libdir}/pkgconfig/sane-backends.pc
%changelog %changelog
* Wed Aug 08 2007 Nils Philippsen <nphilipp@redhat.com> - 1.0.18-14
- make udev rules more robust (#243953)
* Wed Jul 25 2007 Jeremy Katz <katzj@redhat.com> - 1.0.18-13 * Wed Jul 25 2007 Jeremy Katz <katzj@redhat.com> - 1.0.18-13
- rebuild for toolchain bug - rebuild for toolchain bug