Subject: [bug#69944] [PATCH] gnu: dmraid: Fix cross-compiling to riscv64-linux.

From: Zheng Junjie <[email-masked]>
Date: Sat, 23 Mar 2024 00:44:44 +0800

* gnu/packages/disk.scm (dmraid)
[native-inputs]: When cross compiling to riscv64-linux-gnu, add config.
[arguments]: When target riscv64-linux-gnu, add update-config phase.

Change-Id: I491c43a6ce2c3fc3aed43ecab9d4a2ab251038bb
---
 gnu/packages/disk.scm | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/gnu/packages/disk.scm b/gnu/packages/disk.scm
index b0117d77ce..5339f54d99 100644
--- a/gnu/packages/disk.scm
+++ b/gnu/packages/disk.scm
@@ -27,7 +27,7 @@
 ;;; Copyright © 2022 Disseminate Dissent <[email-masked]>
 ;;; Copyright © 2023 Timotej Lazar <[email-masked]>
 ;;; Copyright © 2023 Morgan Smith <[email-masked]>
-;;; Copyright © 2023 Zheng Junjie <[email-masked]>
+;;; Copyright © 2023, 2024 Zheng Junjie <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1145,7 +1145,12 @@ (define-public dmraid
                 "1n7vsqvh7y6yvil682q129d21yhb0cmvd5fvsbkza7ypd78inhlk"))))
     (build-system gnu-build-system)
     (inputs (list lvm2))
-    (native-inputs (list which))
+    (native-inputs
+     (append (if (and (target-riscv64?)
+                      (%current-target-system))
+                 (list config)
+                 '())
+             (list which)))
     (arguments
      `(#:tests? #f                      ; No tests.
        ;; Prevent a race condition where some target would attempt to link
@@ -1158,7 +1163,18 @@ (define-public dmraid
                       (chdir (string-append ,version "/dmraid"))
                       (substitute* "make.tmpl.in"
                         (("/bin/sh") (which "sh")))
-                      #t)))
+                      #t))
+                  ,@(if (and (target-riscv64?)
+                             (%current-target-system))
+                        `((add-after 'unpack 'update-config
+                            (lambda* (#:key native-inputs inputs #:allow-other-keys)
+                              (for-each (lambda (file)
+                                          (install-file
+                                           (search-input-file
+                                            (or native-inputs inputs)
+                                            (string-append "/bin/" file)) "."))
+                                        '("config.guess" "config.sub")))))
+                        '()))
        #:configure-flags (list ;; Make sure programs such as 'dmevent_tool' can
                                ;; find libdmraid.so.
                                (string-append "LDFLAGS=-Wl,-rpath="

base-commit: 40f53e8fb5b867e3a1e8fa798328423718282aac
-- 
2.41.0