From c19ce3a711fea24c173d615a4a7b162dbc86ce68 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@gnu.org>
Date: Sat, 13 Sep 2014 10:47:58 +0200
Subject: [PATCH] gnu: eudev: Honor $EUDEV_RULES_DIRECTORY.

* gnu/packages/patches/eudev-rules-directory.patch: New file.
* gnu-system.am (dist_patch_DATA): Add it.
* gnu/packages/linux.scm (eudev): Use it.
---
 gnu-system.am                                 |  1 +
 gnu/packages/linux.scm                        |  3 +-
 .../patches/eudev-rules-directory.patch       | 36 +++++++++++++++++++
 3 files changed, 39 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/eudev-rules-directory.patch

diff --git a/gnu-system.am b/gnu-system.am
index 44cdd2738a3..d5d509e8d77 100644
--- a/gnu-system.am
+++ b/gnu-system.am
@@ -321,6 +321,7 @@ dist_patch_DATA =						\
   gnu/packages/patches/doxygen-test.patch			\
   gnu/packages/patches/doxygen-tmake.patch			\
   gnu/packages/patches/emacs-configure-sh.patch			\
+  gnu/packages/patches/eudev-rules-directory.patch		\
   gnu/packages/patches/findutils-absolute-paths.patch		\
   gnu/packages/patches/flashrom-use-libftdi1.patch		\
   gnu/packages/patches/flex-bison-tests.patch			\
diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index 8550dc0d331..ff6de2b0774 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -1377,7 +1377,8 @@ (define-public eudev
                     version ".tar.gz"))
               (sha256
                (base32
-                "1w6f8h7fhjz3prs630f8gawv7jx74zi600z0pm997kkp24pyj5wg"))))
+                "1w6f8h7fhjz3prs630f8gawv7jx74zi600z0pm997kkp24pyj5wg"))
+              (patches (list (search-patch "eudev-rules-directory.patch")))))
     (arguments
      (substitute-keyword-arguments (package-arguments udev)
        ((#:configure-flags flags)
diff --git a/gnu/packages/patches/eudev-rules-directory.patch b/gnu/packages/patches/eudev-rules-directory.patch
new file mode 100644
index 00000000000..9173e22f764
--- /dev/null
+++ b/gnu/packages/patches/eudev-rules-directory.patch
@@ -0,0 +1,36 @@
+Add $EUDEV_RULES_DIRECTORY to the list of rules directories.
+
+The old udev 182 supported $UDEV_CONFIG_FILE, which in turn allowed
+the search path to be customized, but eudev no longer has this, hence
+this hack.
+
+--- eudev-1.9/src/udev/udev-rules.c	2014-09-13 10:21:59.615980259 +0200
++++ eudev-1.9/src/udev/udev-rules.c	2014-09-13 10:24:13.839976335 +0200
+@@ -46,15 +46,11 @@
+         };
+ };
+ 
+-static const char* const rules_dirs[] = {
++static const char* rules_dirs[] = {
+         UDEV_CONF_DIR "/rules.d",
+         UDEV_RULES_DIR,
+-        "/run/udev/rules.d",
+         UDEV_LIBEXEC_DIR "/rules.d",
+-#ifdef HAVE_SPLIT_USR
+-        "/lib/udev/rules.d",
+-        "/usr/lib/udev/rules.d",
+-#endif
++	NULL,			  /* placeholder for $EUDEV_RULES_DIRECTORY */
+         NULL};
+ 
+ struct udev_rules {
+@@ -1637,6 +1633,9 @@
+ 
+         udev_rules_check_timestamp(rules);
+ 
++	/* Allow the user to specify an additional rules directory.  */
++	rules_dirs[3] = getenv("EUDEV_RULES_DIRECTORY");
++
+         r = conf_files_list_strv(&files, ".rules", NULL, rules_dirs);
+         if (r < 0) {
+                 log_error("failed to enumerate rules files: %s", strerror(-r));
-- 
GitLab