diff mbox series

[bug#53920,v3] gnu: lesspipe: Update to 2.03.

Message ID ad08e104569e8759a2dacc429b4021f2dd2d6250.1645555065.git.h.goebel@crazy-compilers.com
State Accepted
Headers show
Series [bug#53920,v3] gnu: lesspipe: Update to 2.03. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Hartmut Goebel Feb. 22, 2022, 6:39 p.m. UTC
* gnu/packages/less.scm (lesspipe): Update to 2.03.
  [arguments] Use new style. <phases>{configure} Adjust to updated source.
  {fix-makefile} New phase.
  {patch-tput-and-file} rename into …
  {patch-command-paths} this; patch other relevant scripts.
  [inputs] Add perl-archive-zip.
---
 gnu/packages/less.scm | 66 ++++++++++++++++++++++++++++---------------
 1 file changed, 44 insertions(+), 22 deletions(-)

Comments

Ludovic Courtès Feb. 27, 2022, 10:06 p.m. UTC | #1
Hi Hartmut,

Hartmut Goebel <h.goebel@crazy-compilers.com> skribis:

> * gnu/packages/less.scm (lesspipe): Update to 2.03.
>   [arguments] Use new style. <phases>{configure} Adjust to updated source.
>   {fix-makefile} New phase.
>   {patch-tput-and-file} rename into …
>   {patch-command-paths} this; patch other relevant scripts.
>   [inputs] Add perl-archive-zip.

I haven’t tested it but it looks good to me on the surface.  If it works
for you, please go ahead!

Thanks,
Ludo’.
M Feb. 27, 2022, 10:22 p.m. UTC | #2
Hartmut Goebel schreef op di 22-02-2022 om 19:39 [+0100]:
> +                (substitute* "sxw2txt"
> +                  (("^use warnings;" line)
> +                   (string-append
> +                    line "\nuse lib '" #$perl-archive-zip
> +                    "/lib/perl5/site_perl';")))

To make package transformations work, can #$perl-archive-zip be avoided
here?  Maybe:

(substitute* [...]
  ([...]
   (string-append [...] (assoc-ref inputs "perl-archive-zip") [...])))

Greetings,
Maxime.
Hartmut Goebel Feb. 28, 2022, 8:25 a.m. UTC | #3
Am 27.02.22 um 23:22 schrieb Maxime Devos:
> To make package transformations work, can #$perl-archive-zip be avoided
> here?  Maybe:
>
> (substitute* [...]
>    ([...]
>     (string-append [...] (assoc-ref inputs "perl-archive-zip") [...])))

FMPOV I can easily change this.

Anyhow, I don't understand, why this is necessary for package 
transformations. I thought g-exps are the way to do it?
Nicolas Goaziou Feb. 28, 2022, 9:56 a.m. UTC | #4
Hello,

Hartmut Goebel <h.goebel@crazy-compilers.com> writes:

> Am 27.02.22 um 23:22 schrieb Maxime Devos:
>> To make package transformations work, can #$perl-archive-zip be avoided
>> here?  Maybe:
>>
>> (substitute* [...]
>>    ([...]
>>     (string-append [...] (assoc-ref inputs "perl-archive-zip") [...])))
>
> FMPOV I can easily change this.
>
> Anyhow, I don't understand, why this is necessary for package
> transformations. I thought g-exps are the way to do it?

Actually, I think it should be the higher-level sexp:

  #$(this-package-input "perl-archive-zip")

instead of

  (assoc-ref inputs ...)

To answer your question, this is explained in
<https://guix.gnu.org/fr/blog/2021/the-big-change/>, in "G-expressions
and self-referential records".

Another nitpick: end-of-line comments only need a single semicolon, not
two.

Regards,
Hartmut Goebel Feb. 28, 2022, 12:31 p.m. UTC | #5
Am 28.02.22 um 10:56 schrieb Nicolas Goaziou:
> Actually, I think it should be the higher-level sexp:
>
>    #$(this-package-input "perl-archive-zip")

How can one know, this one to use?

The blog post is more like a historical story, not a tutorial for 
converting. It uses both

|#~`("--disable-color" ,(string-append "--with-gawk=" #$gawk)))) |

|and|

|#~(list (string-append "--with-gawk=" #$(this-package-input "gawk"))))) |

|The manual seems to mostly use the former way.|

||||
Nicolas Goaziou Feb. 28, 2022, 12:50 p.m. UTC | #6
Hartmut Goebel <h.goebel@crazy-compilers.com> writes:

> Am 28.02.22 um 10:56 schrieb Nicolas Goaziou:
>> Actually, I think it should be the higher-level sexp:
>>
>>    #$(this-package-input "perl-archive-zip")
>
> How can one know, this one to use?
>
> The blog post is more like a historical story, not a tutorial for
> converting.

Actually, it is. It a tutorial for converting to the new syntax, with
historical background so you know why you're doing it.

> It uses both
>
> |#~`("--disable-color" ,(string-append "--with-gawk=" #$gawk)))) |
>
> |and|
>
> |#~(list (string-append "--with-gawk=" #$(this-package-input "gawk"))))) |

Yes, it does. The former is an example of what was done before the
change, and the latter is demonstrating what we should now use.

> |The manual seems to mostly use the former way.|

Then this should be fixed.

Regards,
Hartmut Goebel March 2, 2022, 8:52 p.m. UTC | #7
Thanks for the review.

Changed to use #$(this-package-input, updated to 2.04 (which was 
released meanwhile) and pushed as d8e353c11bf1999255a2471b553ce754800b074a
diff mbox series

Patch

diff --git a/gnu/packages/less.scm b/gnu/packages/less.scm
index e23b5d0c24..ede6238d25 100644
--- a/gnu/packages/less.scm
+++ b/gnu/packages/less.scm
@@ -3,6 +3,7 @@ 
 ;;; Copyright © 2019–2021 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
 ;;; Copyright © 2020, 2021 Michael Rohleder <mike@rohleder.de>
+;;; Copyright © 2022 Hartmut Goebel <h.goebel@crazy-compilers.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -20,10 +21,12 @@ 
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (gnu packages less)
+  #:use-module (guix gexp)
   #:use-module (guix licenses)
   #:use-module (gnu packages)
   #:use-module (gnu packages ncurses)
   #:use-module (gnu packages perl)
+  #:use-module (gnu packages perl-compression)
   #:use-module (gnu packages file)
   #:use-module (guix packages)
   #:use-module (guix download)
@@ -59,38 +62,57 @@  text editors.")
 (define-public lesspipe
   (package
     (name "lesspipe")
-    (version "1.91")
+    (version "2.03")
     (source (origin
               (method git-fetch)
               (uri (git-reference
                     (url "https://github.com/wofr06/lesspipe")
-                    (commit version)))
+                    (commit (string-append "v" version))))
               (file-name (git-file-name name version))
               (sha256
                (base32
-                "04dqvq6j4h451xqbvxzv6pv679hzzfm39pdm5vg7h3r45gzg0kps"))))
+                "0hvqs7c2scjzyanylp7f2r1kpdp9v5qvgarhwvaisx9q1d0hiqy9"))))
     (build-system gnu-build-system)
     (arguments
-     '(#:tests? #f                      ; no tests
-       #:phases (modify-phases %standard-phases
-                  (replace 'configure
-                    (lambda* (#:key outputs #:allow-other-keys)
-                      (let ((out (assoc-ref outputs "out")))
-                        (delete-file "Makefile") ; force generating
-                        (invoke "./configure"
-                                (string-append "--prefix=" out)
-                                "--yes"))))
-                  (add-before 'install 'patch-tput-and-file
-                    (lambda* (#:key inputs #:allow-other-keys)
-                      (substitute* "lesspipe.sh"
-                        (("tput colors")
-                         (string-append (search-input-file inputs "/bin/tput")
-                                        " colors"))
-                        (("file -")
-                         (string-append (search-input-file inputs "/bin/file")
-                                        " -"))))))))
+     (list
+      #:tests? #f                      ; no tests
+      #:phases
+      #~(modify-phases %standard-phases
+          (replace 'configure
+            (lambda* (#:key outputs #:allow-other-keys)
+              ;; configure is a perl script which the standard configure phase
+              ;; fails to execute
+              (invoke "./configure"
+                      (string-append "--prefix=" (assoc-ref outputs "out")))))
+          (add-before 'install 'fix-makefile
+            (lambda _
+              (substitute* "Makefile"
+                (("\\$\\(DESTDIR\\)/etc") "$(DESTDIR)$(PREFIX)/etc"))))
+          (add-before 'install 'patch-command-paths
+            ;; Depending on the content of the file to be displayed and some
+            ;; settings, lesspipe trees to use a large variety of external
+            ;; commands, e.g. rpm, dpkg, vimcolor.  We only link the
+            ;; essential ones to avoid this package to pull in all these
+            ;; dependencies which might never ever we used.
+            (lambda* (#:key inputs #:allow-other-keys)
+              (let ((file (search-input-file inputs "/bin/file"))
+                    (tput (search-input-file inputs "/bin/tput")))
+                (substitute* "sxw2txt"
+                  (("^use warnings;" line)
+                   (string-append
+                    line "\nuse lib '" #$perl-archive-zip
+                    "/lib/perl5/site_perl';")))
+                (substitute* "lesscomplete"
+                  (("file -") (string-append file " -")))
+                (substitute* "lesspipe.sh"
+                  (("tput colors")
+                   (string-append tput " colors"))
+                  (("file -")
+                   (string-append file " -")))))))))
     (inputs
-     (list file ncurses))  ; for tput
+     (list file
+           ncurses  ;; for tput
+           perl-archive-zip))
     (native-inputs (list perl))
     (home-page "https://github.com/wofr06/lesspipe")
     (synopsis "Input filter for less")