53.7. libssh2-1.11.1
Client-side C library implementing the SSH2 protocol
| Version | 1.11.1, release 1 |
| Shelf | net-libs — Networking and protocol libraries |
| Phase | 30_foundation (Build Foundation), 114 of 127 in build order |
| Licence | BSD-3-Clause |
| Homepage | https://libssh2.org/ |
| Build time | 0.5 SBU |
| Installed size | 645.0 KiB in 194 files |
| Recipe | ports/core/net-libs/libssh2/kpkgbuild |
About
libssh2 is a client-side implementation of the SSH-2 protocol as a C library: sessions, authentication, channels, SCP and SFTP. It has no server side and no command-line programs of its own; the ssh command on KDOS is OpenSSH’s.
curl, in the same phase, 30_foundation, links it for its scp:// and sftp:// URLs. libgit2 uses it for SSH remotes, and through libgit2 and their own -sys crates rust and cargo-c do too; vlc, mc, nmap, aria2, libvirt, imhex and gst-plugins-bad depend on it as well. The libssh2-sys crate asks pkg-config for this library only when LIBSSH2_SYS_USE_PKG_CONFIG=1 is set, which both of those build.sh files export, and compiles a copy of its own in silence when it finds none; see rust.
Sources
libssh2-1.11.1.tar.gz(1.0 MiB)
sha256d9ec76cbe34db98eec3539fe2c899d26b0c837cb3eb466a56b0f109cabf658f7
upstream: https://www.libssh2.org/download/libssh2-1.11.1.tar.gz
archive copy: sources-3/net-libs--libssh2-1.11.1.tar.gz
Dependencies
Required by (11): aria2, cargo-c, curl, gst-plugins-bad, imhex, libgit2, libvirt, mc, nmap, rust, vlc.
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 libssh2'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/net-libs/libssh2.
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/libssh2
echo 'd9ec76cbe34db98eec3539fe2c899d26b0c837cb3eb466a56b0f109cabf658f7 libssh2-1.11.1.tar.gz' | 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/libssh2
SRC=$SRC_ROOT/libssh2-1.11.1
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf libssh2-1.11.1.tar.gz -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 --disable-static --with-crypto=openssl --with-libz \
--disable-examples-build --disable-rpath
make
make DESTDIR=$PKG install
The switches, and why each is set:
--with-crypto=openssl— the cryptography library libssh2 is built on. The default,auto, tries OpenSSL, libgcrypt, mbedTLS, WinCNG and wolfSSL in that order and takes the first it finds; libgcrypt and mbedtls are ports too, in41_system. Named, OpenSSL is the only backend configure looks for, and a missing OpenSSL stops it withRequired dependencies are missing.instead of falling back to another. It is the same library curl, which links this one, uses for TLS.--with-libz— compression of the SSH transport through zlib. The default,auto, turns compression off with a notice when zlib is not found; naming it makes a missing zlib an error.--disable-examples-build— do not compile the example programs underexample/, which upstream builds by default and never installs.--disable-rpath— a switch of gnulib’s library-search macros, which configure uses to find OpenSSL and zlib: with it, they hard-code no directory they found a library in as a run path inlibssh2.so. Every library it links is in/usr/lib, the loader’s default path, and the package lint warns on such an entry (see What the package lint refuses).
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/libssh2, 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 libssh2-1.11.1-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/libssh2, and runs the triggers its paths call for.
Contents
Installed libraries: libssh2.so.
Installed directories: /usr/share/licenses/libssh2.
Short descriptions
libssh2.pc |
Library for SSH-based communication |