minidlna: update to latest master
authorRosen Penev <redacted>
Mon, 13 Jan 2020 03:05:26 +0000 (19:05 -0800)
committerRosen Penev <redacted>
Mon, 24 Feb 2020 02:03:14 +0000 (18:03 -0800)
Removed inactive maintainer.

Cleaned up Makefile to remove old options.

Switched to PKG_INSTALL for consistency.

Added PKG_BUILD_PARALLEL for faster compilation.

Fixed license info.

Removed '' from enabled for consistency.

Ran init script through shellcheck. Batched config file writes.

Switched it to use procd. The -S parameter changes it to foreground. It
stands for systemd.

Added a sysctl tweak to get rid of warning.

Signed-off-by: Rosen Penev <redacted>
multimedia/minidlna/Makefile
multimedia/minidlna/files/minidlna.config
multimedia/minidlna/files/minidlna.init
multimedia/minidlna/files/minidlna.sysctl [new file with mode: 0644]
multimedia/minidlna/patches/010-lg.patch [new file with mode: 0644]
multimedia/minidlna/patches/020-wrap_container_definitions_into_a_structure.patch [moved from multimedia/minidlna/patches/003-wrap_container_definitions_into_a_structure.patch with 90% similarity]
multimedia/minidlna/patches/030-mark_all_instances_of_magic_container_s_as_const.patch [moved from multimedia/minidlna/patches/002-mark_all_instances_of_magic_container_s_as_const.patch with 90% similarity]
multimedia/minidlna/patches/040-heroes.patch [new file with mode: 0644]
multimedia/minidlna/patches/050-no-cover-resizing.patch [new file with mode: 0644]
multimedia/minidlna/patches/060-reduce_duplication_in_sql_c.patch [moved from multimedia/minidlna/patches/004-reduce_duplication_in_sql_c.patch with 100% similarity]
multimedia/minidlna/patches/070-return-void.patch [new file with mode: 0644]

index d6bc34fe64f96829af5db1b5351e61a920be8265..bf52e91846a44654e05dd7c5f07300497fd31cb3 100644 (file)
@@ -12,18 +12,17 @@ PKG_RELEASE:=3
 
 PKG_SOURCE_PROTO:=git
 PKG_SOURCE_URL:=https://git.code.sf.net/p/minidlna/git
-PKG_SOURCE_DATE:=2018-04-10
-PKG_SOURCE_VERSION:=799e6cf505ec470b2bf0ae4118143380aa16b837
-PKG_MIRROR_HASH:=67cc817e671de99e5a3f5ed237f89e22470f1de94819bcaba86c0ba821104af5
+PKG_SOURCE_DATE:=2019-12-09
+PKG_SOURCE_VERSION:=0763719f2776f91114bc5564919896f28e078c77
+PKG_MIRROR_HASH:=93030a80eff44c0ec13f54daf3b2ba345b70ef8645e0343a34092f37d6f9e8dd
 
-PKG_LICENSE:=GPL-2.0 BSD-3-Clause
+PKG_MAINTAINER:=
+PKG_LICENSE:=GPL-2.0-or-later BSD-3-Clause
 PKG_LICENSE_FILES:=COPYING LICENCE.miniupnpd
 
-PKG_MAINTAINER:=Knyazkov Dmitry <medavedik@gmail.com>
-
 PKG_FIXUP:=autoreconf
-
-PKG_BUILD_PARALLEL:=0
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
 PKG_BUILD_DEPENDS:=util-linux
 
 include $(INCLUDE_DIR)/package.mk
@@ -49,37 +48,24 @@ define Package/minidlna/conffiles
 /etc/config/minidlna
 endef
 
-TARGET_CPPFLAGS += \
-       -I$(ICONV_PREFIX)/include \
-       -I$(INTL_PREFIX)/include \
-       -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 \
-
-TARGET_LDFLAGS += \
-       -L$(ICONV_PREFIX)/lib \
-       -L$(INTL_PREFIX)/lib \
-       -Wl,-rpath-link=$(STAGING_DIR)/usr/lib \
-
-MAKE_FLAGS +=\
-       CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)" \
-       LDFLAGS="$(TARGET_LDFLAGS)" \
-       ICONV_LIBS="-liconv $(if $(INTL_FULL),-lintl)" \
-
 CONFIGURE_ARGS +=\
        --with-libiconv-prefix="$(ICONV_PREFIX)" \
        --with-libintl-prefix="$(INTL_PREFIX)" \
        --with-os-name="OpenWrt Linux" \
        --with-os-version="$(LINUX_VERSION)" \
-       --with-os-url="http://openwrt.org/" \
+       --with-os-url="https://openwrt.org/" \
        --with-db-path="/var/run/minidlna" \
-       --with-log-path="/var/log" \
+       --with-log-path="/var/log"
 
 define Package/minidlna/install
-       $(INSTALL_DIR) $(1)/usr/bin
-       $(INSTALL_BIN) $(PKG_BUILD_DIR)/minidlnad $(1)/usr/bin/minidlna
+       $(INSTALL_DIR) $(1)/usr/sbin
+       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/minidlnad $(1)/usr/sbin/minidlnad
        $(INSTALL_DIR) $(1)/etc/init.d
        $(INSTALL_BIN) ./files/minidlna.init $(1)/etc/init.d/minidlna
        $(INSTALL_DIR) $(1)/etc/config
        $(INSTALL_CONF) ./files/minidlna.config $(1)/etc/config/minidlna
+       $(INSTALL_DIR) $(1)/etc/sysctl.d
+       $(INSTALL_CONF) ./files/minidlna.sysctl $(1)/etc/sysctl.d/30-minidlna.conf
 endef
 
 $(eval $(call BuildPackage,minidlna))
index cdde73ff391d05be35ab1d70e3076440dfc8c178..4ffeadb07952ab28c7a2c46fb44f5b2939e7b29a 100644 (file)
@@ -1,11 +1,10 @@
 config minidlna config
-       option 'enabled' '0'
+       option enabled '0'
        option user 'minidlna'
        option port '8200'
        option interface 'br-lan'
        option friendly_name 'OpenWrt DLNA Server'
        option db_dir '/var/run/minidlna'
-       option log_dir '/var/log/minidlna'
        option inotify '1'
        option enable_tivo '0'
        option wide_links '0'
index 909b098713040b98d13a80c3f88e224c3e14103b..6dcc104ea88194e69daf725d98c4362a0beb7e18 100644 (file)
@@ -1,17 +1,13 @@
 #!/bin/sh /etc/rc.common
 # Copyright (C) 2010 OpenWrt.org
 
-START=50
+START=81
 
-SERVICE_USE_PID=1
-SERVICE_PID_FILE=/var/run/minidlna/minidlna.pid
+PROG=/usr/sbin/minidlnad
+USE_PROCD=1
 
 MINIDLNA_CONFIG_FILE="/var/etc/minidlna.conf"
 
-minidlna_cfg_append() {
-       echo "$1" >> "$MINIDLNA_CONFIG_FILE"
-}
-
 minidlna_cfg_addbool() {
        local cfg="$1"
        local key="$2"
@@ -20,7 +16,7 @@ minidlna_cfg_addbool() {
 
        config_get_bool val "$cfg" "$key" "$def"
        [ "$val" -gt 0 ] && val="yes" || val="no"
-       minidlna_cfg_append "$key=$val"
+       echo "$key=$val"
 }
 
 minidlna_cfg_addstr() {
@@ -30,12 +26,12 @@ minidlna_cfg_addstr() {
        local val
 
        config_get val "$cfg" "$key" "$def"
-       [ -n "$val" ] && minidlna_cfg_append "$key=$val"
+       [ -n "$val" ] && echo "$key=$val"
 }
 
 minidlna_cfg_add_media_dir() {
        local val=$1
-       minidlna_cfg_append "media_dir=$val"
+       echo "media_dir=$val"
 }
 
 minidlna_create_config() {
@@ -46,18 +42,18 @@ minidlna_create_config() {
        config_get port "$cfg" port
        config_get interface "$cfg" interface
 
-       [ -z "$interface" -o -t "$port" ] && return 1
+       { [ -z "$interface" ] || [ -t "$port" ]; } && return 1
 
        mkdir -p /var/etc
-       echo "# this file is generated automatically, don't edit" > "$MINIDLNA_CONFIG_FILE"
+       {
+       echo "# this file is generated automatically, don't edit"
 
-       minidlna_cfg_append "port=$port"
-       minidlna_cfg_append "network_interface=$interface"
+       echo "port=$port"
+       echo "network_interface=$interface"
 
        minidlna_cfg_addstr "$cfg" friendly_name
        minidlna_cfg_addstr "$cfg" user
        minidlna_cfg_addstr "$cfg" db_dir
-       minidlna_cfg_addstr "$cfg" log_dir
        minidlna_cfg_addstr "$cfg" log_level 'error'
        minidlna_cfg_addbool "$cfg" inotify '1'
        minidlna_cfg_addbool "$cfg" enable_tivo '0'
@@ -72,16 +68,16 @@ minidlna_create_config() {
        minidlna_cfg_addstr "$cfg" root_container '.'
        minidlna_cfg_addstr "$cfg" uuid '019f9a56-ff60-44c0-9edc-eae88d09fa05'
        config_list_foreach "$cfg" "media_dir" minidlna_cfg_add_media_dir
+       } > "$MINIDLNA_CONFIG_FILE"
 
        return 0
 }
 
-start() {
+start_service() {
        local enabled
        local db_dir
-       local log_dir
        local user
-       local var
+       local val
 
        config_load 'minidlna'
        config_get_bool enabled config 'enabled' '0'
@@ -89,20 +85,31 @@ start() {
        [ "$enabled" -gt 0 ] || return 1
 
        config_get val "config" uuid
-       [ "$val" = '' ] && uci set  minidlna.config.uuid=$(cat /proc/sys/kernel/random/uuid) && uci commit
+       [ "$val" = '' ] && uci set minidlna.config.uuid="$(cat /proc/sys/kernel/random/uuid)" && uci commit
 
        minidlna_create_config config || return 1
 
        config_get db_dir config 'db_dir' '/var/run/minidlna'
-       config_get log_dir config 'log_dir' '/var/log/minidlna'
-       config_get user config 'user' 'root'
-
-       mkdir -m 0755 -p "$db_dir" "$log_dir"
-       chown -R "$user" "$db_dir" "$log_dir"
+       config_get user config 'user' 'minidlna'
+
+       [ -d "$db_dir" ] || {
+               mkdir -m 755 -p "$db_dir"
+               chown -R "$user":"$user" "$db_dir"
+       }
+
+       procd_open_instance
+       procd_set_param command "$PROG"
+       procd_append_param command -S -f "$MINIDLNA_CONFIG_FILE"
+       procd_set_param stdout 1
+       procd_set_param stderr 1
+       procd_set_param respawn
+       procd_close_instance
+}
 
-       service_start /usr/bin/minidlna -f "$MINIDLNA_CONFIG_FILE"
+reload_service() {
+       procd_send_signal "$PROG"
 }
 
-stop() {
-       service_stop /usr/bin/minidlna
+service_triggers() {
+       procd_add_reload_trigger "minidlna"
 }
diff --git a/multimedia/minidlna/files/minidlna.sysctl b/multimedia/minidlna/files/minidlna.sysctl
new file mode 100644 (file)
index 0000000..aaf460e
--- /dev/null
@@ -0,0 +1,2 @@
+# this is the desired value for minidlna
+fs.inotify.max_user_watches=65536
diff --git a/multimedia/minidlna/patches/010-lg.patch b/multimedia/minidlna/patches/010-lg.patch
new file mode 100644 (file)
index 0000000..1fb48b1
--- /dev/null
@@ -0,0 +1,24 @@
+From eb473817d73b8740f27955f93950029fdfc9d73e Mon Sep 17 00:00:00 2001
+From: Daniel Kamil Kozar <dkk089@gmail.com>
+Date: Sat, 15 Dec 2018 00:55:20 +0100
+Subject: [PATCH] LG webOS 3.5 devices require audio/flac in order to detect
+ FLAC
+
+Imported from https://sourceforge.net/p/minidlna/patches/176/
+---
+ clients.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/clients.c b/clients.c
+index 42f0d1c..d324eab 100644
+--- a/clients.c
++++ b/clients.c
+@@ -164,7 +164,7 @@ struct client_type_s client_types[] =
+       /* USER-AGENT: Linux/2.6.35 UPnP/1.0 DLNADOC/1.50 INTEL_NMPR/2.0 LGE_DLNA_SDK/1.6.0 */
+       { ELGNetCastDevice,
+-        FLAG_DLNA | FLAG_CAPTION_RES,
++        FLAG_DLNA | FLAG_CAPTION_RES | FLAG_MIME_FLAC_FLAC,
+         "LG",
+         "LGE_DLNA_SDK/1.6.0",
+         EUserAgent
similarity index 90%
rename from multimedia/minidlna/patches/003-wrap_container_definitions_into_a_structure.patch
rename to multimedia/minidlna/patches/020-wrap_container_definitions_into_a_structure.patch
index a4fb39bfbbc8de560a811cfb3eaab7e092a2437f..4733b32fe242b0de79ea587267bb27f270eb142a 100644 (file)
@@ -9,6 +9,8 @@ Subject: [PATCH] Wrap container definitions into a structure
  scanner.c    | 33 ++++++---------------------------
  3 files changed, 39 insertions(+), 27 deletions(-)
 
+diff --git a/containers.c b/containers.c
+index f5cece1..19a0bb1 100644
 --- a/containers.c
 +++ b/containers.c
 @@ -23,6 +23,31 @@
@@ -42,7 +44,9 @@ Subject: [PATCH] Wrap container definitions into a structure
 +
  #define NINETY_DAYS "7776000"
  
- static const char *music_id = MUSIC_ID;
+ const char *music_id = MUSIC_ID;
+diff --git a/containers.h b/containers.h
+index aef77c5..1fcf7cd 100644
 --- a/containers.h
 +++ b/containers.h
 @@ -16,6 +16,14 @@
@@ -60,9 +64,11 @@ Subject: [PATCH] Wrap container definitions into a structure
  struct magic_container_s {
        const char *name;
        const char *objectid_match;
+diff --git a/scanner.c b/scanner.c
+index a730567..eb26c9e 100644
 --- a/scanner.c
 +++ b/scanner.c
-@@ -529,30 +529,7 @@ insert_file(const char *name, const char
+@@ -529,30 +529,7 @@ insert_file(const char *name, const char *path, const char *parentID, int object
  int
  CreateDatabase(void)
  {
@@ -114,5 +120,5 @@ Subject: [PATCH] Wrap container definitions into a structure
 -      for( i=0; magic_containers[i].objectid_match; i++ )
 +      for( int i=0; magic_containers[i].objectid_match; i++ )
        {
-               const struct magic_container_s *magic = &magic_containers[i];
+               struct magic_container_s *magic = &magic_containers[i];
                if (!magic->name)
similarity index 90%
rename from multimedia/minidlna/patches/002-mark_all_instances_of_magic_container_s_as_const.patch
rename to multimedia/minidlna/patches/030-mark_all_instances_of_magic_container_s_as_const.patch
index cb1f2febc853fc5c0b5601c0a12b304dbdc66a92..44a27665bd2a9ea50ed290653bb928ccae14dfb8 100644 (file)
@@ -12,7 +12,7 @@ Subject: [PATCH] Mark all instances of magic_container_s as const
 
 --- a/containers.c
 +++ b/containers.c
-@@ -25,23 +25,23 @@
+@@ -50,23 +50,23 @@
  
  #define NINETY_DAYS "7776000"
  
@@ -52,7 +52,7 @@ Subject: [PATCH] Mark all instances of magic_container_s as const
  {
        /* Alternate root container */
        { NULL,
-@@ -124,7 +124,7 @@ struct magic_container_s magic_container
+@@ -149,7 +149,7 @@ struct magic_container_s magic_container
        { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0 }
  };
  
@@ -61,7 +61,7 @@ Subject: [PATCH] Mark all instances of magic_container_s as const
  in_magic_container(const char *id, int flags, const char **real_id)
  {
        size_t len;
-@@ -154,7 +154,7 @@ in_magic_container(const char *id, int f
+@@ -179,7 +179,7 @@ in_magic_container(const char *id, int f
        return NULL;
  }
  
@@ -72,7 +72,7 @@ Subject: [PATCH] Mark all instances of magic_container_s as const
        int i;
 --- a/containers.h
 +++ b/containers.h
-@@ -30,7 +30,7 @@ struct magic_container_s {
+@@ -38,7 +38,7 @@ struct magic_container_s {
        int required_flags;
  };
  
@@ -85,9 +85,9 @@ Subject: [PATCH] Mark all instances of magic_container_s as const
 +const struct magic_container_s *check_magic_container(const char *id, int flags);
 --- a/scanner.c
 +++ b/scanner.c
-@@ -587,7 +587,7 @@ CreateDatabase(void)
+@@ -566,7 +566,7 @@ CreateDatabase(void)
        }
-       for( i=0; magic_containers[i].objectid_match; i++ )
+       for( int i=0; magic_containers[i].objectid_match; i++ )
        {
 -              struct magic_container_s *magic = &magic_containers[i];
 +              const struct magic_container_s *magic = &magic_containers[i];
@@ -105,7 +105,7 @@ Subject: [PATCH] Mark all instances of magic_container_s as const
  {
        int ret;
  
-@@ -1292,7 +1292,7 @@ BrowseContentDirectory(struct upnphttp *
+@@ -1297,7 +1297,7 @@ BrowseContentDirectory(struct upnphttp *
                        "<Result>"
                        "&lt;DIDL-Lite"
                        CONTENT_DIRECTORY_SCHEMAS;
@@ -114,7 +114,7 @@ Subject: [PATCH] Mark all instances of magic_container_s as const
        char *zErrMsg = NULL;
        char *sql, *ptr;
        struct Response args;
-@@ -1807,7 +1807,7 @@ SearchContentDirectory(struct upnphttp *
+@@ -1819,7 +1819,7 @@ SearchContentDirectory(struct upnphttp *
                        "<Result>"
                        "&lt;DIDL-Lite"
                        CONTENT_DIRECTORY_SCHEMAS;
diff --git a/multimedia/minidlna/patches/040-heroes.patch b/multimedia/minidlna/patches/040-heroes.patch
new file mode 100644 (file)
index 0000000..5c2d313
--- /dev/null
@@ -0,0 +1,27 @@
+From 972fb2bbfdb7118551da45c5828c9e74be581fc4 Mon Sep 17 00:00:00 2001
+From: Daniel Kamil Kozar <dkk089@gmail.com>
+Date: Sat, 15 Dec 2018 21:55:52 +0100
+Subject: [PATCH] What about David Bowie's "Heroes"?
+
+---
+ utils.c | 7 -------
+ 1 file changed, 7 deletions(-)
+
+diff --git a/utils.c b/utils.c
+index dc936f9..dfa2b65 100644
+--- a/utils.c
++++ b/utils.c
+@@ -87,13 +87,6 @@ trim(char *str)
+               len--;
+       }
+-      if (str[0] == '"' && str[len-1] == '"')
+-      {
+-              str[0] = '\0';
+-              str[len-1] = '\0';
+-              str++;
+-      }
+-
+       return str;
+ }
diff --git a/multimedia/minidlna/patches/050-no-cover-resizing.patch b/multimedia/minidlna/patches/050-no-cover-resizing.patch
new file mode 100644 (file)
index 0000000..e05bb9c
--- /dev/null
@@ -0,0 +1,80 @@
+From aae49f0f80e73d1b52f23b89b0d314e9b9f89425 Mon Sep 17 00:00:00 2001
+From: Daniel Kamil Kozar <dkk089@gmail.com>
+Date: Sat, 15 Dec 2018 22:55:44 +0100
+Subject: [PATCH] Add an option to disable cover art resizing
+
+Imported from
+https://sourceforge.net/p/minidlna/patches/_discuss/thread/9825a1a0/4c28/attachment/minidlna-1.1.2-no-cover-resize.patch
+---
+ albumart.c       | 3 +++
+ minidlna.c       | 4 ++++
+ options.c        | 1 +
+ options.h        | 1 +
+ upnpglobalvars.h | 1 +
+ 5 files changed, 10 insertions(+)
+
+diff --git a/albumart.c b/albumart.c
+index de026ec..04fa8f2 100644
+--- a/albumart.c
++++ b/albumart.c
+@@ -67,6 +67,9 @@ save_resized_album_art(image_s *imsrc, const char *path)
+       strncpyt(cache_dir, cache_file, sizeof(cache_dir));
+       make_dir(dirname(cache_dir), S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH);
++      if( GETFLAG(NO_COVER_RESIZE_MASK) )
++              return image_save_to_jpeg_file(imsrc, cache_file);
++
+       if( imsrc->width > imsrc->height )
+       {
+               dstw = 160;
+diff --git a/minidlna.c b/minidlna.c
+index 7cce301..a1dd08b 100644
+--- a/minidlna.c
++++ b/minidlna.c
+@@ -735,6 +735,10 @@ init(int argc, char **argv)
+                       if (strtobool(ary_options[i].value))
+                               SETFLAG(DLNA_STRICT_MASK);
+                       break;
++              case RESIZE_COVER_ART:
++                      if((strcmp(ary_options[i].value, "no") == 0) || !atoi(ary_options[i].value))
++                              SETFLAG(NO_COVER_RESIZE_MASK);
++                      break;
+               case ROOT_CONTAINER:
+                       switch (ary_options[i].value[0]) {
+                       case '.':
+diff --git a/options.c b/options.c
+index cee3dff..cacbdfb 100644
+--- a/options.c
++++ b/options.c
+@@ -68,6 +68,7 @@ static const struct {
+       { WIDE_LINKS, "wide_links" },
+       { TIVO_DISCOVERY, "tivo_discovery" },
+       { ENABLE_SUBTITLES, "enable_subtitles" },
++      { RESIZE_COVER_ART, "resize_covers" },
+ };
+ int
+diff --git a/options.h b/options.h
+index 1ff5b22..ec5ea68 100644
+--- a/options.h
++++ b/options.h
+@@ -61,6 +61,7 @@ enum upnpconfigoptions {
+       WIDE_LINKS,                     /* allow following symlinks outside the defined media_dirs */
+       TIVO_DISCOVERY,                 /* TiVo discovery protocol: bonjour or beacon. Defaults to bonjour if supported */
+       ENABLE_SUBTITLES,               /* Enable generic subtitle support for all clients by default */
++      RESIZE_COVER_ART,               /* resize cover art to comply with DLNA spec */
+ };
+ /* readoptionsfile()
+diff --git a/upnpglobalvars.h b/upnpglobalvars.h
+index 1a2fb5e..7e3a1ba 100644
+--- a/upnpglobalvars.h
++++ b/upnpglobalvars.h
+@@ -205,6 +205,7 @@ extern uint32_t runtime_flags;
+ #define RESCAN_MASK           0x0200
+ #define SUBTITLES_MASK        0x0400
+ #define FORCE_ALPHASORT_MASK  0x0800
++#define NO_COVER_RESIZE_MASK  0x1000
+ #define SETFLAG(mask) runtime_flags |= mask
+ #define GETFLAG(mask) (runtime_flags & mask)
diff --git a/multimedia/minidlna/patches/070-return-void.patch b/multimedia/minidlna/patches/070-return-void.patch
new file mode 100644 (file)
index 0000000..7109dd9
--- /dev/null
@@ -0,0 +1,21 @@
+From ce34745bb19a649c8570ef0a3da9ffd5e941548e Mon Sep 17 00:00:00 2001
+From: Daniel Kamil Kozar <dkk089@gmail.com>
+Date: Sun, 30 Dec 2018 22:49:50 +0100
+Subject: [PATCH] No return in a function returning non-void
+
+---
+ upnpdescgen.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/upnpdescgen.c b/upnpdescgen.c
+index 85ce185..78d5754 100644
+--- a/upnpdescgen.c
++++ b/upnpdescgen.c
+@@ -525,6 +525,7 @@ genXML(char *str, int *len, int *tmplen, const struct XMLElt *p)
+                       pile[top].eltname = eltname;
+               }
+       }
++      return str;
+ }
+ /* genRootDesc() :
git clone https://git.99rst.org/PROJECT