| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 |
|
| 22 | (define-module (gnu packages netpbm)
|
| 23 | #:use-module (gnu packages)
|
| 24 | #:use-module (gnu packages compression)
|
| 25 | #:use-module (gnu packages compiler-tools)
|
| 26 | #:use-module (gnu packages ghostscript)
|
| 27 | #:use-module (gnu packages image)
|
| 28 | #:use-module (gnu packages perl)
|
| 29 | #:use-module (gnu packages pkg-config)
|
| 30 | #:use-module (gnu packages python)
|
| 31 | #:use-module (gnu packages xml)
|
| 32 | #:use-module (gnu packages xorg)
|
| 33 | #:use-module (guix build-system gnu)
|
| 34 | #:use-module ((guix licenses) #:select (gpl2))
|
| 35 | #:use-module (guix packages)
|
| 36 | #:use-module (guix svn-download)
|
| 37 | #:use-module (guix utils))
|
| 38 |
|
| 39 | (define-public netpbm
|
| 40 | (package
|
| 41 | (name "netpbm")
|
| 42 | (version "10.78.3")
|
| 43 | (source (origin
|
| 44 | (method svn-fetch)
|
| 45 | |
| 46 | |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | (uri (svn-reference
|
| 53 | (url "http://svn.code.sf.net/p/netpbm/code/advanced")
|
| 54 | (revision 2965)))
|
| 55 | (sha256
|
| 56 | (base32
|
| 57 | "1k7as9qi1942wyjxpvbf02wg0h4braw44m3m3vvi8sm9y5z1m967"))
|
| 58 | (patches (search-patches "netpbm-CVE-2017-2586.patch"
|
| 59 | "netpbm-CVE-2017-2587.patch"))
|
| 60 | (file-name (string-append name "-" version "-checkout"))
|
| 61 | (modules '((guix build utils)))
|
| 62 | (snippet
|
| 63 | '(begin
|
| 64 | |
| 65 |
|
| 66 | (define-syntax drop
|
| 67 | (syntax-rules (in)
|
| 68 | |
| 69 | |
| 70 | ((_ program ... in directory)
|
| 71 | (begin
|
| 72 | (substitute* (string-append directory "/Makefile")
|
| 73 | ((program) "") ...)
|
| 74 |
|
| 75 | (let* ((subdir (string-append directory "/" program))
|
| 76 | (dot-c (string-append subdir ".c")))
|
| 77 | (when (file-exists? subdir)
|
| 78 | (delete-file-recursively subdir))
|
| 79 | (when (file-exists? dot-c)
|
| 80 | (delete-file dot-c)))
|
| 81 |
|
| 82 | ...))))
|
| 83 |
|
| 84 | |
| 85 | (drop "hpcdtoppm" in "converter/ppm")
|
| 86 |
|
| 87 | |
| 88 | |
| 89 | (drop "pbmto4425" "pbmtoln03" "pbmtolps" "pbmtopk" "pktopbm"
|
| 90 | in "converter/pbm")
|
| 91 | (drop "spottopgm" in "converter/pgm")
|
| 92 | (drop "ppmtopjxl" in "converter/ppm")
|
| 93 |
|
| 94 | |
| 95 | (substitute* "buildtools/makepointerman"
|
| 96 | (("gmctime[(][)]")
|
| 97 | "\"Thu Jan 1 00:00:00 1970\""))
|
| 98 | (substitute* "buildtools/stamp-date"
|
| 99 | (("^DATE=.*")
|
| 100 | "DATE=\"Thu Jan 01 00:00:00+0000 1970\"\n")
|
| 101 | (("^USER=.*")
|
| 102 | "USER=Guix\n"))
|
| 103 | #t))))
|
| 104 |
|
| 105 | (build-system gnu-build-system)
|
| 106 | (arguments
|
| 107 | `(#:modules ((guix build gnu-build-system)
|
| 108 | (guix build utils)
|
| 109 | (ice-9 match))
|
| 110 | #:phases
|
| 111 | (modify-phases %standard-phases
|
| 112 | (replace 'configure
|
| 113 | (lambda* (#:key inputs outputs #:allow-other-keys)
|
| 114 | (copy-file "config.mk.in" "config.mk")
|
| 115 | (chmod "config.mk" #o664)
|
| 116 | (let ((f (open-file "config.mk" "a")))
|
| 117 | (display "CC=gcc\n" f)
|
| 118 | (display "CFLAGS_SHLIB += -fPIC\n" f)
|
| 119 | (display "TIFFLIB = libtiff.so\n" f)
|
| 120 | (display "JPEGLIB = libjpeg.so\n" f)
|
| 121 | (display "ZLIB = libz.so\n" f)
|
| 122 | (display (string-append "LDFLAGS += -Wl,-rpath=" %output "/lib") f)
|
| 123 | (close-port f))
|
| 124 |
|
| 125 | (let ((rgb (search-input-file inputs "/share/X11/rgb.txt")))
|
| 126 | (substitute* "config.mk"
|
| 127 | (("/usr/share/netpbm/rgb.txt") rgb))
|
| 128 |
|
| 129 | |
| 130 | |
| 131 | (substitute* "converter/other/pstopnm.c"
|
| 132 | (("\"%s/gs\"")
|
| 133 | "\"%s/gsc\"")
|
| 134 | (("/usr/bin/gs")
|
| 135 | (search-input-file inputs "/bin/gsc"))))))
|
| 136 | (add-before 'check 'setup-check
|
| 137 | (lambda _
|
| 138 | |
| 139 | (invoke "make" "package")
|
| 140 | |
| 141 | (substitute* "test/all-in-place.test" (("pamx") ""))
|
| 142 | |
| 143 | (substitute* "test/all-in-place.test" (("^rm ") "rm -f "))
|
| 144 | |
| 145 | (substitute* "test/Test-Order"
|
| 146 | (("all-in-place.test") "")
|
| 147 | (("pnmpsnr.test") "")
|
| 148 | (("pnmremap1.test") "")
|
| 149 | (("gif-roundtrip.test") "")
|
| 150 |
|
| 151 | |
| 152 | ,@(if (target-ppc32?)
|
| 153 | `((("pbmtog3\\.test") "")
|
| 154 | (("g3-roundtrip\\.test") ""))
|
| 155 | '())
|
| 156 |
|
| 157 | |
| 158 | (("jpeg-roundtrip.test") "")
|
| 159 | (("pbmtext.test") "")
|
| 160 |
|
| 161 | |
| 162 | (("ps-alt-roundtrip.test") "" )
|
| 163 | (("pbm-misc-converters.test") ""))))
|
| 164 | (replace 'install
|
| 165 | (lambda* (#:key outputs make-flags #:allow-other-keys)
|
| 166 | (let ((out (assoc-ref outputs "out")))
|
| 167 | (apply invoke "make" "package"
|
| 168 | (string-append "pkgdir=" out) make-flags)
|
| 169 | |
| 170 | (with-directory-excursion out
|
| 171 | (for-each delete-file-recursively
|
| 172 | '("config_template" "pkginfo" "README" "VERSION"
|
| 173 | "link/" "misc/"))
|
| 174 | |
| 175 | |
| 176 | (with-directory-excursion "lib"
|
| 177 | (symlink
|
| 178 | (match (find-files "." "^libnetpbm\\.so\\.[^.]*\\.[^.]*$")
|
| 179 | ((head _ ...) head))
|
| 180 | "libnetpbm.so")))))))))
|
| 181 | (inputs
|
| 182 | (list ghostscript
|
| 183 | libjpeg-turbo
|
| 184 | libpng
|
| 185 | libtiff
|
| 186 | libxml2
|
| 187 | xorg-rgb
|
| 188 | zlib))
|
| 189 | (native-inputs
|
| 190 | (list flex perl pkg-config python-wrapper))
|
| 191 | (synopsis "Toolkit for manipulation of images")
|
| 192 | (description
|
| 193 | "Netpbm is a toolkit for the manipulation of graphic images, including
|
| 194 | the conversion of images between a variety of different formats.
|
| 195 | There are over 300 separate tools in the package including converters for
|
| 196 | about 100 graphics formats.")
|
| 197 | (license gpl2)
|
| 198 | (home-page "https://netpbm.sourceforge.net/")))
|