Subject: [PATCH] gnu: Add tk-img.

From: cage <[email-masked]>
Date: Wed, 6 Sep 2023 16:06:59 +0200

Hi!

With this patch I tried to address all the issues that was pointed out
(hope they are fine :)) except one:

> One last thing, the source of tk-img carries many 'contrib' sources;
> they should be removed in a snippet to ensure only Guix-provided system
> libraries are used instead.

Because I was not able to find out the contribs sources.

Also, for the record, the problem with  tests is not that the Tk (as I
erroneously thought)  executable can not  be found but that,  for some
reasons, the tcl script seems to fails to resolve Tk as dependency:

$ tclsh

% package require Tk → raise an error

the same line works on my other system (Debian)

Bye!
C.

---
 gnu/packages/tcl.scm | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/gnu/packages/tcl.scm b/gnu/packages/tcl.scm
index b69dba2254..22602c177a 100644
--- a/gnu/packages/tcl.scm
+++ b/gnu/packages/tcl.scm
@@ -36,6 +36,7 @@ (define-module (gnu packages tcl)
   #:use-module (gnu packages)
   #:use-module (gnu packages image)
   #:use-module (gnu packages fontutils)
+  #:use-module (gnu packages ghostscript)
   #:use-module (gnu packages perl)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages tls)
@@ -509,3 +510,42 @@ (define-public go-github.com-nsf-gothic
     (description "Gothic contains Go bindings for Tcl/Tk.  The package contains
 only one type and one function that can be used to create a Tk interpreter.")
     (license license:expat))))
+
+(define-public tk-img
+  (package
+    (name "tk-img")
+    (version "1.4.14")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append
+             "mirror://sourceforge/tkimg/tkimg/1.4/tkimg%20"
+             version
+             "/Img-" version "-Source.tar.gz"))
+       (file-name (string-append "tkimg-" version ".tar.gz"))
+       (sha256
+        (base32 "08dvb8bfkxr919wp6fq14cfb9lz1v59jx1la4a6j4ks636wb243m"))))
+    (build-system gnu-build-system)
+    (arguments
+     (list #:tests? #f ; tests fails because the tcl shell can not find Tk ("package require Tk" fails)
+           #:phases
+           #~(modify-phases %standard-phases
+               (replace 'install
+                 (lambda* (#:key outputs #:allow-other-keys)
+                   (invoke "make" "install-libraries"))))
+           #:configure-flags
+           #~(list
+              (string-append "--exec-prefix=" #$output)
+              (string-append "--with-tcl="
+                             (assoc-ref %build-inputs "tcl") "/lib")
+              (string-append "--with-tk="
+                             (assoc-ref %build-inputs "tk") "/lib"))))
+    (native-inputs
+     (list tcl tk ghostscript))
+    (home-page "https://sourceforge.net/projects/tkimg/")
+    (synopsis "Increase the number bitmap file formats supported by TK.")
+    (description
+     "The Img package adds supports for several image formats to TCl/TK; notably JPEG, ICO, BMP, TGA and PostScript (using an external PostScript interpreter).")
+    (license (license:non-copyleft
+              "file://license.terms"
+              "See license.terms in the distribution."))))

base-commit: 42ae42cf41e8f5e88422e30d801251a3427d7f3b
--
2.34.0