Subject: [bug#60129] [PATCH 1/2] activation: Firmware activation handles missing support in kernel.

From: Marius Bakke <[email-masked]>
Date: Fri, 16 Dec 2022 23:15:33 +0100

* gnu/build/activation.scm (activate-firmware): Check if firmware loading is
enabled before attempting to use it.
---
 gnu/build/activation.scm | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/gnu/build/activation.scm b/gnu/build/activation.scm
index 10c9045740..af1aa0f4c4 100644
--- a/gnu/build/activation.scm
+++ b/gnu/build/activation.scm
@@ -363,9 +363,12 @@ (define (activate-firmware directory)
   "Tell the kernel to look for device firmware under DIRECTORY.  This
 mechanism bypasses udev: it allows Linux to handle firmware loading directly
 by itself, without having to resort to a \"user helper\"."
-  (call-with-output-file "/sys/module/firmware_class/parameters/path"
-    (lambda (port)
-      (display directory port))))
+  ;; If the kernel was built without firmware loading support, this file
+  ;; does not exist.  Do nothing in that case.
+  (when (file-exists? "/sys/module/firmware_class/parameters/path")
+    (call-with-output-file "/sys/module/firmware_class/parameters/path"
+      (lambda (port)
+        (display directory port)))))
 
 (define (activate-ptrace-attach)
   "Allow users to PTRACE_ATTACH their own processes.
-- 
2.38.0