Subject: [bug#31114] [PATCH] gnu: Add fortune-mod.

From: Pierre Neidhardt <[email-masked]>
Date: Tue, 10 Apr 2018 21:52:02 +0530

Yup, we need valgrind as a propagated input for perl-test-runvalgrind.

Attached the whole patch set: 3 perl packages and fortune-mod.

-- 
Pierre Neidhardt

A pencil with no point needs no eraser.
From 2314e654a55ce7cecfeeb4410e92a7490f4128f3 Mon Sep 17 00:00:00 2001
From: Pierre Neidhardt <[email-masked]>
Date: Tue, 10 Apr 2018 21:00:08 +0530
Subject: [PATCH 1/4] gnu: Add perl-file-readbackwards.

* gnu/packages/perl.scm (perl-file-readbackwards): New variable.
---
 gnu/packages/perl.scm | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/gnu/packages/perl.scm b/gnu/packages/perl.scm
index 50273d31e..e1d029c38 100644
--- a/gnu/packages/perl.scm
+++ b/gnu/packages/perl.scm
@@ -19,6 +19,7 @@
 ;;; Copyright © 2017 Leo Famulari <[email-masked]>
 ;;; Copyright © 2017 Christopher Allan Webber <[email-masked]>
 ;;; Copyright © 2018 Oleg Pykhalov <[email-masked]>
+;;; Copyright © 2018 Pierre Neidhardt <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -3501,6 +3502,35 @@ provided base directory and can return files (and/or directories if desired)
 matching a regular expression.")
     (home-page "http://search.cpan.org/~dopacki/File-List//")))
 
+(define-public perl-file-readbackwards
+  (package
+    (name "perl-file-readbackwards")
+    (version "1.05")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append
+             "mirror://cpan/authors/id/U/UR/URI/File-ReadBackwards-"
+             version
+             ".tar.gz"))
+       (sha256
+        (base32
+         "0vldy5q0zyf1cwzwb1gv14f8vg2f21bw96b8wvkw6z2hhypn3cl2"))))
+    (build-system perl-build-system)
+    (home-page
+     "http://search.cpan.org/dist/File-ReadBackwards/")
+    (synopsis "Read a file backwards by lines")
+    (description "This module reads a file backwards line by line. It is
+simple to use, memory efficient and fast. It supports both an object and a
+tied handle interface.
+
+It is intended for processing log and other similar text files which
+typically have their newest entries appended to them. By default files
+are assumed to be plain text and have a line ending appropriate to the
+OS. But you can set the input record separator string on a per file
+basis.")
+    (license #f)))
+
 (define-public perl-file-remove
   (package
     (name "perl-file-remove")
-- 
2.16.3

From e819b9532883aaf168a2fcc74daa40341dcf8afb Mon Sep 17 00:00:00 2001
From: Pierre Neidhardt <[email-masked]>
Date: Tue, 10 Apr 2018 21:01:09 +0530
Subject: [PATCH 2/4] gnu: Add perl-io-all.

* gnu/packages/perl.scm (perl-io-all): New variable.
---
 gnu/packages/perl.scm | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/gnu/packages/perl.scm b/gnu/packages/perl.scm
index e1d029c38..4bef99dce 100644
--- a/gnu/packages/perl.scm
+++ b/gnu/packages/perl.scm
@@ -46,6 +46,7 @@
   #:use-module (guix build-system perl)
   #:use-module (gnu packages base)
   #:use-module (gnu packages compression)
+  #:use-module (gnu packages freedesktop)
   #:use-module (gnu packages perl-check)
   #:use-module (gnu packages perl-web)
   #:use-module (gnu packages pkg-config))
@@ -4086,6 +4087,32 @@ This document describes how to use Inline with the C programming language.
 It also goes a bit into Perl C internals.")
     (license (package-license perl))))
 
+(define-public perl-io-all
+  (package
+    (name "perl-io-all")
+    (version "0.87")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append
+             "mirror://cpan/authors/id/F/FR/FREW/IO-All-"
+             version
+             ".tar.gz"))
+       (sha256
+        (base32
+         "0nsd9knlbd7if2v6zwj4q978axq0w5hk8ymp61z14a821hjivqjl"))))
+    (build-system perl-build-system)
+    (propagated-inputs
+     `(("perl-file-mimeinfo" ,perl-file-mimeinfo)
+       ("perl-file-readbackwards" ,perl-file-readbackwards)))
+    (home-page "http://search.cpan.org/dist/IO-All/")
+    (synopsis "IO::All to Larry Wall!")
+    (description "IO::All combines all of the best Perl IO modules into a
+single nifty object oriented interface to greatly simplify your everyday Perl
+IO idioms. It exports a single function called io, which returns a new IO::All
+object. And that object can do it all!")
+    (license perl-license)))
+
 (define-public perl-io-captureoutput
   (package
     (name "perl-io-captureoutput")
-- 
2.16.3

From a1d5a57a4e55f7aca4033844ff764aa2a0069bf9 Mon Sep 17 00:00:00 2001
From: Pierre Neidhardt <[email-masked]>
Date: Tue, 10 Apr 2018 21:01:44 +0530
Subject: [PATCH 3/4] gnu: Add perl-test-runvalgrind

* gnu/packages/perl-check.scm (perl-test-runvalgrind): New variable.
---
 gnu/packages/perl-check.scm | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/gnu/packages/perl-check.scm b/gnu/packages/perl-check.scm
index 1fd725f65..832efc2b7 100644
--- a/gnu/packages/perl-check.scm
+++ b/gnu/packages/perl-check.scm
@@ -12,6 +12,7 @@
 ;;; Copyright © 2017 Petter <[email-masked]>
 ;;; Copyright © 2017, 2018 Tobias Geerinckx-Rice <[email-masked]>
 ;;; Copyright © 2018 Oleg Pykhalov <[email-masked]>
+;;; Copyright © 2018 Pierre Neidhardt <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -31,6 +32,7 @@
 (define-module (gnu packages perl-check)
   #:use-module (guix licenses)
   #:use-module (gnu packages)
+  #:use-module (gnu packages valgrind)
   #:use-module (guix packages)
   #:use-module (guix download)
   #:use-module (guix build-system perl)
@@ -1001,6 +1003,33 @@ reported, and the tests skipped.")
     (description "Test::Roo provides composable, reusable tests with roles.")
     (license asl2.0)))
 
+(define-public perl-test-runvalgrind
+  (package
+    (name "perl-test-runvalgrind")
+    (version "0.2.0")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append
+             "mirror://cpan/authors/id/S/SH/SHLOMIF/Test-RunValgrind-"
+             version
+             ".tar.gz"))
+       (sha256
+        (base32
+         "0cfndkn2k9pcx290wcblwmrwh1ybs0grxjlsrp8fbqqbmmjpb53h"))))
+    (build-system perl-build-system)
+    (native-inputs
+     `(("perl-module-build" ,perl-module-build)))
+    (propagated-inputs
+     `(("perl-path-tiny" ,perl-path-tiny)
+       ("perl-test-trap" ,perl-test-trap)
+       ("valgrind" ,valgrind)))
+    (home-page "http://search.cpan.org/dist/Test-RunValgrind/")
+    (synopsis "Tests that an external program is valgrind-clean")
+    (description "Test::RunValgind checks weather Valgrind does not detect
+errors (such as memory leaks) in an arbitrary binary executable.")
+    (license x11)))
+
 (define-public perl-test-script
   (package
     (name "perl-test-script")
-- 
2.16.3

From d4ab7650cae4e4cf3403a5e03bc68cef15e4109a Mon Sep 17 00:00:00 2001
From: Pierre Neidhardt <[email-masked]>
Date: Mon, 9 Apr 2018 23:01:04 +0530
Subject: [PATCH 4/4] gnu: Add fortune-mod.

* gnu/packages/games.scm (fortune-mod): New variable.
---
 gnu/packages/games.scm | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)

diff --git a/gnu/packages/games.scm b/gnu/packages/games.scm
index 5207e08d6..47557a762 100644
--- a/gnu/packages/games.scm
+++ b/gnu/packages/games.scm
@@ -112,6 +112,7 @@
   #:use-module (gnu packages gstreamer)
   #:use-module (gnu packages bash)
   #:use-module (gnu packages perl)
+  #:use-module (gnu packages perl-check)
   #:use-module (gnu packages qt)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages pulseaudio)
@@ -4851,3 +4852,56 @@ Strife, Chex Quest, and fan-created games like Harmony, Hacx and Freedoom.")
                    (license:non-copyleft ; modified dumb
                     "file://dumb/licence.txt"
                     "Dumb license, explicitly GPL compatible.")))))
+
+(define-public fortune-mod
+  (package
+    (name "fortune-mod")
+    (version "2.4.1")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "https://github.com/shlomif/fortune-mod/"
+                                  "archive/" name "-" version ".tar.gz"))
+              (sha256
+               (base32
+                "1hnqpkassh7fwg2jgvybr8mw7vzfikbrhb5r22367ilfwxnl9yd2"))))
+    (build-system cmake-build-system)
+    (arguments
+     `(#:test-target "check"
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'fix-build-env
+           (lambda* (#:key inputs #:allow-other-keys)
+             (use-modules (guix build utils))
+             (let* ((cmake-rules (assoc-ref inputs "cmake-rules")))
+               (copy-file cmake-rules
+                          (string-append "fortune-mod/cmake/"
+                                         (strip-store-file-name cmake-rules)))
+               (chdir "fortune-mod"))))
+         (add-after 'install 'fix-install-directory
+           ;; Move binary from "games/" to "bin/".
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let ((out (assoc-ref outputs "out")))
+               (rename-file (string-append out "/games/fortune")
+                            (string-append out "/bin/fortune"))
+               #t))))))
+    (inputs `(("recode" ,recode)))
+    (native-inputs
+     `(("perl" ,perl)
+       ;; The following is only needed for tests.
+       ("perl-file-find-object" ,perl-file-find-object)
+       ("perl-test-differences" ,perl-test-differences)
+       ("perl-class-xsaccessor" ,perl-class-xsaccessor)
+       ("perl-io-all" ,perl-io-all)
+       ("perl-test-runvalgrind" ,perl-test-runvalgrind)
+       ("cmake-rules"
+        ,(origin
+           (method url-fetch)
+           (uri (string-append "https://bitbucket.org/shlomif/shlomif-cmake-modules/"
+                               "raw/default/shlomif-cmake-modules/Shlomif_Common.cmake"))
+           (sha256
+            (base32 "0kx9s1qqhhzprp1w3b67xmsns0n0v506bg5hgrshxaxpy6lqiwb2"))))))
+    (home-page "http://www.shlomifish.org/open-source/projects/fortune-mod/")
+    (synopsis "The Fortune Cookie program from BSD games")
+    (description "Fortune is a command-line utility which displays a random
+quotation from a collection of quotes.")
+    (license license:gpl2+)))
-- 
2.16.3