135.7. libsndfile-1.2.2
Library for reading and writing files containing sampled sound (WAV, AIFF, FLAC, etc.)
| Version | 1.2.2, release 2 |
| Shelf | audio-codecs — Audio codecs, containers and tagging, including the Bluetooth audio codecs |
| Phase | 41_system (System), 24 of 1047 in build order |
| Licence | LGPL-2.1-or-later |
| Homepage | https://libsndfile.github.io/libsndfile/ |
| Build time | 0.9 SBU |
| Installed size | 1.2 MiB in 47 files |
| Recipe | ports/core/audio-codecs/libsndfile/kpkgbuild |
About
libsndfile reads and writes files of sampled sound through one API: WAV, AIFF, AU, CAF, W64 and the other PCM containers, and FLAC, Ogg Vorbis, Opus and MP3 through the codec libraries. Many programs on the host that open a sound file go through it, among them pipewire, libpulse, sox, speech-dispatcher, openal-soft, fluidsynth and the audio editors. It also installs the sndfile-* commands: sndfile-info, sndfile-convert, sndfile-play and the rest.
Sources
libsndfile-1.2.2.tar.xz(713.6 KiB)
sha2563799ca9924d3125038880367bf1468e53a1b7e3686a934f098b7e1d286cdb80e
upstream: https://github.com/libsndfile/libsndfile/releases/download/1.2.2/libsndfile-1.2.2.tar.xz
archive copy: sources-1/audio-codecs--libsndfile-1.2.2.tar.xz
Dependencies
Depends on: cmake, libogg, libvorbis, flac, opus, lame, mpg123, alsa-lib.
Required by (37): ardour, aubio, audacious-plugins, audacity, baresip, blender, dsda-doom, fldigi, fluidsynth, freedv-gui, furnace, gnuradio, gst-plugins-bad, hydrogen, k3b, ladspa, libbs2b, libgig, libkdegames, libopenmpt, libpulse, lilv, lmms, mpd, mumble, ngspice, octave, openal-soft, opencpn, pipewire, rubberband, sbc, sox, speech-dispatcher, tenacity, twolame, vamp-sdk.
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 libsndfile'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/audio-codecs/libsndfile.
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/audio-codecs/libsndfile
echo '3799ca9924d3125038880367bf1468e53a1b7e3686a934f098b7e1d286cdb80e libsndfile-1.2.2.tar.xz' | 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/libsndfile
SRC=$SRC_ROOT/libsndfile-1.2.2
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf libsndfile-1.2.2.tar.xz -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:
mkdir -p build
cd build
cmake .. \
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_INSTALL_LIBDIR=lib \
-DBUILD_SHARED_LIBS=ON \
-DBUILD_PROGRAMS=ON \
-DBUILD_EXAMPLES=OFF \
-DBUILD_TESTING=OFF \
-DENABLE_EXTERNAL_LIBS=ON \
-DENABLE_MPEG=ON \
-DCMAKE_REQUIRE_FIND_PACKAGE_Ogg=ON \
-DCMAKE_REQUIRE_FIND_PACKAGE_Vorbis=ON \
-DCMAKE_REQUIRE_FIND_PACKAGE_FLAC=ON \
-DCMAKE_REQUIRE_FIND_PACKAGE_Opus=ON \
-DCMAKE_REQUIRE_FIND_PACKAGE_mp3lame=ON \
-DCMAKE_REQUIRE_FIND_PACKAGE_mpg123=ON \
-DCMAKE_REQUIRE_FIND_PACKAGE_ALSA=ON
make
make DESTDIR=$PKG install
The switches, and why each is set:
-DCMAKE_POLICY_VERSION_MINIMUM=3.5— theCMakeLists.txtdeclarescmake_minimum_required (VERSION 3.1..3.18). Two dots are not CMake’s...range, so the floor it reads is 3.1, which the tree’s CMake 4 refuses (see An old CMake policy floor).-DENABLE_EXTERNAL_LIBS=ON— FLAC, Ogg, Vorbis and Opus. Off, libsndfile compiles all four out, whatever is installed, and keeps only the formats and codecs built into it. It is upstream’s default, named.-DENABLE_MPEG=ON— MP3, read through mpg123 and written through lame. It is turned on only when both are found; either one missing turns MP3 off in both directions. Upstream’s default, named.-DCMAKE_REQUIRE_FIND_PACKAGE_Ogg=ON— and the same switch forVorbis,FLAC,Opus,mp3lame,mpg123andALSA: turn eachfind_packageinto a required one. libsndfile answers a missing codec library by building without it, so without these a library missing at build time gives a libsndfile narrower than itsdependssay, and nothing reports it.ALSAis whatsndfile-playplays through; without it the program is built to write to OSS’s/dev/dsp, which exists only while the kernel’s OSS emulation is loaded and bypasses the sound server.-DBUILD_PROGRAMS=ON— build and install thesndfile-*commands and their manual pages, upstream’s default, named.-DBUILD_EXAMPLES=OFF— skip the example programs, which upstream builds by default.
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/libsndfile, 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 libsndfile-1.2.2-2.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/libsndfile, and runs the triggers its paths call for.
Contents
Installed programs: sndfile-cmp, sndfile-concat, sndfile-convert, sndfile-deinterleave, sndfile-info, sndfile-interleave, sndfile-metadata-get, sndfile-metadata-set, sndfile-play, sndfile-salvage.
Installed libraries: libsndfile.so.
Installed directories: /usr/lib/cmake/SndFile, /usr/share/doc/libsndfile, /usr/share/licenses/libsndfile.
Short descriptions
sndfile-cmp |
compare two audio files |
sndfile-concat |
concatenate audio data from two or more audio files |
sndfile-convert |
convert sound files from one format to another |
sndfile-deinterleave |
convert mono files into a multi-channel file and vice versa |
sndfile-info |
display information about sound files |
sndfile-interleave |
convert mono files into a multi-channel file and vice versa |
sndfile-metadata-get |
get or set metadata in a sound file |
sndfile-metadata-set |
get or set metadata in a sound file |
sndfile-play |
play a sound file |
sndfile-salvage |
salvage audio data from WAV files longer than 4G |
sndfile.pc |
A library for reading and writing audio files |