projects/guix·blob ruby-team · refs

409 lines · 19.9 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2014 John Darrington <[email protected]>
3;;; Copyright © 2014, 2016 Mark H Weaver <[email protected]>
4;;; Copyright © 2016, 2018, 2024 Ricardo Wurmus <[email protected]>
5;;; Copyright © 2017, 2020 Marius Bakke <[email protected]>
6;;; Copyright © 2018 Tobias Geerinckx-Rice <[email protected]>
7;;; Copyright © 2020, 2021, 2022, 2024 Maxim Cournoyer <[email protected]>
8;;; Copyright © 2020 Boris A. Dekshteyn <[email protected]>
9;;; Copyright © 2020 Ekaitz Zarraga <[email protected]>
10;;; Copyright © 2023, 2024 Efraim Flashner <[email protected]>
11;;; Copyright © 2025 John Kehayias <[email protected]>
12;;;
13;;; This file is part of GNU Guix.
14;;;
15;;; GNU Guix is free software; you can redistribute it and/or modify it
16;;; under the terms of the GNU General Public License as published by
17;;; the Free Software Foundation; either version 3 of the License, or (at
18;;; your option) any later version.
19;;;
20;;; GNU Guix is distributed in the hope that it will be useful, but
21;;; WITHOUT ANY WARRANTY; without even the implied warranty of
22;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23;;; GNU General Public License for more details.
24;;;
25;;; You should have received a copy of the GNU General Public License
26;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
27
28(define-module (gnu packages inkscape)
29 #:use-module ((guix licenses) #:prefix license:)
30 #:use-module (guix packages)
31 #:use-module (guix download)
32 #:use-module (guix gexp)
33 #:use-module (guix utils)
34 #:use-module (guix deprecation)
35 #:use-module (guix build-system cmake)
36 #:use-module (gnu packages)
37 #:use-module (gnu packages algebra)
38 #:use-module (gnu packages bash)
39 #:use-module (gnu packages bdw-gc)
40 #:use-module (gnu packages boost)
41 #:use-module (gnu packages check)
42 #:use-module (gnu packages gettext)
43 #:use-module (gnu packages glib)
44 #:use-module (gnu packages gnome)
45 #:use-module (gnu packages graphics)
46 #:use-module (gnu packages gtk)
47 #:use-module (gnu packages imagemagick)
48 #:use-module (gnu packages libreoffice)
49 #:use-module (gnu packages maths)
50 #:use-module (gnu packages perl)
51 #:use-module (gnu packages pdf)
52 #:use-module (gnu packages popt)
53 #:use-module (gnu packages python)
54 #:use-module (gnu packages python-web)
55 #:use-module (gnu packages python-xyz)
56 #:use-module (gnu packages readline)
57 #:use-module (gnu packages xml)
58 #:use-module (gnu packages ghostscript)
59 #:use-module (gnu packages fontutils)
60 #:use-module (gnu packages image)
61 #:use-module (gnu packages pkg-config)
62 #:use-module (srfi srfi-1))
63
64;;; A variant of Inkscape intended to be bumped only on core-updates, to avoid
65;;; rebuilding 2k+ packages through dblatex. It should only be used as a
66;;; native-input since it might not receive timely security updates.
67(define-public inkscape/pinned
68 (hidden-package
69 (package
70 (name "inkscape")
71 (version "1.3.2")
72 (source
73 (origin
74 (method url-fetch)
75 (uri (string-append "https://media.inkscape.org/dl/"
76 "resources/file/"
77 "inkscape-" version ".tar.xz"))
78 (sha256
79 (base32 "0sq81smxwypgnp7r3wgza8w25dsz9qa8ga79sc85xzj3qi6q9lfv"))
80 (modules '((guix build utils)
81 (ice-9 format)))
82 (patches (search-patches "inkscape-libxml2.patch"))
83 (snippet
84 '(begin
85 (let-syntax
86 ;; XXX: The build system doesn't currently support using
87 ;; system libraries over bundled ones (see:
88 ;; https://gitlab.com/inkscape/inkscape/issues/876).
89 ((unbundle
90 (syntax-rules ()
91 ((_ (name source-dir use-pkg-config?) ...)
92 (begin
93 ;; Delete bundled source directories.
94 (delete-file-recursively source-dir) ...
95 (substitute* '("src/CMakeLists.txt"
96 "src/3rdparty/CMakeLists.txt")
97 (((string-append ".*add_subdirectory\\("
98 (basename source-dir) "\\).*"))
99 "") ...)
100 ;; Remove bundled entries from INKSCAPE_TARGET_LIBS.
101 (substitute* "src/CMakeLists.txt"
102 (((string-append name "_LIB.*")) "") ...)
103 ;; Register the external libraries, so that their
104 ;; headers are added to INKSCAPE_INCS_SYS and their
105 ;; shared libraries added to INKSCAPE_LIBS.
106 (if use-pkg-config?
107 (let* ((width (string-length "pkg_check_modules("))
108 (indent (string-join (make-list width " ") "")))
109 (substitute* "CMakeScripts/DefineDependsandFlags.cmake"
110 (("^pkg_check_modules\\(INKSCAPE_DEP REQUIRED.*" start)
111 (string-append start
112 (format #f "~a~a~%" indent name)))))
113 (substitute* "CMakeScripts/DefineDependsandFlags.cmake"
114 (("^find_package\\(Iconv REQUIRED\\).*" start)
115 (string-append (format #f "
116find_path(~a_INCLUDE_DIR NAMES ~:*~a/~:*~a.h ~:*~a.h)
117if(NOT ~:*~a_INCLUDE_DIR)
118 message(FATAL_ERROR \"~:*~a headers not found\")
119else()
120 list(APPEND INKSCAPE_INCS_SYS ${~:*~a_INCLUDE_DIR})
121endif()
122
123find_library(~:*~a_LIB NAMES ~:*~a)
124if(NOT ~:*~a_LIB)
125 message(FATAL_ERROR \"~:*~a library not found\")
126else()
127 list(APPEND INKSCAPE_LIBS ~:*~a_LIB)
128endif()~%~%"
129 name)
130 start)))) ...
131 ;; Fix the references to the headers of the
132 ;; unbundled libraries.
133 (substitute* (find-files "." "\\.h$|\\.cpp$")
134 (((string-append "#include (\"|<)3rdparty/"
135 (basename source-dir)) _ quote)
136 (string-append "#include " quote
137 (basename source-dir)))
138 ...))))))
139 (unbundle ("2geom" "src/3rdparty/2geom" #t)
140 ;; libcroco cannot be unbundled as it is heavily
141 ;; modified (see:
142 ;; https://gitlab.com/inkscape/inkscape/issues/876#note_276114904).
143 ;; ("croco" "src/3rdparty/libcroco" #t)
144 ;; FIXME: Unbundle the following libraries once they
145 ;; have been packaged.
146 ;; ("cola" "src/3rdparty/adaptagrams/libcola")
147 ;; ("avoid" "src/3rdparty/adaptagrams/libavoid")
148 ;; ("vpsc" "src/3rdparty/adaptagrams/libvpsc")
149 ;; libuemf cannot be unbundled as it slightly modified
150 ;; from upstream (see:
151 ;; https://gitlab.com/inkscape/inkscape/issues/973).
152 ;; ("uemf" "src/3rdparty/libuemf" #f)
153 ;; FIXME: libdepixelize upstream is ancient and doesn't
154 ;; build with a recent lib2geom
155 ;; (see: https://bugs.launchpad.net/libdepixelize/+bug/1862458).
156 ;;("depixelize" "src/3rdparty/libdepixelize")
157 ("autotrace" "src/3rdparty/autotrace" #t)))
158 ;; Lift the requirement on the double-conversion library, as
159 ;; it is only needed by lib2geom, which is now unbundled.
160 (substitute* "CMakeScripts/DefineDependsandFlags.cmake"
161 ((".*find_package\\(DoubleConversion.*") ""))))))
162 (build-system cmake-build-system)
163 (arguments
164 (list
165 #:disallowed-references (list (this-package-native-input "imagemagick"))
166
167 #:imported-modules `(,@%cmake-build-system-modules
168 (guix build glib-or-gtk-build-system))
169 #:modules '((guix build cmake-build-system)
170 ((guix build glib-or-gtk-build-system) #:prefix glib-or-gtk:)
171 (guix build utils))
172 ;; Disable imagemagick support in the stable variant, to reduce the
173 ;; number of dependents of the 'imagemagick' package.
174 #:configure-flags
175 #~(list "-DWITH_IMAGE_MAGICK=OFF"
176 ;; TODO: Remove after next release, since the problematic
177 ;; libsoup/soup.h include is no longer used.
178 (string-append "-DCMAKE_CXX_FLAGS=-I"
179 (search-input-directory %build-inputs
180 "/include/libsoup-2.4")))
181 #:phases
182 #~(modify-phases %standard-phases
183 (add-after 'unpack 'generate-gdk-pixbuf-loaders-cache-file
184 (assoc-ref glib-or-gtk:%standard-phases
185 'generate-gdk-pixbuf-loaders-cache-file))
186 #$@(if (or (target-aarch64?)
187 (target-ppc64le?)
188 (target-riscv64?))
189 '((add-after 'unpack 'disable-more-tests
190 (lambda _
191 ;; https://gitlab.com/inkscape/inkscape/-/issues/3554#note_1035680690
192 (substitute* "testfiles/CMakeLists.txt"
193 (("lpe64-test") "#lpe64-test")
194 ((" lpe-test") " #lpe-test")
195 (("add_subdirectory\\(lpe_tests\\)") ""))
196 ;; https://gitlab.com/inkscape/inkscape/-/issues/3554#note_1035539888
197 ;; According to upstream, this is a false positive.
198 (substitute* "testfiles/rendering_tests/CMakeLists.txt"
199 (("add_rendering_test\\(test-use" all)
200 (string-append "#" all)))
201 ;; https://gitlab.com/inkscape/inkscape/-/issues/3554#note_1035539888
202 ;; Allegedly a precision error in the gamma.
203 (substitute* "testfiles/cli_tests/CMakeLists.txt"
204 (("add_cli_test\\(export-png-color-mode-gray-8_png" all)
205 (string-append "#" all))
206 ;; These also seem to be failing due to precision errors.
207 (("add_pdfinput_test\\(font-(spacing|style) 1 draw-all" all)
208 (string-append "#" all))))))
209 '())
210 #$@(if (or (target-x86-32?)
211 (target-arm32?))
212 '((add-after 'unpack 'fix-32bit-size_t-format
213 (lambda _
214 ;; Fix an error due to format type mismatch with 32-bit size_t.
215 (substitute* "testfiles/src/visual-bounds-test.cpp"
216 (("%lu") "%u")))))
217 '())
218 (add-after 'unpack 'set-home
219 ;; Mute Inkscape warnings during tests.
220 (lambda _
221 (setenv "HOME" (getcwd))))
222 ;; Move the check phase after the install phase, as when run in the
223 ;; tests, Inkscape relies on files that are not yet installed, such
224 ;; as the "share/inkscape/ui/units.xml" file.
225 (delete 'check)
226 (add-after 'install 'check
227 ;; Use ctest directly so that we can easily exclude problematic
228 ;; tests.
229 (lambda* (#:key parallel-tests? tests? #:allow-other-keys)
230 (when tests?
231 ;; The following tests fails, perhaps due to building without
232 ;; ImageMagick (see:
233 ;; https://gitlab.com/inkscape/inbox/-/issues/10005).
234 (let ((job-count (if parallel-tests?
235 (number->string (parallel-job-count))
236 "1"))
237 (skipped-tests
238 (list "cli_export-type-caseinsensitive_check_output"
239 "cli_export-type_xaml_check_output"
240 "cli_export-height_export-use-hints_check_output"
241 "cli_export-plain-svg_check_output"
242 "cli_export-use-hints_export-id_check_output"
243 "cli_export-extension_svg_check_output"
244 "cli_export-extension_ps_check_output"
245 "cli_export-extension_eps_check_output"
246 "cli_export-extension_pdf_check_output"
247 "cli_export-plain-extension-svg_check_output"
248 ;; These fail non-deterministically (see:
249 ;; https://gitlab.com/inkscape/inbox/-/issues/10005).
250 "cli_export-ps-level_3_check_output"
251 "cli_export-ps-level_3_content_check_output"
252 "cli_export-ps-level_2_content_check_output"
253 "cli_export-ps-level_2_check_output"
254 ;; These fail on i686 but not x86-64
255 #$@(if (target-x86-32?)
256 '("cli_actions-path-simplify_check_output"
257 "cli_pdfinput-font-spacing_check_output"
258 "cli_pdfinput-font-style_check_output"
259 "cli_pdfinput-latex_check_output"
260 "cli_pdfinput-multi-page-sample_check_output"
261 "test_lpe")
262 '()))))
263 (invoke "make" "-j" job-count "tests")
264 (invoke "ctest" "-j" job-count
265 "--output-on-failure"
266 "-E" (string-append
267 "(" (string-join skipped-tests "|") ")"))))))
268 (add-after 'install 'glib-or-gtk-compile-schemas
269 (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-compile-schemas))
270 (add-after 'glib-or-gtk-compile-schemas 'glib-or-gtk-wrap
271 (assoc-ref glib-or-gtk:%standard-phases 'glib-or-gtk-wrap))
272 (add-after 'install 'wrap-program
273 ;; Ensure Python is available at runtime.
274 (lambda* (#:key inputs #:allow-other-keys)
275 (wrap-program (string-append #$output "/bin/inkscape")
276 `("PATH" prefix
277 (,(dirname (search-input-file inputs "bin/python"))))
278 `("GUIX_PYTHONPATH" prefix
279 (,(getenv "GUIX_PYTHONPATH")))
280 ;; Wrapping GDK_PIXBUF_MODULE_FILE allows Inkscape to load
281 ;; its own icons in pure environments.
282 `("GDK_PIXBUF_MODULE_FILE" =
283 (,(getenv "GDK_PIXBUF_MODULE_FILE")))
284 ;; Ensure GObject Introspection typelibs are found.
285 `("GI_TYPELIB_PATH" ":" prefix
286 (,(getenv "GI_TYPELIB_PATH")))))))))
287 (inputs
288 (list (librsvg-for-system) ;for the pixbuf loader
289 autotrace
290 bash-minimal
291 boost
292 freetype
293 gdl-minimal
294 gsl
295 gspell
296 gtk+
297 gtkmm-3
298 lcms
299 lib2geom/pinned
300 libcdr
301 libgc
302 libjpeg-turbo
303 libpng
304 libsoup-minimal-2
305 libvisio
306 libwpd
307 libwpg
308 libxml2
309 libxslt
310 poppler
311 popt
312 potrace
313 ;; These Python dependencies are used by the Inkscape extension
314 ;; management system. To verify that it is working, visit the
315 ;; Extensions -> Manage Extensions... menu.
316 python-appdirs
317 python-cssselect
318 python-lxml
319 python-numpy
320 python-pygobject
321 python-pyserial
322 python-requests
323 python-scour
324 python-wrapper
325 readline))
326 (native-inputs
327 (list `(,glib "bin")
328 bc
329 gettext-minimal
330 googletest
331 imagemagick/stable ;for tests
332 perl
333 pkg-config))
334 (home-page "https://inkscape.org/")
335 (synopsis "Vector graphics editor")
336 (description "Inkscape is a vector graphics editor. What sets Inkscape
337apart is its use of Scalable Vector Graphics (SVG), an XML-based W3C standard,
338as the native format.")
339 (license license:gpl3+)))) ;see the file COPYING
340
341(define-deprecated/public-alias inkscape/stable inkscape/pinned)
342
343;;; The Inkscape release year used in the about dialog. Please keep it sync
344;;; when updating the package!
345(define %inkscape-release-year 2025)
346(define-public inkscape
347 (package
348 (inherit inkscape/pinned)
349 (name "inkscape")
350 (version "1.4.3")
351 (source
352 (origin
353 (inherit (package-source inkscape/pinned))
354 (method url-fetch)
355 (uri (string-append "https://media.inkscape.org/dl/"
356 "resources/file/"
357 "inkscape-" version ".tar.xz"))
358 (patches '())
359 (sha256
360 (base32 "1lfi1rqr32kwjdkka4sbsxmkyyw3k1qgxk0gzyhwbdkhnlyjqfp8"))))
361 (build-system cmake-build-system)
362 (arguments
363 (substitute-keyword-arguments (package-arguments inkscape/pinned)
364 ((#:modules modules)
365 (append '(((guix build gnu-build-system) #:prefix gnu:)) modules))
366 ((#:configure-flags flags ''())
367 ;; Enable ImageMagick support.
368 #~(delete "-DWITH_IMAGE_MAGICK=OFF" #$flags))
369 ((#:phases phases)
370 #~(modify-phases #$phases
371 (add-after 'unpack 'patch-inkscape-build-year
372 (lambda _
373 (substitute* "CMakeScripts/inkscape-version.cmake"
374 (("string\\(TIMESTAMP INKSCAPE_BUILD_YEAR.*")
375 (format #f "set(INKSCAPE_BUILD_YEAR ~a)~%"
376 #$%inkscape-release-year)))))
377 #$@(if (target-x86-32?)
378 #~() ;XXX: there are remaining failures on i686
379 ;; Re-instate the tests disabled in inkscape/pinned, now that
380 ;; their ImageMagick requirement is satisfied.
381 #~((replace 'check (assoc-ref gnu:%standard-phases 'check))))
382 #$@(if (or (target-aarch64?)
383 (target-ppc64le?)
384 (target-riscv64?))
385 '((add-after 'unpack 'disable-geom-pathstroke-test
386 (lambda _
387 ;; https://gitlab.com/inkscape/lib2geom/-/work_items/80
388 (substitute* "testfiles/CMakeLists.txt"
389 ((" geom-pathstroke-test") "")))))
390 '())
391 (replace 'wrap-program
392 ;; Ensure Python is available at runtime.
393 (lambda _
394 (wrap-program (string-append #$output "/bin/inkscape")
395 `("GUIX_PYTHONPATH" prefix
396 (,(getenv "GUIX_PYTHONPATH")))
397 ;; Wrapping GDK_PIXBUF_MODULE_FILE allows Inkscape to load
398 ;; its own icons in pure environments.
399 `("GDK_PIXBUF_MODULE_FILE" =
400 (,(getenv "GDK_PIXBUF_MODULE_FILE"))))))))))
401 (inputs (modify-inputs (package-inputs inkscape/pinned)
402 (replace "lib2geom" lib2geom)
403 (append imagemagick ;for libMagickCore and libMagickWand
404 python-tinycss2)))
405 (native-inputs
406 (modify-inputs (package-native-inputs inkscape/pinned)
407 ;; Only use 1 imagemagick across the package build.
408 (replace "imagemagick" imagemagick)))
409 (properties (alist-delete 'hidden? (package-properties inkscape/pinned)))))