AtlatestRepositorycore-channel
1;;; XML and HTML parsing.
2;;;
3;;; libxml2 is what gives Emacs `libxml-parse-html-region`, and therefore shr
4;;; and eww. Built static and deliberately narrow: no Python bindings, no
5;;; loadable modules, and no HTTP client, because Emacs uses libxml2 purely as
6;;; a parser and its network stack is its own.
7;;;
8;;; It also carries the channel's first patch, and the reason is worth reading
9;;; before touching it -- see the note beside the `patch` phase.
10(define-library (core packages xml)
11 (import (sigil core)
12 (core build-environments)
13 (sigil env package)
14 (sigil build external))
15 (export libxml2 expat)
16 (begin
17 (define libxml2
18 (package
19 name: "libxml2"
20 version: "2.13.5"
21 source: (external-source
22 location: "https://download.gnome.org/sources/libxml2/2.13/libxml2-2.13.5.tar.xz"
23 sha256: "74fc163217a3964257d3be39af943e08861263c4231f9ef5b496b6f6d4c7b2b6")
24 buildenv: core-buildenv
25 phases: (list
26 ;; WHY THIS PATCH EXISTS. The pinned seed's pkgconf 1.9.5
27 ;; ABORTS (SIGABRT, a Zig pointer-overflow panic) on any .pc
28 ;; file carrying an EMPTY dependency-list field, and libxml2
29 ;; installs `Requires:` empty because it is built
30 ;; --without-zlib. Emacs finds libxml2 through
31 ;; PKG_CHECK_MODULES, which runs `pkg-config --exists` and
32 ;; reads ANY non-zero status as "not present" -- so a
33 ;; crashing tool impersonates a calm, plausible absence and
34 ;; configure still exits 0. That is how the port build lost
35 ;; libxml2 with no error and no warning.
36 ;;
37 ;; Measured against the seed's own pkg-config, both
38 ;; directions: with the empty `Requires:` line,
39 ;; `pkg-config --exists libxml-2.0` exits 134 with the panic;
40 ;; with the line deleted it exits 0 and `--cflags --libs`
41 ;; returns exactly what Emacs needs.
42 ;;
43 ;; This patch deletes the line from the TEMPLATE, before
44 ;; configure substitutes it, so no empty field is ever
45 ;; generated. It fixes libxml2 only. The general fix is a
46 ;; seed re-pin onto a pkgconf past the bug
47 ;; (investigations/seed-pkgconf-empty-field-abort), which is
48 ;; still owed -- gnutls' closure will hit the same wall.
49 (external-phase
50 kind: 'patch
51 patches: (list
52 (channel-patch
53 path: "patches/libxml2-pc-drop-empty-requires.patch"
54 sha256: "386f08e511d8f45fd649aacc2a55c7fcd52bdbc9ed11fac8fc613aa63eebf441")))
55 (external-phase
56 kind: 'configure
57 args: (list "--prefix=${out}"
58 "--disable-shared"
59 "--enable-static"
60 "--without-python"
61 "--without-lzma"
62 "--without-zlib"
63 "--without-http"
64 "--without-modules"))
65 (external-phase kind: 'make)
66 (external-phase kind: 'install))))
68 ;; expat, the OTHER XML parser in this channel, and it is here rather than
69 ;; folded into libxml2's consumers because two different packages ask for
70 ;; it by name through pkg-config: libwayland (for wayland-scanner, which
71 ;; parses the protocol XML) and fontconfig (for fonts.conf). Neither can
72 ;; use libxml2 instead.
73 ;;
74 ;; MUST SHIP A `.pc` FILE, and this is not incidental. Both consumers find
75 ;; it through PKG_CHECK_MODULES, and a dependency that is found by header
76 ;; probe instead of by pkg-config is how `core/ncurses` poisoned tmux's
77 ;; entire configure -- a probe that tested a header and concluded about a
78 ;; library. expat's autotools build installs `expat.pc` by default; that
79 ;; is asserted below rather than assumed, because "it installs one by
80 ;; default" is exactly the kind of belief that turns out to be false after
81 ;; a build cycle.
82 (define expat
83 (package
84 name: "expat"
85 version: "2.7.1"
86 source: (external-source
87 location: "https://github.com/libexpat/libexpat/releases/download/R_2_7_1/expat-2.7.1.tar.xz"
88 sha256: "354552544b8f99012e5062f7d570ec77f14b412a3ff5c7d8d0dae62c0d217c30")
89 buildenv: core-buildenv
90 phases: (list
91 (external-phase
92 kind: 'configure
93 args: (list "--prefix=${out}"
94 "--disable-shared"
95 "--enable-static"
96 ;; xmlwf is a command-line tool no consumer
97 ;; here uses, and the examples and tests are
98 ;; build-time only.
99 "--without-xmlwf"
100 "--without-examples"
101 "--without-tests"
102 "--without-docbook"))
103 (external-phase kind: 'make)
104 (external-phase kind: 'install)
105 ;; ASSERT THE `.pc` RATHER THAN TRUST IT. If a future expat
106 ;; stops installing one, the failure without this check is
107 ;; not "expat is broken" -- it is fontconfig or wayland
108 ;; quietly configuring itself differently, three packages
109 ;; downstream, with configure still exiting 0.
110 (external-phase
111 kind: 'run
112 args: (list "sh" "-c"
113 (string-append
114 "set -eu\n"
115 "d=\"$(dirname \"$PWD\")/install-root\"\n"
116 "test -f \"$d${out}/lib/pkgconfig/expat.pc\"\n"
117 "echo EXPAT-PC-PRESENT\n"))))))))