diff mbox series

[bug#65853,v2] gnu: scilab: Fix and hardcode script inputs.

Message ID 0dd0a7387a8232abd43f484b87f183c9340497b0.1695927790.git.ngraves@ngraves.fr
State New
Headers show
Series [bug#65853,v2] gnu: scilab: Fix and hardcode script inputs. | expand

Commit Message

Nicolas Graves Sept. 28, 2023, 7:03 p.m. UTC
* 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(-)


base-commit: f9784991eb6c7ec1a20f76d080873a3319be0908

Comments

Ludovic Courtès Oct. 5, 2023, 2:51 p.m. UTC | #1
Hi,

Nicolas Graves <ngraves@ngraves.fr> skribis:

> +            (add-after 'install 'hardcode-script-inputs
> +              (lambda _
> +                (substitute* (string-append #$output "/bin/scilab")
> +                  (("grep")
> +                   (search-inputs-file #$inputs "/bin/grep"))

I’ll contradict Efraim, but hopefully they’ll pardon me: I’d write it
like so:

  (lambda* (#:key inputs #:allow-other-keys)
    (substitute* …
      (("grep")
       (search-input-file inputs "/bin/grep"))))

That way it’ll DTRT even when creating a variant of this package.

(The code above had a typo too, with “inputs” as plural.)

Could you send one last updated patch?

Thanks,
Ludo’.
Nicolas Graves Oct. 5, 2023, 3:09 p.m. UTC | #2
On 2023-10-05 16:51, Ludovic Courtès wrote:

> Hi,
>
> Nicolas Graves <ngraves@ngraves.fr> skribis:
>
>> +            (add-after 'install 'hardcode-script-inputs
>> +              (lambda _
>> +                (substitute* (string-append #$output "/bin/scilab")
>> +                  (("grep")
>> +                   (search-inputs-file #$inputs "/bin/grep"))
>
> I’ll contradict Efraim, but hopefully they’ll pardon me: I’d write it
> like so:
>
>   (lambda* (#:key inputs #:allow-other-keys)
>     (substitute* …
>       (("grep")
>        (search-input-file inputs "/bin/grep"))))
>
> That way it’ll DTRT even when creating a variant of this package.
>
> (The code above had a typo too, with “inputs” as plural.)
>
> Could you send one last updated patch?

Yes, it also has to be rebased now that scilab is version 2023. 
>
> Thanks,
> Ludo’.
diff mbox series

Patch

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