189.1. minidlna-1.3.3
ReadyMedia — a DLNA media server for the televisions and players on a LAN
The build-state snapshot was taken from 1.3.3-1; this recipe is 1.3.3-2, so the size, time and contents below describe the earlier build.
| Version | 1.3.3, release 2 |
| Shelf | servers — Daemons that serve other machines: remote shell, web, mail, XMPP, IRC, CalDAV/CardDAV, SMB and DLNA |
| Phase | 42_graphics (Graphics Stack), 163 of 189 in build order |
| Licence | GPL-2.0-only AND BSD-3-Clause |
| Homepage | https://sourceforge.net/projects/minidlna/ |
| Build time | 1.0 SBU |
| Installed size | 385.3 KiB in 7 files |
| Recipe | ports/core/servers/minidlna/kpkgbuild |
About
MiniDLNA (ReadyMedia) is a DLNA/UPnP media server: it indexes the music, pictures and video in the directories its configuration names, and serves them to televisions, consoles and players on the local network. The port ships its own start script, /etc/init.d/84_minidlna.sh, which starts minidlnad under supervision as the unprivileged minidlna account and skips the service until /etc/minidlna.conf exists and is not empty; the upstream example is installed as /usr/share/doc/minidlna/minidlna.conf.example. Other machines reach it only once the dlna firewall name is opened; see Opening a service and firewall.
Sources
minidlna-1.3.3.tar.gz(805.2 KiB)
sha25639026c6d4a139b9180192d1c37225aa3376fdf4f1a74d7debbdbb693d996afa4
upstream: https://downloads.sourceforge.net/project/minidlna/minidlna/1.3.3/minidlna-1.3.3.tar.gz
archive copy: sources-4/servers--minidlna-1.3.3.tar.gz
Dependencies
Depends on: ffmpeg, libjpeg-turbo, libexif, libid3tag, flac, libogg, libvorbis, sqlite, zlib, gettext, autoconf, automake, libtool.
Required by: no port names it.
Patches
build.sh applies these; kpkg applies nothing by itself.
ffmpeg7.patch— Taken from Arch Linux (itsPatch-Source:line). Reads an audio stream’s channel count fromcodecpar->ch_layout.nb_channelsinstead ofcodecpar->channels, a field the FFmpeg API of this tree does not have; without itlibav.hdoes not compile.libav-fix.patch— Drops@LIBAVUTIL_LIBS@from the link line of thetestupnpdescgentest program inMakefile.am.configure.acnever substitutes that variable, so afterautoreconf -fithe reference would stay in the generated Makefile as literal text.
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/42_graphics/phase.env && kpkg install minidlna'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/servers/minidlna.
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/servers/minidlna
echo '39026c6d4a139b9180192d1c37225aa3376fdf4f1a74d7debbdbb693d996afa4 minidlna-1.3.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/minidlna
SRC=$SRC_ROOT/minidlna-1.3.3
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf minidlna-1.3.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 five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
patch -p1 -i "$PORT_SRC/ffmpeg7.patch"
patch -p1 -i "$PORT_SRC/libav-fix.patch"
autoreconf -fi
export CFLAGS="$CFLAGS -fcommon"
./configure --prefix=/usr --sysconfdir=/etc \
ac_cv_lib_avahi_client_avahi_threaded_poll_new=no \
--with-db-path=/var/lib/minidlna \
--with-log-path=/var/log/minidlna \
--with-os-name=KDOS --with-os-url=https://kdos.dev/ \
--disable-nls --disable-tivo --disable-netgear --disable-readynas
make
make DESTDIR=$PKG install
install -Dm644 minidlna.conf.5 "$PKG/usr/share/man/man5/minidlna.conf.5"
install -Dm644 minidlnad.8 "$PKG/usr/share/man/man8/minidlnad.8"
install -Dm644 minidlna.conf "$PKG/usr/share/doc/minidlna/minidlna.conf.example"
install -dm755 "$PKG/var/lib/minidlna" "$PKG/var/log/minidlna"
install -d "$PKG/etc/init.d"
cat > "$PKG/etc/init.d/84_minidlna.sh" <<'KDOS_SH'
#!/bin/bash
. /etc/init.d/service_helper
NAME="minidlna"
DAEMON="/usr/sbin/minidlnad"
CONF="/etc/minidlna.conf"
case "$1" in
start)
[ ! -x "$DAEMON" ] && { echo "[SKIP] $NAME: $DAEMON not found"; exit 0; }
if [ ! -s "$CONF" ]; then
echo "[SKIP] $NAME: no $CONF (/usr/share/doc/minidlna has the template)"
exit 0
fi
if ! getent passwd minidlna >/dev/null; then
echo "[SKIP] $NAME: no minidlna account (the port's postinstall makes it)"
exit 0
fi
echo "[KDOS] Starting $NAME..."
supervise "$NAME" "$DAEMON" -S -u minidlna -f "$CONF"
;;
stop) stop_service "$NAME" ;;
status) check_status "$NAME" ;;
*) echo "Usage: $0 {start|stop|status}"; exit 1 ;;
esac
KDOS_SH
chmod 755 "$PKG/etc/init.d/84_minidlna.sh"
The switches, and why each is set:
export CFLAGS="$CFLAGS -fcommon"— Place uninitialised global variables in a common block, so one defined withoutexternin more than one object file is merged at link time instead of failing the link with a multiple-definition error, which GCC’s default-fno-commongives.ac_cv_lib_avahi_client_avahi_threaded_poll_new=no— Answer configure’s Avahi probe with no, so the server is built without announcing itself over mDNS/DNS-SD even when avahi is in the build root. Avahi is not independs. DLNA clients find the server through its own SSDP announcements on UDP 1900.--with-db-path=/var/lib/minidlna— The default directory for the media database and the album-art cache. Upstream’s default is/var/cache/minidlna;/var/lib/minidlnais the directory the package creates andpostinstall.shgives to theminidlnaaccount.--with-log-path=/var/log/minidlna— The default log directory, also created by the package and owned by the account; upstream’s default is/var/log, which the account cannot write. The start script’s-Skeepsminidlnadin the foreground and sends its log to standard output for the supervisor, so the directory is written only when the daemon is started by hand without-S.--with-os-name=KDOS,--with-os-url=https://kdos.dev/— The model description (MiniDLNA on KDOS) and model URL the server publishes in its UPnP device description. Upstream takes the name fromuname -sand uses Netgear’s web site as the URL.--disable-tivo,--disable-netgear,--disable-readynas— TiVo support, and the Netgear and ReadyNAS device identities, which replace the device description’s manufacturer and model with Netgear’s. All three are off in upstream’s default; naming them keeps them off.
The common switches of each build system are explained in the Flag glossary.
postinstall.sh runs on the installed system after the package is adopted:
# Everything is written under PKG_ROOT, the root kpkgadd is installing into:
# --root and an A/B update install into a tree that is not the running one, and
# an account made in / instead would be missing from the system that needs it.
#
# The guard reads PKG_ROOT's files: getent answers for the running root, not
# the tree being installed, and would let useradd run against an account the
# target already has.
root="${PKG_ROOT:-/}"
grep -q '^minidlna:' "$root/etc/group" 2>/dev/null || groupadd -R "$root" -r minidlna
grep -q '^minidlna:' "$root/etc/passwd" 2>/dev/null || \
useradd -R "$root" -r -g minidlna -d /var/lib/minidlna -s /sbin/nologin minidlna
# chown resolves a name against the running root's passwd, so the ids are read
# out of PKG_ROOT's. The database and the log are written after the drop.
while IFS=: read -r n _ uid gid _; do
[ "$n" = minidlna ] || continue
chown "$uid:$gid" "$root/var/lib/minidlna" "$root/var/log/minidlna"
done < "$root/etc/passwd"
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/minidlna, 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 minidlna-1.3.3-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/minidlna, and runs the triggers its paths call for.
Contents
Installed programs: minidlnad.
Installed directories: /usr/share/doc/minidlna, /usr/share/licenses/minidlna, /var/lib/minidlna, /var/log/minidlna.
Short descriptions
minidlnad |
MiniDLNA DLNA/UPnP-AV Server |
Notes
autoreconf -fi runs after both patches because libav-fix.patch edits Makefile.am; without it the shipped Makefile.in would still carry the reference. That is why autoconf, automake and libtool are in depends.
postinstall.sh makes the minidlna group and account inside $PKG_ROOT, then gives /var/lib/minidlna and /var/log/minidlna to it by the numeric ids it reads from that root’s /etc/passwd, so an install into a root that is not the running system gives the directories to the right account. The start script runs minidlnad -S -u minidlna, so the daemon writes its database after dropping to that account; see postinstall.sh and System accounts.