8.113. Curl-8.12.1

The cURL package contains an utility and a library used for transferring files with URL syntax to any of the following protocols: FTP, FTPS, HTTP, HTTPS, SCP, SFTP, TFTP, TELNET, DICT, LDAP, LDAPS and FILE. Its ability to both download and upload files can be incorporated into other programs to support functions like streaming media.

Approximate build time: 0.2 SBU
Required disk space: 53 MB
[Note]

Note

The curl pacakge built here has many more depenencies as listed in the optdepends array below, and is somewhat limited. You should consider reviewing the package's optional dependencies and adjusting as necessary.

Create the PKGBUILD for the cURL package with the following commands:

mkdir /sources/curl
cd /sources/curl
cat > PKGBUILD << "REALEOF"
# Maintainer: Linux From Scratch <lfs-dev@lists.linuxfromscratch.org>

pkgname="curl"
pkgver="8.12.1"
pkgrel="1"
pkgdesc="cURL is a URL retrieval utility and library"
arch=('x86'
      'x86_64')
url="https://curl.haxx.se/"
license=('MIT')
groups=('core')
depends=('glibc'
         'make-ca'
         'libidn2'
         'libpsl'
         'openssl'
         'rootfs'
         'zlib')
makedepends=('bash'
             'binutils'
             'coreutils'
             'gcc'
             'gettext'
             'grep'
             'make'
             'pacman'
             'sed'
             'texinfo'
             'xz')
optdepends('apache'
           'axtls'
           'brotli'
           'c-ares'
           'cyassl'
           'gnutls'
           'impacket'
           'krb5'
           'libidn'
           'libmetalink'
           'librtmp'
           'libssh2'
           'mbedtls'
           'nghttp2'
           'ngtcp2'
           'nss'
           'openldap'
           'openssh'
           'polarssl'
           'quiche'
           'samba'
           'spnego'
           'stunnel'
           'valgrind')
source=('https://curl.haxx.se/download/curl-8.12.1.tar.xz')
md5sums=('7940975dd510399c4b27831165ab62e0')
 
build(){
  cd "${pkgname}-${pkgver}"
  ./configure --prefix=/usr                           \
              --disable-static                        \
              --enable-threaded-resolver              \
              --with-ca-path=/etc/ssl/certs
  make
}

package(){
  cd "${pkgname}-${pkgver}"
  rm -rf docs/examples/.deps
  find docs \( -name Makefile\* -o  \
               -name \*.1       -o  \
               -name \*.3       -o  \
               -name CMakeLists.txt \) -delete
  install -vdm755 "${pkgdir}/usr/share/doc/${pkgname}-${pkgver}"
  cp -v -R docs -T "${pkgdir}/usr/share/doc/${pkgname}-${pkgver}"
}
REALEOF

Prepare the build directory for the pacman user and build the package:

chown -R root:pacman .
chmod 2775 .
chmod 664 PKGBUILD
su pacman -c 'makepkg -L --nodeps'

Add the newly created package to the central package repository:

cp curl-8.12.1-1-$(uname -m).pkg.tar.xz \
   /srv/pacman/repos/LFS/
repo-add /srv/pacman/repos/LFS/LFS.db.tar.xz \
         /srv/pacman/repos/LFS/curl-8.12.1-1-$(uname -m).pkg.tar.xz

Update the local cache and install the cURL package:

pacman -Syu
pacman -S curl --overwrite \* -dd --noconfirm

Finally, copy the source files into the source repository and clean up the build directory:

mkdir /srv/pacman/source/LFS/curl
cp PKGBUILD /srv/pacman/source/LFS/curl
cd /sources
rm -rf curl

8.113.2. Command Explanations

--enable-threaded-resolver: This switch enables cURL's builtin threaded DNS resolver.

--with-ca-path=/etc/ssl/certs: This switch sets the location of the BLFS Certificate Authority store.

--with-gssapi: This parameter adds Kerberos 5 support to libcurl.

--without-ssl --with-gnutls: Use to build with GnuTLS support instead of OpenSSL for SSL/TLS.

--with-ca-bundle=/etc/pki/tls/certs/ca-bundle.crt: Use this switch instead of --with-ca-path if building with GnuTLS support instead of OpenSSL for SSL/TLS.

--with-libssh2: This paramater adds SSH support to cURL. This is disabled by default.

--enable-ares: This paramater adds support for DNS resolution through the c-ares library. It is disabled by default, but does speed up DNS resolution queries.

find docs ... -exec rm {} \;: This command removes Makefiles and man files from the documentation directory that would otherwise be installed by the commands that follow.

8.113.3. Contents

Installed Programs: curl and curl-config
Installed Library: libcurl.so
Installed Directories: /usr/include/curl and /usr/share/doc/curl-8.12.1

Short Descriptions

curl

is a command line tool for transferring files with URL syntax.

curl-config

prints information about the last compile, like libraries linked to and prefix setting.

libcurl.so

provides the API functions required by curl and other programs.