diff mbox series

[bug#62008,1/2] gnu: disarchive: Wrap program instead of using propagated inputs..

Message ID 20230306191950.3639176-1-zimon.toutoune@gmail.com
State New
Headers show
Series Update Disarchive to 0.5.0 | expand

Commit Message

Simon Tournier March 6, 2023, 7:19 p.m. UTC
* gnu/packages/backup.scm (disarchive)[arguments]: Add phase after install
to wrap program.
[inputs]: Add guile-gcrypt and guile-lzma.
[propagated-inputs]: Remove it.
---
 gnu/packages/backup.scm | 34 +++++++++++++++++++++++++++++++---
 1 file changed, 31 insertions(+), 3 deletions(-)

Comments

Ludovic Courtès March 7, 2023, 9:49 a.m. UTC | #1
Hi Simon,

Simon Tournier <zimon.toutoune@gmail.com> skribis:

> * gnu/packages/backup.scm (disarchive)[arguments]: Add phase after install
> to wrap program.
> [inputs]: Add guile-gcrypt and guile-lzma.
> [propagated-inputs]: Remove it.

For this package, I have a slight preference for keeping propagated
inputs so that one can use Disarchive as a library.

WDYT?

Some comments while at it…

[...]

> +              (let* ((effective
> +                      (read (open-pipe* OPEN_READ
> +                                        (string-append #$guile-3.0 "/bin/guile")
> +                                        "-c" "(write (effective-version))")))

(guix build guile-build-system) exports ‘target-guile-effective-version’
to do that; it’s more convenient.

> +                     (modules (list #$output
> +                                    #$guile-bytestructures
> +                                    #$guile-gcrypt
> +                                    #$guile-lzma))

This should use (this-package-input "guile-bytestructures“) and similar,
for consistency.

Ludo’.
Simon Tournier March 7, 2023, 10:43 a.m. UTC | #2
Hi Ludo,

On mar., 07 mars 2023 at 10:49, Ludovic Courtès <ludo@gnu.org> wrote:

> For this package, I have a slight preference for keeping propagated
> inputs so that one can use Disarchive as a library.

Well, maybe I am missing a point but currently for Disarchive standalone,

--8<---------------cut here---------------start------------->8---
$ guix shell -C disarchive -- disarchive disassemble hello-2.12.1
Backtrace:
In ice-9/boot-9.scm:

[...]

ice-9/boot-9.scm:3329:6: In procedure resolve-interface:
no code for module (gcrypt hash)
--8<---------------cut here---------------end--------------->8---

And I need to add Guile for triggering the search patch.  And I find
that annoying,

    $ guix shell -C disarchive guile -- disarchive disassemble hello-2.12.1

It does not appear to me straightforward to know that.


> WDYT?

Since we have two usages of Disarchive, the standalone CLI and the
library, maybe we should have two packages: disarchive and
guile-disarchive.

WDYT?


> Some comments while at it…

Thanks.  That’s interesting because I took inspiration from the packages
Cuirass and Dezyne. :-)

>> +              (let* ((effective
>> +                      (read (open-pipe* OPEN_READ
>> +                                        (string-append #$guile-3.0 "/bin/guile")
>> +                                        "-c" "(write (effective-version))")))
>
> (guix build guile-build-system) exports ‘target-guile-effective-version’
> to do that; it’s more convenient.

I did not know.  Well, I will adapt Cuirass and Dezyne too, IIUC. :-)


>> +                     (modules (list #$output
>> +                                    #$guile-bytestructures
>> +                                    #$guile-gcrypt
>> +                                    #$guile-lzma))
>
> This should use (this-package-input "guile-bytestructures“) and similar,
> for consistency.

Ok.  Just for my understanding about the "consistency”, is the procedure
’make-gitolite’ from (gnu packages version-conrol) consistent?


Cheers,
simon
Ludovic Courtès March 10, 2023, 8:17 a.m. UTC | #3
Hi Simon!

Simon Tournier <zimon.toutoune@gmail.com> skribis:

> On mar., 07 mars 2023 at 10:49, Ludovic Courtès <ludo@gnu.org> wrote:
>
>> For this package, I have a slight preference for keeping propagated
>> inputs so that one can use Disarchive as a library.
>
> Well, maybe I am missing a point but currently for Disarchive standalone,
>
> $ guix shell -C disarchive -- disarchive disassemble hello-2.12.1
> Backtrace:

Hmm good point.  So maybe we need to wrap after all, and also keep
propagated inputs (as an example, (guix build download) uses the
Disarchive modules directly, not the command.)

I realize that I worked around it in ‘etc/disarchive-manifest.scm’.

>>> +              (let* ((effective
>>> +                      (read (open-pipe* OPEN_READ
>>> +                                        (string-append #$guile-3.0 "/bin/guile")
>>> +                                        "-c" "(write (effective-version))")))
>>
>> (guix build guile-build-system) exports ‘target-guile-effective-version’
>> to do that; it’s more convenient.
>
> I did not know.  Well, I will adapt Cuirass and Dezyne too, IIUC. :-)

Awesome.

>
>>> +                     (modules (list #$output
>>> +                                    #$guile-bytestructures
>>> +                                    #$guile-gcrypt
>>> +                                    #$guile-lzma))
>>
>> This should use (this-package-input "guile-bytestructures“) and similar,
>> for consistency.
>
> Ok.  Just for my understanding about the "consistency”, is the procedure
> ’make-gitolite’ from (gnu packages version-conrol) consistent?

It should use ‘this-package-input’ as well, to keep input fields and
inheritance meaningful.

Thanks,
Ludo’.
Simon Tournier March 10, 2023, 11:41 a.m. UTC | #4
Hi Ludo,

On ven., 10 mars 2023 at 09:17, Ludovic Courtès <ludo@gnu.org> wrote:

> Hmm good point.  So maybe we need to wrap after all, and also keep
> propagated inputs (as an example, (guix build download) uses the
> Disarchive modules directly, not the command.)

I am proposing to have ’package/inherit’,

 1. ’disarchive’: the standalone CLI with wrap
 2. ’guile-disarchive’: the library with propagated-inputs

WDYT?


Cheers,
simon
Ludovic Courtès March 10, 2023, 4:44 p.m. UTC | #5
Simon Tournier <zimon.toutoune@gmail.com> skribis:

> On ven., 10 mars 2023 at 09:17, Ludovic Courtès <ludo@gnu.org> wrote:
>
>> Hmm good point.  So maybe we need to wrap after all, and also keep
>> propagated inputs (as an example, (guix build download) uses the
>> Disarchive modules directly, not the command.)
>
> I am proposing to have ’package/inherit’,
>
>  1. ’disarchive’: the standalone CLI with wrap
>  2. ’guile-disarchive’: the library with propagated-inputs

I think having a single package is more convenient: it would both
propagate inputs and wrap the binaries as you proposed.

Ludo’.
diff mbox series

Patch

diff --git a/gnu/packages/backup.scm b/gnu/packages/backup.scm
index 7be0c813bb..7fe2e80d39 100644
--- a/gnu/packages/backup.scm
+++ b/gnu/packages/backup.scm
@@ -23,6 +23,7 @@ 
 ;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
 ;;; Copyright © 2022 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;; Copyright © 2022 Feng Shu <tumashu@163.com>
+;;; Copyright © 2023 Simon Tournier <zimon.toutoune@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1230,6 +1231,35 @@  (define-public disarchive
                (base32
                 "1pql8cspsxyx8cpw3xyhirnisv6rb4vj5mxr1d7w9la72q740n8s"))))
     (build-system gnu-build-system)
+    (arguments
+     (list
+      #:modules `((ice-9 popen)
+                  ,@%gnu-build-system-modules)
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'install 'wrap-program
+            (lambda* (#:key inputs outputs #:allow-other-keys)
+              (let* ((effective
+                      (read (open-pipe* OPEN_READ
+                                        (string-append #$guile-3.0 "/bin/guile")
+                                        "-c" "(write (effective-version))")))
+                     (scm-dir (string-append "/share/guile/site/" effective))
+                     (go-dir (string-append "/lib/guile/" effective
+                                            "/site-ccache/"))
+                     (modules (list #$output
+                                    #$guile-bytestructures
+                                    #$guile-gcrypt
+                                    #$guile-lzma))
+                     (scm-path
+                      (map (lambda (module) (string-append module scm-dir))
+                           modules))
+                     (go-path
+                      (map (lambda (module) (string-append module scm-dir))
+                           modules)))
+                (wrap-program (string-append #$output "/bin/disarchive")
+                  `("PATH" ":" prefix (,(string-append #$output "/bin")))
+                  `("GUILE_LOAD_PATH" ":" prefix ,scm-path)
+                  `("GUILE_LOAD_COMPILED_PATH" ":" prefix ,go-path))))))))
     (native-inputs
      (list autoconf
            automake
@@ -1239,9 +1269,7 @@  (define-public disarchive
            guile-lzma
            guile-quickcheck))
     (inputs
-     (list guile-3.0 zlib))
-    (propagated-inputs
-     (list guile-gcrypt guile-lzma))
+     (list guile-3.0 guile-gcrypt guile-lzma zlib))
     (home-page "https://ngyro.com/software/disarchive.html")
     (synopsis "Software archive disassembler")
     (description "Disarchive can disassemble software archives into data