AtlatestRepositorycore-channel
core-channel / tree / src / core / packagesxml.sgl
1
;;; XML and HTML parsing.2
;;;3
;;; libxml2 is what gives Emacs `libxml-parse-html-region`, and therefore shr4
;;; and eww. Built static and deliberately narrow: no Python bindings, no5
;;; loadable modules, and no HTTP client, because Emacs uses libxml2 purely as6
;;; a parser and its network stack is its own.7
;;;8
;;; It also carries the channel's first patch, and the reason is worth reading9
;;; 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
(begin17
(define libxml218
(package19
name: "libxml2"20
version: "2.13.5"21
source: (external-source22
location: "https://download.gnome.org/sources/libxml2/2.13/libxml2-2.13.5.tar.xz"23
sha256: "74fc163217a3964257d3be39af943e08861263c4231f9ef5b496b6f6d4c7b2b6")24
buildenv: core-buildenv25
phases: (list26
;; WHY THIS PATCH EXISTS. The pinned seed's pkgconf 1.9.527
;; ABORTS (SIGABRT, a Zig pointer-overflow panic) on any .pc28
;; file carrying an EMPTY dependency-list field, and libxml229
;; installs `Requires:` empty because it is built30
;; --without-zlib. Emacs finds libxml2 through31
;; PKG_CHECK_MODULES, which runs `pkg-config --exists` and32
;; reads ANY non-zero status as "not present" -- so a33
;; crashing tool impersonates a calm, plausible absence and34
;; configure still exits 0. That is how the port build lost35
;; libxml2 with no error and no warning.36
;;37
;; Measured against the seed's own pkg-config, both38
;; 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, before44
;; configure substitutes it, so no empty field is ever45
;; generated. It fixes libxml2 only. The general fix is a46
;; seed re-pin onto a pkgconf past the bug47
;; (investigations/seed-pkgconf-empty-field-abort), which is48
;; still owed -- gnutls' closure will hit the same wall.49
(external-phase50
kind: 'patch51
patches: (list52
(channel-patch53
path: "patches/libxml2-pc-drop-empty-requires.patch"54
sha256: "386f08e511d8f45fd649aacc2a55c7fcd52bdbc9ed11fac8fc613aa63eebf441")))55
(external-phase56
kind: 'configure57
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 than69
;; folded into libxml2's consumers because two different packages ask for70
;; it by name through pkg-config: libwayland (for wayland-scanner, which71
;; parses the protocol XML) and fontconfig (for fonts.conf). Neither can72
;; use libxml2 instead.73
;;74
;; MUST SHIP A `.pc` FILE, and this is not incidental. Both consumers find75
;; it through PKG_CHECK_MODULES, and a dependency that is found by header76
;; probe instead of by pkg-config is how `core/ncurses` poisoned tmux's77
;; entire configure -- a probe that tested a header and concluded about a78
;; library. expat's autotools build installs `expat.pc` by default; that79
;; is asserted below rather than assumed, because "it installs one by80
;; default" is exactly the kind of belief that turns out to be false after81
;; a build cycle.82
(define expat83
(package84
name: "expat"85
version: "2.7.1"86
source: (external-source87
location: "https://github.com/libexpat/libexpat/releases/download/R_2_7_1/expat-2.7.1.tar.xz"88
sha256: "354552544b8f99012e5062f7d570ec77f14b412a3ff5c7d8d0dae62c0d217c30")89
buildenv: core-buildenv90
phases: (list91
(external-phase92
kind: 'configure93
args: (list "--prefix=${out}"94
"--disable-shared"95
"--enable-static"96
;; xmlwf is a command-line tool no consumer97
;; here uses, and the examples and tests are98
;; 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 expat106
;; stops installing one, the failure without this check is107
;; not "expat is broken" -- it is fontconfig or wayland108
;; quietly configuring itself differently, three packages109
;; downstream, with configure still exiting 0.110
(external-phase111
kind: 'run112
args: (list "sh" "-c"113
(string-append114
"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"))))))))