diff mbox series

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

Message ID 0852115dc8e706b80b05d57cfbfae64de79fdac5.1694362722.git.ngraves@ngraves.fr
State New
Headers show
Series [bug#65853] gnu: scilab: Fix and hardcode script inputs. | expand

Commit Message

Nicolas Graves Sept. 10, 2023, 4:18 p.m. UTC
* gnu/packages/maths.scm (scilab): Fix script inputs.
[inputs]: Reorder alphabetically. Add coreutils, grep, sed.
[arguments](phases): Add phase hardcode-script-inputs.
---
 gnu/packages/maths.scm | 43 ++++++++++++++++++++++++++++++------------
 1 file changed, 31 insertions(+), 12 deletions(-)


base-commit: 2eb6df537c36da8bf8e81ff698421f6fb1bfd1ab
prerequisite-patch-id: eb618ab7b10483d917c308a38792af98baa517e2
prerequisite-patch-id: 40b6c9f09f27833367a71ec25d77afae4d2a835e
prerequisite-patch-id: c12968d02d99c253f858586a86b16fa32d41f1c1
prerequisite-patch-id: 09d995d48139f8e61183d5634cda13a01cdb50f7
prerequisite-patch-id: 86baa45ec2aad977c8c8135f7613aa391155de6d
prerequisite-patch-id: 3425fbbff6a603d60b4e143ea2141aabf4ddc92c
prerequisite-patch-id: c373c01aab5dcba3503a97d51c62a595147a041c
prerequisite-patch-id: cda857c790b88c681c4e713c5f71e40291970daf
prerequisite-patch-id: 8e234d0f4d93d2aad499eec8842be3d28da98707
prerequisite-patch-id: 5f664cb2fd995a53765c5ffc19a708ac795cc0c4
prerequisite-patch-id: ed447cba9cf9b7e1a1b47aa27acb14f8f2da0a8e
prerequisite-patch-id: 9f80c5bbbfb8cd3347951c4d57634e93ffa79924
prerequisite-patch-id: 1aaa9f0d466e2d6837f75844df48a98beb70ff24
prerequisite-patch-id: 34502820d8c0355b3ed2638c457084edeaba029d
prerequisite-patch-id: a96258da9e78cfb9ac9893cdcdeb38b69b75f134

Comments

Efraim Flashner Sept. 28, 2023, 4:36 p.m. UTC | #1
A couple of things I noticed:

On Sun, Sep 10, 2023 at 06:18:42PM +0200, Nicolas Graves wrote:
> * gnu/packages/maths.scm (scilab): Fix script inputs.
> [inputs]: Reorder alphabetically. Add coreutils, grep, sed.
> [arguments](phases): Add phase hardcode-script-inputs.
> ---
>  gnu/packages/maths.scm | 43 ++++++++++++++++++++++++++++++------------
>  1 file changed, 31 insertions(+), 12 deletions(-)
> 
> diff --git a/gnu/packages/maths.scm b/gnu/packages/maths.scm
> index 38e71e18f8..40883d71c1 100644
> --- a/gnu/packages/maths.scm
> +++ b/gnu/packages/maths.scm
> @@ -8448,22 +8448,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

This can be 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
> @@ -8534,7 +8537,23 @@ (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")
> +                   #$(file-append (this-package-input "grep") "/bin/grep"))

These can be (search-input-file #$inputs "/bin/grep") to make it easier
to swap out the packages for something else if people want.

> +                  (("sed")

I checked the script, it should be ((" sed ") since there are a couple
of instances of 'sed' in the script which aren't invocations of sed.

> +                   #$(file-append (this-package-input "sed") "/bin/sed"))
> +                  (("uname")
> +                   #$(file-append (this-package-input "coreutils")
> +                                  "/bin/uname"))
> +                  (("dirname")
> +                   #$(file-append (this-package-input "coreutils")
> +                                  "/bin/dirname"))
> +                  (("basename")
> +                   #$(file-append (this-package-input "coreutils")
> +                                  "/bin/basename"))))))))

Are there more binaries which should be substituted? I saw glxgears,
chcon, a couple instances of java, pwd, valgrind, docbook paths. And
then there's a couple of other scripts and binaries in the bin/ folder.
I think it'd be better to use wrap-script or wrap-program and then use
substitute* to strip the leading /usr/bin/ from the different calls to
the different binaries.

>      (home-page "https://scilab.org")
>      (synopsis "Software for engineers and scientists")
>      (description "This package provides the non-graphical version of the Scilab
> 
> base-commit: 2eb6df537c36da8bf8e81ff698421f6fb1bfd1ab
> prerequisite-patch-id: eb618ab7b10483d917c308a38792af98baa517e2
> prerequisite-patch-id: 40b6c9f09f27833367a71ec25d77afae4d2a835e
> prerequisite-patch-id: c12968d02d99c253f858586a86b16fa32d41f1c1
> prerequisite-patch-id: 09d995d48139f8e61183d5634cda13a01cdb50f7
> prerequisite-patch-id: 86baa45ec2aad977c8c8135f7613aa391155de6d
> prerequisite-patch-id: 3425fbbff6a603d60b4e143ea2141aabf4ddc92c
> prerequisite-patch-id: c373c01aab5dcba3503a97d51c62a595147a041c
> prerequisite-patch-id: cda857c790b88c681c4e713c5f71e40291970daf
> prerequisite-patch-id: 8e234d0f4d93d2aad499eec8842be3d28da98707
> prerequisite-patch-id: 5f664cb2fd995a53765c5ffc19a708ac795cc0c4
> prerequisite-patch-id: ed447cba9cf9b7e1a1b47aa27acb14f8f2da0a8e
> prerequisite-patch-id: 9f80c5bbbfb8cd3347951c4d57634e93ffa79924
> prerequisite-patch-id: 1aaa9f0d466e2d6837f75844df48a98beb70ff24
> prerequisite-patch-id: 34502820d8c0355b3ed2638c457084edeaba029d
> prerequisite-patch-id: a96258da9e78cfb9ac9893cdcdeb38b69b75f134
> -- 
> 2.41.0
> 
> 
>
Nicolas Graves Sept. 28, 2023, 6:30 p.m. UTC | #2
On 2023-09-28 19:36, Efraim Flashner wrote:

> A couple of things I noticed:
>
> On Sun, Sep 10, 2023 at 06:18:42PM +0200, Nicolas Graves wrote:
>> +                  coreutils
>
> This can be coreutils-minimal
>

Will change it.
>> +                  (("grep")
>> +                   #$(file-append (this-package-input "grep") "/bin/grep"))
>
> These can be (search-input-file #$inputs "/bin/grep") to make it easier
> to swap out the packages for something else if people want.
>

Fine for me.

>> +                  (("sed")
>
> I checked the script, it should be ((" sed ") since there are a couple
> of instances of 'sed' in the script which aren't invocations of sed.

Yes I indeed noticed it too, probably forgot to resubmit a patch but my
local version works well.
>
>> +                   #$(file-append (this-package-input "sed") "/bin/sed"))
>> +                  (("uname")
>> +                   #$(file-append (this-package-input "coreutils")
>> +                                  "/bin/uname"))
>> +                  (("dirname")
>> +                   #$(file-append (this-package-input "coreutils")
>> +                                  "/bin/dirname"))
>> +                  (("basename")
>> +                   #$(file-append (this-package-input "coreutils")
>> +                                  "/bin/basename"))))))))
>
> Are there more binaries which should be substituted? I saw glxgears,
> chcon, a couple instances of java, pwd, valgrind, docbook paths. And
> then there's a couple of other scripts and binaries in the bin/ folder.
> I think it'd be better to use wrap-script or wrap-program and then use
> substitute* to strip the leading /usr/bin/ from the different calls to
> the different binaries.

I don't use more than that for a CLI usage. The thing is that we already
build without the GUI (so without java). Maybe valgrind could be useful
for debugging, docbook for documentation...

I'll take a look in the coming weeks, but I can guarantee it works for
me, so I propose we should process with this one, and add other patches
on top when someone needs them. But we should be mindful that all
possible paths / binaries are not reachable when the script is run
(IIRC, they also depend on the OS and options).
Ludovic Courtès Nov. 23, 2023, 10:30 a.m. UTC | #3
Hi Nicolas,

Nicolas Graves <ngraves@ngraves.fr> skribis:

>   gnu: scilab: Remove uneeded code.
>   gnu: scilab: Activate tests and disable failing tests.
>   gnu: scilab: Use gexp for tcl and tk libraries.
>   gnu: scilab: Add phase rewrap-scilab-cli.
>   gnu: scilab: Reindent.
>   gnu: scilab: Update to 2024.0.0.
>   gnu: scilab: Add phase set-version.
>   gnu: scilab: Set default SCIHOME value.

I added one commit log that was mostly missing and applied the whole
series.  Thank you!

Ludo’.
diff mbox series

Patch

diff --git a/gnu/packages/maths.scm b/gnu/packages/maths.scm
index 38e71e18f8..40883d71c1 100644
--- a/gnu/packages/maths.scm
+++ b/gnu/packages/maths.scm
@@ -8448,22 +8448,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
+                  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
@@ -8534,7 +8537,23 @@  (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")
+                   #$(file-append (this-package-input "grep") "/bin/grep"))
+                  (("sed")
+                   #$(file-append (this-package-input "sed") "/bin/sed"))
+                  (("uname")
+                   #$(file-append (this-package-input "coreutils")
+                                  "/bin/uname"))
+                  (("dirname")
+                   #$(file-append (this-package-input "coreutils")
+                                  "/bin/dirname"))
+                  (("basename")
+                   #$(file-append (this-package-input "coreutils")
+                                  "/bin/basename"))))))))
     (home-page "https://scilab.org")
     (synopsis "Software for engineers and scientists")
     (description "This package provides the non-graphical version of the Scilab