Subject: [PATCH] gnu: jpegoptim: fix riscv64 cross-build.

From: Z572 <[email-masked]>
Date: Sat, 25 Mar 2023 12:51:34 +0800

* gnu/packages/image.scm (jpegoptim): fix riscv64 cross-build.
[arguments]: when target-riscv64, add phase to update-config-scripts
[native-inputs]: when target-riscv64, add config.
---
 gnu/packages/image.scm | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/image.scm b/gnu/packages/image.scm
index 81cdcd778e..3148ddee3c 100644
--- a/gnu/packages/image.scm
+++ b/gnu/packages/image.scm
@@ -526,8 +526,24 @@ (define-public jpegoptim
        (base32 "06f6d08xvmsiki4mc1qs985gsjqmsxx793a93b72y25q84wbg9x9"))))
    (build-system gnu-build-system)
    (inputs (list libjpeg-turbo))
+   (native-inputs
+    (if (target-riscv64?)
+        (list config)
+        '()))
    (arguments
-    '(#:tests? #f))                     ; no tests
+    `(#:tests? #f                       ; no tests
+      ,@(if (target-riscv64?)
+            (list #:phases
+                  #~(modify-phases %standard-phases
+                             (add-after 'unpack 'update-config-scripts
+                               (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)) "./tools"))
+                                           '("config.guess" "config.sub"))))))
+            '())))
    (synopsis "Optimize JPEG images")
    (description
     "jpegoptim provides lossless optimization (based on optimizing
-- 
2.39.2