162.14. libmirisdr-2.0.0
Driver library and the miri_sdr and miri_fm tools for Mirics MSi2500/MSi001 receivers (libmirisdr-4)
| Version | 2.0.0, release 1 |
| Shelf | sdr-hw — SDR hardware drivers and the SoapySDR device layer |
| Phase | 41_system (System), 909 of 1047 in build order |
| Licence | GPL-2.0-or-later |
| Homepage | https://github.com/f4exb/libmirisdr-4 |
| Build time | 0.1 SBU |
| Installed size | 151.6 KiB in 9 files |
| Recipe | ports/core/sdr-hw/libmirisdr/kpkgbuild |
About
libmirisdr is a user-space driver library for receivers built on the Mirics MSi2500 USB bridge and MSi001 tuner, the chips of the early SDRplay receivers among others. It talks to the device over libusb, and installs libmirisdr.so, its headers mirisdr.h and mirisdr_export.h, its pkg-config file, and the miri_sdr and miri_fm tools. gr-osmosdr and sdrangel use it. The source is libmirisdr-4, a further development of Miroslav Slugen’s libmirisdr-2 and its libmirisdr-3-bsz fork.
Sources
libmirisdr-2.0.0.tar.gz(73.4 KiB)
sha256c9fa00737f37de788873248c71dd653b0e9c043aed70620ea17cfde8894be2df
upstream: https://github.com/f4exb/libmirisdr-4/archive/refs/tags/v2.0.0.tar.gz
archive copy: sources-4/sdr-hw--libmirisdr-2.0.0.tar.gz
Dependencies
Depends on: cmake, pkgconf, libusb.
Required by (2): gr-osmosdr, sdrangel.
Patches
build.sh applies these; kpkg applies nothing by itself.
pc-version.patch— Afterinclude(Version)inCMakeLists.txt, setsVERSIONfromMIRISDR_PC_VERSIONwhen that is given. Upstream marks its patch level asgit, and itsVersion.cmakethen takesVERSIONfromgit describe. A release tarball is not a git checkout, so that is either empty or, with no git at all, the placeholderv4.0.x-xxx-xunknown, and either one ends up on theVersion:line oflibmirisdr.pc.
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 libmirisdr'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/sdr-hw/libmirisdr.
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/sdr-hw/libmirisdr
echo 'c9fa00737f37de788873248c71dd653b0e9c043aed70620ea17cfde8894be2df libmirisdr-2.0.0.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/libmirisdr
SRC=$SRC_ROOT/libmirisdr-2.0.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf libmirisdr-2.0.0.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/pc-version.patch"
mkdir -p build && cd build
cmake .. -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
-DLIB_SUFFIX= \
-DCMAKE_SKIP_INSTALL_RPATH=ON \
-DDETACH_KERNEL_DRIVER=ON \
-DMIRISDR_PC_VERSION=$version
make
make DESTDIR=$PKG install
rm "$PKG/usr/lib/libmirisdr.a"
test -f "$PKG/usr/lib/libmirisdr.so"
test -f "$PKG/usr/include/mirisdr.h"
test -x "$PKG/usr/bin/miri_sdr"
grep -q '^Version: .' "$PKG/usr/lib/pkgconfig/libmirisdr.pc"
The switches, and why each is set:
-DLIB_SUFFIX=— Install the library intolibwith nothing appended. The project’sCMakeLists.txtwriteslib${LIB_SUFFIX}for both the install path and the pkg-configlibdir, and does not useGNUInstallDirs, soCMAKE_INSTALL_LIBDIRhas no effect on it. Left unset, the variable expands to nothing as well, so the flag pins upstream’s default layout, the one thetestlines check.-DCMAKE_SKIP_INSTALL_RPATH=ON— Install the library and tools with noRPATH. The project sets its installRPATHto${CMAKE_INSTALL_PREFIX}/lib, which is/usr/lib, a directory the loader searches anyway.-DDETACH_KERNEL_DRIVER=ON— When a kernel driver has claimed the device’s USB interface (Linux has one for this hardware,msi2500, which presents it as a V4L2 device), detach it when the device is opened and reattach it when it is closed. Off upstream, where opening the device would fail while that driver holds it.-DMIRISDR_PC_VERSION=$version— The version written intolibmirisdr.pc. The option exists only with this port’s patch,pc-version.patch.
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/libmirisdr, 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 libmirisdr-2.0.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/libmirisdr, and runs the triggers its paths call for.
Contents
Installed programs: miri_fm, miri_sdr.
Installed libraries: libmirisdr.so.
Installed directories: /usr/share/licenses/libmirisdr.
Short descriptions
libmirisdr.pc |
C Utility Library |
Notes
The project always builds a static library beside the shared one; build.sh removes libmirisdr.a after the install.
The three test lines and the grep at the end fail the build unless the shared library, the header, the miri_sdr program and a non-empty Version: line in the pkg-config file are all in the package. The grep is the one that proves the patch took effect.
Access to the device for a user comes from the tree’s udev rules, which give the SDRplay vendor id 1df7 and the 04bb:0537 stick to the dialout group (see The device groups and the udev rules). Upstream’s mirisdr.rules is not installed.