summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2025-01-06 01:27:12 +0100
committerWaldemar Brodkorb <wbx@openadk.org>2025-01-06 11:53:44 +0100
commitbe735c88debdd1e3207af9c403e3c594798a3944 (patch)
tree0c99b2831a3e8b3add3070f8076177f2845b1279
parentfad1d3192c26fae8423907c9de6af2fe2b03dea6 (diff)
package: Port minidlna
This is a more capable alternative to gmediaserver. Signed-off-by: Phil Sutter <phil@nwl.cc>
-rw-r--r--package/minidlna/Makefile29
-rw-r--r--package/minidlna/files/minidlna.init36
-rw-r--r--package/minidlna/files/minidlna.postinst3
-rw-r--r--package/minidlna/patches/0001-log-Try-syslog-if-no-log-path-was-given.patch104
4 files changed, 172 insertions, 0 deletions
diff --git a/package/minidlna/Makefile b/package/minidlna/Makefile
new file mode 100644
index 000000000..2a51c978d
--- /dev/null
+++ b/package/minidlna/Makefile
@@ -0,0 +1,29 @@
+# This file is part of the OpenADK project. OpenADK is copyrighted
+# material, please see the LICENCE file in the top-level directory.
+
+include $(ADK_TOPDIR)/rules.mk
+
+PKG_NAME:= minidlna
+PKG_VERSION:= 1.3.3
+PKG_RELEASE:= 1
+PKG_HASH:= 39026c6d4a139b9180192d1c37225aa3376fdf4f1a74d7debbdbb693d996afa4
+PKG_DESCR:= DLNA/UPnP-AV compliant media server
+PKG_SECTION:= mm/video
+PKG_DEPENDS:= libffmpeg libjpeg-turbo libexif libid3tag libogg libflac libvorbis libsqlite libiconv
+PKG_BUILDDEP:= ffmpeg libjpeg-turbo libexif libid3tag libogg flac libvorbis sqlite libiconv
+PKG_URL:= http://sourceforge.net/projects/minidlna/
+PKG_SITES:= $(MASTER_SITE_SOURCEFORGE:=minidlna/)
+DISTFILES:= $(PKG_NAME)-$(PKG_VERSION).tar.gz
+
+include $(ADK_TOPDIR)/mk/package.mk
+
+$(eval $(call PKG_template,MINIDLNA,minidlna,$(PKG_VERSION)-$(PKG_RELEASE),$(PKG_DEPENDS),$(PKG_DESCR),$(PKG_SECTION)))
+
+minidlna-install:
+ $(INSTALL_DIR) $(IDIR_MINIDLNA)/usr/sbin
+ $(INSTALL_BIN) $(WRKINST)/usr/sbin/minidlnad \
+ $(IDIR_MINIDLNA)/usr/sbin
+ $(INSTALL_DIR) $(IDIR_MINIDLNA)/etc/
+ $(INSTALL_DATA) $(WRKSRC)/minidlna.conf $(IDIR_MINIDLNA)/etc/
+
+include $(ADK_TOPDIR)/mk/pkg-bottom.mk
diff --git a/package/minidlna/files/minidlna.init b/package/minidlna/files/minidlna.init
new file mode 100644
index 000000000..c4a1fe795
--- /dev/null
+++ b/package/minidlna/files/minidlna.init
@@ -0,0 +1,36 @@
+#!/bin/sh
+#PKG minidlna
+#INIT 60
+. /etc/rc.conf
+
+pidfile=$(echo "$minidlna_flags" | sed -n 's/.*-P \([^ ]\+\).*/\1/p')
+[ "$pidfile" ] || pidfile="/var/run/minidlna/minidlna.pid"
+
+case $1 in
+autostop) ;;
+autostart)
+ test x"${minidlna:-NO}" = x"NO" && exit 0
+ test x"$minidlna" = x"DAEMON" && test -x /bin/mksh && exec mksh -T- $0 start
+ exec sh $0 start
+ ;;
+start)
+ /usr/sbin/minidlnad $minidlna_flags
+ ;;
+stop)
+ if [ -f "$pidfile" ]; then
+ kill $(<$pidfile)
+ rm $pidfile
+ else
+ kill $(pgrep -f /usr/sbin/minidlnad)
+ fi
+ ;;
+restart)
+ sh $0 stop
+ sleep 1
+ sh $0 start
+ ;;
+*)
+ echo "usage: $0 (start | stop | restart)"
+ exit 1
+esac
+exit $?
diff --git a/package/minidlna/files/minidlna.postinst b/package/minidlna/files/minidlna.postinst
new file mode 100644
index 000000000..6c14ff1e8
--- /dev/null
+++ b/package/minidlna/files/minidlna.postinst
@@ -0,0 +1,3 @@
+#!/bin/sh
+. $IPKG_INSTROOT/etc/functions.sh
+add_rcconf minidlna NO
diff --git a/package/minidlna/patches/0001-log-Try-syslog-if-no-log-path-was-given.patch b/package/minidlna/patches/0001-log-Try-syslog-if-no-log-path-was-given.patch
new file mode 100644
index 000000000..c42c28097
--- /dev/null
+++ b/package/minidlna/patches/0001-log-Try-syslog-if-no-log-path-was-given.patch
@@ -0,0 +1,104 @@
+From 989841a0c4e83b0ac1b9d276be3797bcfa83bcb1 Mon Sep 17 00:00:00 2001
+From: Phil Sutter <phil@nwl.cc>
+Date: Sun, 27 Nov 2022 23:45:41 +0100
+Subject: [PATCH] log: Try syslog if no log path was given
+
+Signed-off-by: Phil Sutter <phil@nwl.cc>
+---
+ log.c | 44 ++++++++++++++++++++++++++++++++++++++++++--
+ minidlna.c | 2 --
+ 2 files changed, 42 insertions(+), 4 deletions(-)
+
+diff --git a/log.c b/log.c
+index a989904a24d93..840a8c02e678b 100644
+--- a/log.c
++++ b/log.c
+@@ -23,6 +23,7 @@
+ #include <stdio.h>
+ #include <stdarg.h>
+ #include <string.h>
++#include <syslog.h>
+ #include <time.h>
+
+ #include "upnpglobalvars.h"
+@@ -147,6 +148,40 @@ log_init(const char *debug)
+ return 0;
+ }
+
++static int
++syslog_err(int level, enum _log_facility facility,
++ char *fname, int lineno, char *fmt, va_list *ap)
++{
++ char myfmt[1024];
++ int level_to_syslog[E_MAXDEBUG + 1] = {
++ /* [E_OFF] = 0, */
++ [E_FATAL] = LOG_CRIT,
++ [E_ERROR] = LOG_ERR,
++ [E_WARN] = LOG_WARNING,
++ [E_INFO] = LOG_NOTICE,
++ [E_DEBUG] = LOG_INFO,
++ [E_MAXDEBUG] = LOG_DEBUG,
++ };
++
++ if (level == E_OFF)
++ return 0;
++
++ if (level > E_MAXDEBUG)
++ return -1;
++
++ if (level)
++ snprintf(myfmt, 1024, "%s:%d: %s: %s", fname, lineno, level_name[level], fmt);
++ else
++ snprintf(myfmt, 1024, "%s:%d: %s", fname, lineno, fmt);
++
++ vsyslog(level_to_syslog[level], myfmt, *ap);
++
++ if (level == E_FATAL)
++ exit(-1);
++
++ return 0;
++}
++
+ void
+ log_err(int level, enum _log_facility facility, char *fname, int lineno, char *fmt, ...)
+ {
+@@ -155,8 +190,14 @@ log_err(int level, enum _log_facility facility, char *fname, int lineno, char *f
+ if (level && level>log_level[facility] && level>E_FATAL)
+ return;
+
+- if (!log_fp)
++ va_start(ap, fmt);
++ if (!log_fp) {
++ if (!syslog_err(level, facility, fname, lineno, fmt, &ap)) {
++ va_end(ap);
++ return;
++ }
+ log_fp = stdout;
++ }
+
+ // timestamp
+ if (!GETFLAG(SYSTEMD_MASK))
+@@ -176,7 +217,6 @@ log_err(int level, enum _log_facility facility, char *fname, int lineno, char *f
+ fprintf(log_fp, "%s:%d: ", fname, lineno);
+
+ // user log
+- va_start(ap, fmt);
+ if (vfprintf(log_fp, fmt, ap) == -1)
+ {
+ va_end(ap);
+diff --git a/minidlna.c b/minidlna.c
+index 999adee977353..db29d603d1e28 100644
+--- a/minidlna.c
++++ b/minidlna.c
+@@ -817,8 +817,6 @@ init(int argc, char **argv)
+ optionsfile);
+ }
+ }
+- if (!log_path[0])
+- strncpyt(log_path, DEFAULT_LOG_PATH, sizeof(log_path));
+ if (!db_path[0])
+ strncpyt(db_path, DEFAULT_DB_PATH, sizeof(db_path));
+
+--
+2.38.1
+