Subject: Re: bug#39926: Regression introduced by Shepherd 0.7.0 ('make check-system TESTS=btrfs-root-os' fails)

From: Ludovic Courtès <[email-masked]>
Date: Sat, 07 Mar 2020 12:33:08 +0100

The build log of <https://ci.guix.gnu.org/build/2356870/details> has:

--8<---------------cut here---------------start------------->8---
guix system: [1m[0mbootloader successfully installed on '[1m/dev/vdb[0m'
+ sync
[  194.803139] udevd[313]: failed to execute '/gnu/store/pxw38aa6wwxyd2ws9pkzj4m68qrmjscd-eudev-3.2.9/lib/udev/${exec_prefix}/bin/udevadm' '${exec_prefix}/bin/udevadm trigger -s block -p ID_BTRFS_READY=0': No such file or directory
--8<---------------cut here---------------end--------------->8---

The broken udev rule is ‘64-btrfs.rules’ in eudev:

--8<---------------cut here---------------start------------->8---
# reconsider pending devices in case when multidevice volume awaits
ENV{ID_BTRFS_READY}=="1", RUN+="${exec_prefix}/bin/udevadm trigger -s block -p ID_BTRFS_READY=0"
--8<---------------cut here---------------end--------------->8---

… where “${exec_prefix}” is expanded from “@bindir@”, a classical
issue that we should report upstream.  :-)

In the meantime, the following patch should solve the problem.  I’m
running the test now, and if it passes and you’re fine with it, I’ll
commit it.

It’s pleasant we have tests to catch such issues!

Thanks,
Ludo’.

diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index 64ea566dbd..3884e15233 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <[email-masked]>
+;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <[email-masked]>
 ;;; Copyright © 2013, 2014, 2015, 2016 Andreas Enge <[email-masked]>
 ;;; Copyright © 2012 Nikita Karetnikov <[email-masked]>
 ;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019, 2020 Mark H Weaver <[email-masked]>
@@ -2870,6 +2870,26 @@ device nodes from /dev/, handles hotplug events and loads drivers at boot
 time.")
     (license license:gpl2+)))
 
+;; TODO: Merge with eudev on the next rebuild cycle.
+(define-public eudev/btrfs-fix
+  (package/inherit
+   eudev
+   (version (string-append (package-version eudev) "-1"))
+   (arguments
+    (substitute-keyword-arguments (package-arguments eudev)
+      ((#:phases phases '%standard-phases)
+       `(modify-phases ,phases
+          (add-before 'configure 'patch-bindir-in-btrfs-rules
+            (lambda* (#:key outputs #:allow-other-keys)
+              ;; The "@bindir@" substitution incorrectly expands to a literal
+              ;; "${exec_prefix}" (see <https://bugs.gnu.org/39926>).  Work
+              ;; around it.
+              (let ((out (assoc-ref outputs "out")))
+                (substitute* "rules/64-btrfs.rules.in"
+                  (("@bindir@")
+                   (string-append out "/bin")))
+                #t)))))))))
+
 (define-public eudev-with-hwdb
   (deprecated-package "eudev-with-hwdb" eudev))
 
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index 706b3ae7ec..0c8978790d 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -1,5 +1,5 @@
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <[email-masked]>
+;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <[email-masked]>
 ;;; Copyright © 2015, 2016 Alex Kost <[email-masked]>
 ;;; Copyright © 2015, 2016 Mark H Weaver <[email-masked]>
 ;;; Copyright © 2015 Sou Bunnbu <[email-masked]>
@@ -1918,7 +1918,7 @@ archive}).  If that is not the case, the service will fail to start."
   udev-configuration make-udev-configuration
   udev-configuration?
   (udev   udev-configuration-udev                 ;<package>
-          (default eudev))
+          (default eudev/btrfs-fix))
   (rules  udev-configuration-rules                ;list of <package>
           (default '())))