53.8. curl-8.23.0
Utility and a library used for transferring files
| Version | 8.23.0, release 1 |
| Shelf | net-libs — Networking and protocol libraries |
| Phase | 30_foundation (Build Foundation), 116 of 127 in build order |
| Licence | curl |
| Homepage | https://curl.se/ |
| Build time | 0.9 SBU |
| Installed size | 5.7 MiB in 552 files |
| Recipe | ports/core/net-libs/curl/kpkgbuild |
About
curl is the curl command and libcurl, the library behind it: URL transfers over HTTP(S) in all three versions, FTP, SCP and SFTP, LDAP, SMTP, IMAP and the rest of its protocols. git, in the same phase, links it for HTTP remotes; rust’s cargo and cargo-c, in 31_compilers, link it too; and many later ports depend on it.
KDOS’s own tools run the curl command rather than linking the library, always through an argument vector and never a shell. kdos update fetch downloads the signed ports tree with it and takes curl’s exit codes for an unresolved name, a refused connection and a timeout to mean the machine is offline; kpkg downloads each source with it during kdos update apply; and kdos-fetch-static downloads with it too. The build’s own ports/fetch and ports/publish run on the build host and use the host’s curl, not this one.
Almost every switch in build.sh names a feature, and the library behind it is in the recipe’s depends, so it is installed before curl builds. Left to itself, configure looks for each optional library and builds without the feature when it finds none; named, each makes a missing library an error instead. libidn2 is the exception: configure only warns about it whatever the switches say. The Notes describe the two checks build.sh adds after configure.
Sources
curl-8.23.0.tar.xz(2.9 MiB)
sha2568dadd7d2536a314f982ad05a651b713f426bf7d02cc2c76cffb9796f2218e6c5
upstream: https://curl.haxx.se/download/curl-8.23.0.tar.xz
archive copy: sources-3/net-libs--curl-8.23.0.tar.xz
Dependencies
Depends on: ca-certificates, openssl, zlib, perl, nghttp2, ngtcp2, nghttp3, libidn2, libunistring, libpsl, libssh2, zstd, brotli, openldap.
Required by (77): amiberry, appstream, ardour, bladerf, cargo-c, chromium, clamav, coeurl, darktable, ddnet, freeciv, fwupd, git, gnuastro, gpredict, gst-plugins-bad, horizon-eda, htslib, hurl, imhex, ioquake3, kdos-tools, kicad, kodi, koreader, libgphoto2, libkiwix, libmediainfo, libproxy, libqalculate, libreoffice, libtatsu, lnav, mpd, mtxclient, mupdf, nbdkit, nco, netcdf-c, netsurf, networkmanager, newsboat, nheko, obs-studio, octave, opencpn, openttd, orcaslicer, pdal, postgresql, powerman, predict, profanity, prusaslicer, qemu, R, remmina, rust, sane-backends, satdump, sfeed, srb2, supertuxkart, tesseract, tpm2-tools, tpm2-tss, transmission, viking, vorbis-tools, warzone2100, weechat, wesnoth, wxwidgets, xastir, xmlrpc-c, xonotic, yamagi-quake2.
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/30_foundation/phase.env && kpkg install curl'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/net-libs/curl.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/net-libs/curl
echo '8dadd7d2536a314f982ad05a651b713f426bf7d02cc2c76cffb9796f2218e6c5 curl-8.23.0.tar.xz' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/curl
SRC=$SRC_ROOT/curl-8.23.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf curl-8.23.0.tar.xz -C "$SRC" --strip-components=1
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
./configure \
--prefix=/usr \
--enable-ldap \
--enable-ldaps \
--enable-threaded-resolver \
--with-ca-bundle=/etc/ssl/certs/ca-certificates.crt \
--with-openssl \
--with-nghttp2 \
--with-ngtcp2 \
--with-nghttp3 \
--with-libidn2 \
--with-libpsl \
--with-libssh2 \
--with-zstd \
--with-brotli \
--with-zsh-functions-dir=/usr/share/zsh/site-functions \
--without-fish-functions-dir
grep -q '^#define USE_OPENLDAP 1' lib/curl_config.h ||
{ echo "curl: OpenLDAP not found at configure" >&2; exit 1; }
grep -q '^#define HAVE_BROTLI 1' lib/curl_config.h ||
{ echo "curl: brotli not found at configure" >&2; exit 1; }
make
make DESTDIR=$PKG install
The switches, and why each is set:
--with-openssl— build the TLS layer on openssl. curl’s configure stops unless a TLS backend is chosen or TLS is explicitly turned off. It is also the backend HTTP/3 needs here: configure requires the ngtcp2 crypto helper for the TLS library curl is built on, and the ngtcp2 port builds only the OpenSSL one,ngtcp2_crypto_ossl.--with-ca-bundle=/etc/ssl/certs/ca-certificates.crt— the CA bundle compiled in as the default for verifying servers. The path is a link to/etc/ssl/cert.pem, the fileupdate-ca-certificateswrites from the Mozilla roots and any local ones, so curl trusts what every other OpenSSL program on the system trusts; see TLS trust anchors.--with-nghttp2— HTTP/2, through nghttp2.--with-ngtcp2— with--with-nghttp3, HTTP/3 over QUIC: ngtcp2 is the QUIC transport and nghttp3 the HTTP/3 layer. Configure stops if either is missing, or if ngtcp2 has no crypto helper for the TLS backend chosen.--with-nghttp3— see--with-ngtcp2.--with-libidn2— international domain names: a host name in Unicode is converted to its ASCII form with libidn2 before it is resolved. Configure does not stop when libidn2 is missing even with this switch; it prints “Cannot find libidn2” and builds without it.--with-libpsl— cookie domains are checked against the Public Suffix List with libpsl, so a server cannot set a cookie for a whole suffix such asco.uk.--with-libssh2— thescp://andsftp://protocols, through libssh2.--with-zstd— acceptzstd-compressed responses (Content-Encoding: zstd), through zstd.--with-brotli— accept Brotli-compressed responses (Content-Encoding: br), through the brotli decoder.--enable-ldap—ldap://URLs. Left to itself, configure looks for the LDAP libraries and, when it does not find them, prints a warning and builds without LDAP; named, the switch makes it stop withcould not detect the LDAP librariesinstead. The libraries are openldap’s, which30_foundation’s list installs “for curl’s ldap:// URLs and dirmngr’s directory lookups”.--enable-ldaps—ldaps://, LDAP over TLS. It is turned off with LDAP, and with OpenLDAP it also needs curl’s TLS layer.--enable-threaded-resolver— resolve host names on a thread of their own, so a transfer can time out or be cancelled whilegetaddrinfois still waiting. It is configure’s default on Linux when c-ares is not used, and naming it makes configure stop if no thread library is found. curl is not built against c-ares.--with-zsh-functions-dir=/usr/share/zsh/site-functions— install the_curlcompletion where zsh loads completions from. Configure generates it with a Perl script, and skips it, with a warning, when Perl is missing; perl is in the recipe’sdepends.--without-fish-functions-dir— install no fish completion. That is configure’s default already; fish is not a port in this tree.
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/curl, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf curl-8.23.0-1.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/curl, and runs the triggers its paths call for.
Contents
Installed programs: curl, curl-config, wcurl.
Installed libraries: libcurl.a, libcurl.so.
Installed directories: /usr/include/curl, /usr/share/licenses/curl.
Short descriptions
curl |
transfer a URL |
curl-config |
Get information about a libcurl installation |
wcurl |
a simple wrapper around curl to easily download files. |
libcurl.pc |
Library to transfer files with HTTP, FTP, etc. |
Notes
Two checks run between configure and make. Each greps lib/curl_config.h, the header configure writes, and stops the build unless it defines a feature:
USE_OPENLDAP 1: configure found OpenLDAP’sldap_init_fdand built LDAP support on OpenLDAP’s own code path. When it finds an LDAP library without that function, configure reports “enabled (ancient OpenLDAP)”, defines nothing, and carries on; this check stops the build there instead.HAVE_BROTLI 1: the Brotli decoder was found.--with-brotlialready stops configure when it is not, so this check is a second guard for the same feature.
When either fails, the message names the library: “curl: OpenLDAP not found at configure” or “curl: brotli not found at configure”. Look in config.log for why the library’s check failed, not in make’s output.