98.22. ubdsrv-1.8
ublk userspace block devices — libublksrv, and the ublk tool with its loop, null, NBD and NFS targets
| Version | 1.8, release 1 |
| Shelf | disk — Block devices: partitioning, RAID, LVM, block encryption, SMART, NVMe, recovery, image writing and async I/O |
| Phase | 41_system (System), 406 of 1047 in build order |
| Licence | (MIT OR GPL-2.0-only) AND (MIT OR LGPL-2.1-only) |
| Homepage | https://github.com/ublk-org/ublksrv |
| Build time | 1.3 SBU |
| Installed size | 900.9 KiB in 22 files |
| Recipe | ports/core/disk/ubdsrv/kpkgbuild |
About
ublksrv is the user-space server for ublk, the kernel’s interface for block devices implemented by a user-space program: the kernel creates /dev/ublkbN and hands each I/O request to the server through io_uring, and the server answers it from a file, a network service or memory. The port installs libublksrv, for writing such servers, and the ublk tool with its targets: ublk add -t loop backs a device with a file, -t nbd with an NBD server, -t nfs with a file on an NFS share, -t sheepdog with a Sheepdog volume, -t nvme_vfio with an NVMe drive driven from user space through VFIO (built because the kernel headers carry linux/vfio.h), and -t null with nothing, for testing. It needs the kernel’s ublk_drv module, which the linux port builds (CONFIG_BLK_DEV_UBLK=m). The upstream repository is ublk-org/ublksrv; the port and its package are named ubdsrv.
Sources
ubdsrv-1.8.tar.gz(606.9 KiB)
sha256881eb23b154ac0946609c82d4220df0598907c0f1061b00985b6956d50129e6d
upstream: https://github.com/ublk-org/ublksrv/archive/refs/tags/v1.8.tar.gz
archive copy: sources-1/disk--ubdsrv-1.8.tar.gz
Dependencies
Depends on: autoconf, automake, libtool, pkgconf, liburing, libnfs.
Required by (1): libnbd.
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.
--without-gnutls, line 16: gnutls (explained with the switches below)--without-libiscsi, line 18: libiscsi (explained with the switches below)
Patches
build.sh applies these; kpkg applies nothing by itself.
musl-prctl.patch— Removes#include <linux/prctl.h>fromlib/ublksrv.c, which already includes<sys/prctl.h>. musl’s<sys/prctl.h>defines the samePR_*constants andstruct prctl_mm_mapitself, so including both is a redefinition error.
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 ubdsrv'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/disk/ubdsrv.
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/disk/ubdsrv
echo '881eb23b154ac0946609c82d4220df0598907c0f1061b00985b6956d50129e6d ubdsrv-1.8.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/ubdsrv
SRC=$SRC_ROOT/ubdsrv-1.8
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf ubdsrv-1.8.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:
patch -p1 -i "$PORT_SRC/musl-prctl.patch"
autoreconf -fi
export CXXFLAGS="$CXXFLAGS -fpermissive"
./configure --prefix=/usr --libdir=/usr/lib --sbindir=/usr/sbin --disable-static \
--without-gnutls \
--with-libnfs \
--without-libiscsi
make noinst_PROGRAMS=
make noinst_PROGRAMS= DESTDIR=$PKG install
The switches, and why each is set:
autoreconf -fi— The GitHub tag archive carriesconfigure.acandMakefile.ambut no generatedconfigure, so the build system is generated first; this is why autoconf, automake and libtool are independs.-fpermissive— Added toCXXFLAGSfor the C++ targets. It makes g++ report some kinds of nonconforming code as warnings instead of errors.--sbindir=/usr/sbin— Whereublkand its per-target programs (ublk.loop,ublk.nbd,ublk.nfsand the rest) are installed; it is the default for this prefix, stated.--with-libnfs— Builds the NFS target,ublk.nfs, against libnfs. configure builds it only when libnfs offers its version 2 interface with multithreading (nfs_mt_service_thread_start). When that test fails it drops the target silently, with this switch as much as with the default,check, so the switch does not make a missing libnfs an error.--without-gnutls— Builds the NBD target without TLS, soublk.nbdcannot connect to an NBD server that requires it. By default configure links GnuTLS when pkg-config finds it.--without-libiscsi— Does not build the iSCSI target,ublk.iscsi. By default configure builds it when pkg-config finds libiscsi.noinst_PROGRAMS=— Empties the list of the two demonstration programs,demo_nullanddemo_event, which are built and never installed, so neithermakebuilds them.
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/ubdsrv, 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 ubdsrv-1.8-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/ubdsrv, and runs the triggers its paths call for.
Contents
Installed programs: ublk, ublk.loop, ublk.nbd, ublk.nfs, ublk.null, ublk.nvme_vfio, ublk.sheepdog, ublk_chown.sh, ublk_chown_docker.sh, ublk_user_id.
Installed libraries: libublksrv.so.
Installed directories: /usr/share/licenses/ubdsrv.
Short descriptions
ublk |
Utility to manage ublk devices |
ublksrv.pc |
ublk server library and headers |