104.11. libnbd-1.24.3
NBD client library and the nbdsh, nbdcopy, nbdinfo, nbddump and nbdfuse tools
| Version | 1.24.3, release 1 |
| Shelf | virt — Virtual machines, their tooling, and remote-desktop and VNC protocols |
| Phase | 41_system (System), 1010 of 1047 in build order |
| Licence | LGPL-2.1-or-later |
| Homepage | https://gitlab.com/nbdkit/libnbd |
| Build time | 1.0 SBU |
| Installed size | 2.3 MiB in 217 files |
| Recipe | ports/core/virt/libnbd/kpkgbuild |
About
libnbd is the client library for the Network Block Device protocol, with its command-line tools: nbdsh, a Python shell over the library; nbdcopy, nbdinfo and nbddump; nbdfuse, which shows an NBD export as a file through FUSE; and nbdublk, which attaches one as a block device through the kernel’s ublk driver. libvirt and nbdkit link it.
Sources
libnbd-1.24.3.tar.gz(1.5 MiB)
sha256da36e77aff952f818222a5a0e6c726b3d492405cb1934a9c81f8e4c0071bb26a
upstream: https://download.libguestfs.org/libnbd/1.24-stable/libnbd-1.24.3.tar.gz
archive copy: sources-4/virt--libnbd-1.24.3.tar.gz
Dependencies
Depends on: pkgconf, perl, libxml2, gnutls, fuse, python3, bash-completion, liburing, ubdsrv.
Required by (2): libvirt, nbdkit.
Optional, off in KDOS
These switches in build.sh turn off a feature whose library is a port here. The recipe may turn each off on purpose, or because the library was not yet a port when the recipe was written; this list cannot tell which.
Patches
build.sh applies these; kpkg applies nothing by itself.
musl-unistd.patch— Adds#include <unistd.h>toublk/tgt.c, which callsgettidandgetpidwithout including the header that declares them. glibc’s other headers bring the declarations in; musl’s do not, and the implicit declaration is an error in current GCC.
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/41_system/phase.env && kpkg install libnbd'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/virt/libnbd.
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/virt/libnbd
echo 'da36e77aff952f818222a5a0e6c726b3d492405cb1934a9c81f8e4c0071bb26a libnbd-1.24.3.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/libnbd
SRC=$SRC_ROOT/libnbd-1.24.3
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf libnbd-1.24.3.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 recipe’s helpers _series and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
patch -p1 -i "$PORT_SRC/musl-unistd.patch"
./configure \
--prefix=/usr \
--sysconfdir=/etc \
--libdir=/usr/lib \
--enable-fuse \
--enable-python \
--with-gnutls \
--with-libxml2 \
--enable-ublk \
--disable-ocaml \
--disable-golang \
--disable-rust \
--with-bash-completions \
--disable-static
make
make DESTDIR=$PKG install
test -x "$PKG/usr/bin/nbdublk"
The switches, and why each is set:
--enable-fuse— Buildnbdfuse, against fuse3. It is upstream’s default.--enable-python— Build the Python binding, installed into python3’ssite-packages.nbdshis written on it, so it is the switch that gives the packagenbdsh.--with-gnutls— TLS through GnuTLS, fornbds://URIs and TLS-protected exports.--with-libxml2— URI parsing through libxml2, whichnbd://andnbds://URIs need.--enable-ublk— Buildnbdublk, against ubdsrv’slibublksrvand liburing. configure leavesnbdublkout with only a warning whenublksrvis missing, sobuild.shchecks thatnbdublkwas installed and fails if it was not.--disable-ocaml,--disable-golang,--disable-rust— The OCaml, Go and Rust bindings. No port here builds against them.--with-bash-completions— Install the bash completions, into the directory bash-completion’s pkg-config file names; with the switch given, configure fails if that module is missing instead of installing none.
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/libnbd, 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 libnbd-1.24.3-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/libnbd, and runs the triggers its paths call for.
Contents
Installed programs: nbdcopy, nbddiscard, nbddump, nbdfuse, nbdinfo, nbdsh, nbdublk, nbdzero.
Installed libraries: libnbd.so.
Installed directories: /usr/share/licenses/libnbd.
Short descriptions
nbdcopy |
copy to and from an NBD server |
nbddiscard |
discard or zero all data on a Network Block Device |
nbddump |
hexdump the content of a disk over NBD |
nbdfuse |
mount a network block device in the local filesystem |
nbdinfo |
display information and metadata about NBD servers and exports |
nbdsh |
network block device (NBD) shell |
nbdublk |
connect network block device to a local device |
libnbd.pc |
NBD client library in userspace |