netpbm.scm 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2013, 2015 Andreas Enge <andreas@enge.fr>
  3. ;;; Copyright © 2015, 2016, 2021 Ludovic Courtès <ludo@gnu.org>
  4. ;;; Copyright © 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
  5. ;;;
  6. ;;; This file is part of GNU Guix.
  7. ;;;
  8. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  9. ;;; under the terms of the GNU General Public License as published by
  10. ;;; the Free Software Foundation; either version 3 of the License, or (at
  11. ;;; your option) any later version.
  12. ;;;
  13. ;;; GNU Guix is distributed in the hope that it will be useful, but
  14. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  15. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. ;;; GNU General Public License for more details.
  17. ;;;
  18. ;;; You should have received a copy of the GNU General Public License
  19. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  20. (define-module (gnu packages netpbm)
  21. #:use-module (gnu packages)
  22. #:use-module (gnu packages compression)
  23. #:use-module (gnu packages flex)
  24. #:use-module (gnu packages ghostscript)
  25. #:use-module (gnu packages image)
  26. #:use-module (gnu packages perl)
  27. #:use-module (gnu packages pkg-config)
  28. #:use-module (gnu packages python)
  29. #:use-module (gnu packages xml)
  30. #:use-module (gnu packages xorg)
  31. #:use-module (guix build-system gnu)
  32. #:use-module ((guix licenses) #:select (gpl2))
  33. #:use-module (guix packages)
  34. #:use-module (guix svn-download))
  35. (define-public netpbm
  36. (package
  37. (name "netpbm")
  38. (version "10.78.3")
  39. (source (origin
  40. (method svn-fetch)
  41. ;; At the time of first packaging, the "super-stable" and
  42. ;; "stable" versions did not compile with newer libpng;
  43. ;; we needed the "advanced" version.
  44. ;; The currently highest stable version is 10.47.53,
  45. ;; the currently highest advanced version is 10.69.4,
  46. ;; svn release 2397.
  47. ;; To determine the correct release: "svn log version.mk".
  48. (uri (svn-reference
  49. (url "http://svn.code.sf.net/p/netpbm/code/advanced")
  50. (revision 2965)))
  51. (sha256
  52. (base32
  53. "1k7as9qi1942wyjxpvbf02wg0h4braw44m3m3vvi8sm9y5z1m967"))
  54. (patches (search-patches "netpbm-CVE-2017-2586.patch"
  55. "netpbm-CVE-2017-2587.patch"))
  56. (file-name (string-append name "-" version "-checkout"))
  57. (modules '((guix build utils)))
  58. (snippet
  59. '(begin
  60. ;; Remove non-FSDG-compliant code.
  61. (define-syntax drop
  62. (syntax-rules (in)
  63. ;; Remove PROGRAM from DIRECTORY/Makefile, and remove
  64. ;; DIRECTORY/PROGRAM and DIRECTORY/PROGRAM.c.
  65. ((_ program ... in directory)
  66. (begin
  67. (substitute* (string-append directory "/Makefile")
  68. ((program) "") ...)
  69. (let* ((subdir (string-append directory "/" program))
  70. (dot-c (string-append subdir ".c")))
  71. (when (file-exists? subdir)
  72. (delete-file-recursively subdir))
  73. (when (file-exists? dot-c)
  74. (delete-file dot-c)))
  75. ...))))
  76. ;; Drop advertisement for non-free program.
  77. (drop "hpcdtoppm" in "converter/ppm")
  78. ;; Drop programs without a license, see
  79. ;; <http://packages.debian.org/changelogs/pool/main/n/netpbm-free/netpbm-free_10.0-12.2/libnetpbm10.copyright>.
  80. (drop "pbmto4425" "pbmtoln03" "pbmtolps" "pbmtopk" "pktopbm"
  81. in "converter/pbm")
  82. (drop "spottopgm" in "converter/pgm")
  83. (drop "ppmtopjxl" in "converter/ppm")
  84. ;; Remove timestamps from the generated code.
  85. (substitute* "buildtools/makepointerman"
  86. (("gmctime[(][)]")
  87. "\"Thu Jan 1 00:00:00 1970\""))
  88. (substitute* "buildtools/stamp-date"
  89. (("^DATE=.*")
  90. "DATE=\"Thu Jan 01 00:00:00+0000 1970\"\n")
  91. (("^USER=.*")
  92. "USER=Guix\n"))
  93. #t))))
  94. (build-system gnu-build-system)
  95. (inputs `(("ghostscript" ,ghostscript)
  96. ("libjpeg" ,libjpeg-turbo)
  97. ("libpng" ,libpng)
  98. ("libtiff" ,libtiff)
  99. ("libxml2" ,libxml2)
  100. ("xorg-rgb" ,xorg-rgb)
  101. ("zlib" ,zlib)))
  102. (native-inputs
  103. `(("flex" ,flex)
  104. ("perl" ,perl)
  105. ("pkg-config" ,pkg-config)
  106. ("python" ,python-wrapper)))
  107. (arguments
  108. `(#:modules ((guix build gnu-build-system)
  109. (guix build utils)
  110. (ice-9 match))
  111. #:phases
  112. (modify-phases %standard-phases
  113. (replace 'configure
  114. (lambda* (#:key inputs outputs #:allow-other-keys)
  115. (copy-file "config.mk.in" "config.mk")
  116. (chmod "config.mk" #o664)
  117. (let ((f (open-file "config.mk" "a")))
  118. (display "CC=gcc\n" f)
  119. (display "CFLAGS_SHLIB += -fPIC\n" f)
  120. (display "TIFFLIB = libtiff.so\n" f)
  121. (display "JPEGLIB = libjpeg.so\n" f)
  122. (display "ZLIB = libz.so\n" f)
  123. (display (string-append "LDFLAGS += -Wl,-rpath=" %output "/lib") f)
  124. (close-port f))
  125. (let ((rgb (search-input-file inputs "/share/X11/rgb.txt")))
  126. (substitute* "config.mk"
  127. (("/usr/share/netpbm/rgb.txt") rgb))
  128. ;; Our Ghostscript no longer provides the 'gs' command, only
  129. ;; 'gsc', so look for that instead.
  130. (substitute* "converter/other/pstopnm.c"
  131. (("\"%s/gs\"")
  132. "\"%s/gsc\"")
  133. (("/usr/bin/gs")
  134. (search-input-file inputs "/bin/gsc"))))))
  135. (add-before 'check 'setup-check
  136. (lambda _
  137. ;; install temporarily into /tmp/netpbm
  138. (invoke "make" "package")
  139. ;; remove test requiring X
  140. (substitute* "test/all-in-place.test" (("pamx") ""))
  141. ;; do not worry about non-existing file
  142. (substitute* "test/all-in-place.test" (("^rm ") "rm -f "))
  143. ;; remove four tests that fail for unknown reasons
  144. (substitute* "test/Test-Order"
  145. (("all-in-place.test") "")
  146. (("pnmpsnr.test") "")
  147. (("pnmremap1.test") "")
  148. (("gif-roundtrip.test") "")
  149. ;; These two tests started failing in netpbm-10.78.3.
  150. (("jpeg-roundtrip.test") "")
  151. (("pbmtext.test") "")
  152. ;; Skip tests that use nonfree programs that we don't build.
  153. (("ps-alt-roundtrip.test") "" )
  154. (("pbm-misc-converters.test") ""))
  155. #t))
  156. (replace 'install
  157. (lambda* (#:key outputs make-flags #:allow-other-keys)
  158. (let ((out (assoc-ref outputs "out")))
  159. (apply invoke "make" "package"
  160. (string-append "pkgdir=" out) make-flags)
  161. ;; Remove superfluous files.
  162. (with-directory-excursion out
  163. (for-each delete-file-recursively
  164. '("config_template" "pkginfo" "README" "VERSION"
  165. "link/" "misc/"))
  166. ;; Install the required ‘libnetpbm.so’ link.
  167. ;; See <https://issues.guix.gnu.org/issue/40376>.
  168. (with-directory-excursion "lib"
  169. (symlink
  170. (match (find-files "." "^libnetpbm\\.so\\.[^.]*\\.[^.]*$")
  171. ((head _ ...) head))
  172. "libnetpbm.so"))
  173. #t)))))))
  174. (synopsis "Toolkit for manipulation of images")
  175. (description
  176. "Netpbm is a toolkit for the manipulation of graphic images, including
  177. the conversion of images between a variety of different formats.
  178. There are over 300 separate tools in the package including converters for
  179. about 100 graphics formats.")
  180. (license gpl2)
  181. (home-page "http://netpbm.sourceforge.net/")))