Subject: [PATCH v2] gnu: scilab: Fix and hardcode script inputs.

From: Nicolas Graves <[email-masked]>
Date: Thu, 28 Sep 2023 21:03:10 +0200

* gnu/packages/maths.scm (scilab): Fix script inputs.
[inputs]: Reorder alphabetically. Add coreutils-minimal, grep, sed.
[arguments](phases): Add phase hardcode-script-inputs.
---
 gnu/packages/maths.scm | 46 +++++++++++++++++++++++++++---------------
 1 file changed, 30 insertions(+), 16 deletions(-)

diff --git a/gnu/packages/maths.scm b/gnu/packages/maths.scm
index 62d4adfbd1..f7e1de41f3 100644
--- a/gnu/packages/maths.scm
+++ b/gnu/packages/maths.scm
@@ -8433,22 +8433,25 @@ (define-public scilab
         (base32 "0phg9pn24yw98hbh475ik84dnikf1225b2knh7qbhdbdx6fm2d57"))))
     (build-system gnu-build-system)
     (native-inputs (list pkg-config gfortran))
-    (inputs (list libxml2
+    (inputs (list arpack-ng
+                  coreutils-minimal
+                  curl
+                  fftw
+                  gettext-minimal
+                  grep
+                  hdf5-1.8
+                  lapack
+                  libxml2
+                  libx11
+                  matio
+                  openblas
                   `(,pcre "bin")
                   `(,pcre "out")
                   readline
-                  hdf5-1.8
-                  curl
-                  openblas
-                  lapack
-                  arpack-ng
-                  fftw
-                  gettext-minimal
+                  sed
                   suitesparse-3
                   tcl
-                  tk
-                  libx11
-                  matio))
+                  tk))
     (arguments
      `(#:tests? #f
        #:configure-flags
@@ -8484,10 +8487,6 @@ (define-public scilab
        ,#~(modify-phases %standard-phases
             (add-before 'build 'pre-build
               (lambda _
-                ;; Fix scilab script.
-                (substitute* "bin/scilab"
-                  (("\\/bin\\/ls")
-                   (which "ls")))
                 ;; Fix core.start.
                 (substitute* "modules/core/etc/core.start"
                   (("'SCI/modules")
@@ -8519,7 +8518,22 @@ (define-public scilab
                   (("if \\(array_size > 0\\)")
                    "if (*array_size > 0)"))
                 ;; Set SCIHOME to /tmp before macros compilation.
-                (setenv "SCIHOME" "/tmp"))))))
+                (setenv "SCIHOME" "/tmp")))
+            (add-after 'install 'hardcode-script-inputs
+              (lambda _
+                (substitute* (string-append #$output "/bin/scilab")
+                  (("grep")
+                   (search-inputs-file #$inputs "/bin/grep"))
+                  ((" sed ")  ; some "sed" strings are not binaries invocations
+                   (string-append " " (search-inputs-file #$inputs "/bin/sed") " "))
+                  (("/bin/ls")
+                   (search-inputs-file #$inputs "/bin/ls"))
+                  (("uname")
+                   (search-inputs-file #$inputs "/bin/uname"))
+                  (("dirname")
+                   (search-inputs-file #$inputs "/bin/dirname"))
+                  (("basename")
+                   (search-inputs-file #$inputs "/bin/basename"))))))))
     (home-page "https://scilab.org")
     (synopsis "Software for engineers and scientists")
     (description "This package provides the non-graphical version of the Scilab

base-commit: f9784991eb6c7ec1a20f76d080873a3319be0908
-- 
2.41.0