Subject: [bug#65873] [PATCH 2/5] gnu: Add fig2dev.

From: Bruno Victal <[email-masked]>
Date: Mon, 11 Sep 2023 19:54:50 +0100

* gnu/packages/xfig.scm: Import all of (guix licenses).
(xfig, transfig)[license]: Adjust accordingly.
(fig2dev): New variable.
---
 gnu/packages/xfig.scm | 64 +++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 61 insertions(+), 3 deletions(-)

diff --git a/gnu/packages/xfig.scm b/gnu/packages/xfig.scm
index f68ddb01f9..51791a1696 100644
--- a/gnu/packages/xfig.scm
+++ b/gnu/packages/xfig.scm
@@ -23,7 +23,7 @@
 
 (define-module (gnu packages xfig)
   #:use-module (guix packages)
-  #:use-module ((guix licenses) #:select (bsd-2))
+  #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix download)
   #:use-module (guix gexp)
   #:use-module (guix build-system gnu)
@@ -32,8 +32,66 @@ (define-module (gnu packages xfig)
   #:use-module (gnu packages ghostscript)
   #:use-module (gnu packages xorg)
   #:use-module (gnu packages image)
+  #:use-module (gnu packages ghostscript)
+  #:use-module (gnu packages imagemagick)
+  #:use-module (gnu packages netpbm)
   #:use-module (gnu packages compression))
 
+(define-public fig2dev
+  (package
+    (name "fig2dev")
+    (version "3.2.9")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "mirror://sourceforge/mcj/"
+                           name "-" version ".tar.xz"))
+       (sha256
+        (base32
+         "1cch429zbmrg2zy1mkx9xwnpvkjhmlw40c88bvi2virws744dqhm"))))
+    (build-system gnu-build-system)
+    (arguments
+     (list
+      #:modules '((guix build gnu-build-system)
+                  (guix build utils)
+                  (srfi srfi-26))
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'install 'wrap-program
+            (lambda* (#:key inputs #:allow-other-keys)
+              (let ((programs
+                     (find-files (string-append #$output "/bin")))
+                    (path
+                     (search-path-as-list
+                      '("bin")
+                      (map (cut assoc-ref inputs <>)
+                           (list "ghostscript" "imagemagick")))))
+                (for-each (lambda (program)
+                            (wrap-program program
+                              `("PATH" ":" prefix ,path)))
+                          programs)))))))
+    (inputs
+     (list libpng zlib
+           ;; Quoth INSTALL:
+           ;; “To run fig2dev, the packages
+           ;;    ghostscript, and one out of
+           ;;    netpbm | ImageMagick | GraphicsMagick
+           ;; are needed to produce various bitmap output formats, or process
+           ;; fig files with embedded images.”
+           ghostscript
+           imagemagick))
+    (native-inputs
+     ;; XXX: Tests fail if netpbm is absent.
+     (list netpbm))
+    (home-page "https://sourceforge.net/projects/mcj")
+    (synopsis "Translate Fig to other graphic description formats")
+    (description "Fig2dev is a set of tools for creating TeX documents with
+graphics which are portable, in the sense that they can be printed in a wide
+variety of environments.")
+    (license
+     (license:non-copyleft "file://Makefile.am"
+                           "See <https://spdx.org/licenses/Xfig.html>."))))
+
 (define-public xfig
   (package
     (name "xfig")
@@ -71,7 +129,7 @@ (define-public xfig
 such as GIF, JPEG, EPSF (PostScript), etc.  Those objects can be created,
 deleted, moved or modified.  Attributes such as colors or line styles can be
 selected in various ways.  For text, 35 fonts are available.")
-    (license bsd-2)))
+    (license license:bsd-2)))
 
 (define-public transfig
   (package
@@ -152,4 +210,4 @@ (define-public transfig
 the suffix \".pic\"; Fig files can be specified either with or without the
 suffix \".fig\".  Transfig also creates a TeX macro file appropriate to the
 target language.")
-    (license bsd-2)))
+    (license license:bsd-2)))
-- 
2.40.1