Subject: [bug#29472] [PATCH 3/4] gnu: Add perl-file-mimeinfo.

From: Brendan Tildesley <[email-masked]>
Date: Mon, 27 Nov 2017 23:54:33 +1100

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

diff --git a/gnu/packages/perl.scm b/gnu/packages/perl.scm
index bacaaf38a..f658b9177 100644
--- a/gnu/packages/perl.scm
+++ b/gnu/packages/perl.scm
@@ -46,6 +46,7 @@
   #:use-module (gnu packages perl-web)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages freedesktop)
+  #:use-module (gnu packages gnome)
   #:use-module (gnu packages web))
 
 ;;;
@@ -3477,6 +3478,53 @@ data.")
 those files.")
     (license (package-license perl))))
 
+(define-public perl-file-mimeinfo
+  (package
+    (name "perl-file-mimeinfo")
+    (version "0.28")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "mirror://cpan/authors/id/M/MI/MICHIELB/"
+                           "File-MimeInfo-" version ".tar.gz"))
+       (sha256
+        (base32
+         "1ipbh63bkh1r2gy5g7q4bzhki8j29mm1jkhbv60p9vwsdys5s91a"))))
+    (build-system perl-build-system)
+    ;; If the tests are fixed, add perl-test-pod, perl-test-pod-coverage, and
+    ;; perl-test-tiny as native-inputs.
+    (propagated-inputs
+     `(("shared-mime-info" ,shared-mime-info)
+       ("perl-file-desktopentry" ,perl-file-desktopentry)))
+    (arguments
+     ;; Some tests fail due to requiring the mimetype of perl files to be
+     ;; text/plain when they are actually application/x-perl.
+     `(#:tests? #f
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'install 'wrap-programs
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let ((out (assoc-ref outputs "out")))
+               (for-each (lambda (prog)
+                           (wrap-program (string-append out "/bin/" prog)
+                             `("PERL5LIB" ":" prefix
+                               (,(string-append (getenv "PERL5LIB") ":" out
+                                                "/lib/perl5/site_perl")))))
+                         '("mimeopen" "mimetype")))
+             #t)))))
+    (home-page "http://search.cpan.org/dist/File-MimeInfo/")
+    (synopsis "Determine file type from the file name")
+    (description
+     "File::Mimeinfo can be used to determine the mime type of a file.  It
+tries to implement the freedesktop specification for a shared MIME database.
+
+ This package also contains two related utilities:
+@itemize
+@item mimetype: Determine a file's mimetype.
+@item mimeopen: Open files in an appropriate program according to their mimetype.
+@end itemize")
+    (license (package-license perl))))
+
 (define-public perl-file-sharedir
   (package
     (name "perl-file-sharedir")
-- 
2.15.0