Skip to content

Commit

Permalink
net/gerbera: Update to 2.0.0
Browse files Browse the repository at this point in the history
Partially backport commit 3e2f026f2281aa511f1a9106cf48a1f5344ae06b

Changelog:
https://github.com/gerbera/gerbera/releases/tag/v2.0.0

Reference:
gerbera/gerbera@3e2f026
  • Loading branch information
Daniel Engberg authored and Daniel Engberg committed Jan 13, 2024
1 parent c19463d commit 1ba2612
Show file tree
Hide file tree
Showing 5 changed files with 240 additions and 31 deletions.
15 changes: 4 additions & 11 deletions net/gerbera/Makefile
@@ -1,12 +1,8 @@
PORTNAME= gerbera
DISTVERSIONPREFIX= v
DISTVERSION= 1.12.1
PORTREVISION= 4
DISTVERSION= 2.0.0
CATEGORIES= net multimedia

PATCH_SITES= https://github.com/${PORTNAME}/${PORTNAME}/commit/
PATCHFILES= 37957aac0aea776e6f843af2358916f81056a405.patch:-p1

MAINTAINER= diizzy@FreeBSD.org
COMMENT= Media server compatible with DLNA and UPnP
WWW= https://gerbera.io/
Expand All @@ -25,6 +21,7 @@ USES= cmake compiler:c++17-lang iconv localbase:ldflags \
USE_GITHUB= yes
USE_RC_SUBR= gerbera

CMAKE_ON= WITH_MAGIC
CMAKE_OFF= WITH_EXIF WITH_LASTFM WITH_MYSQL WITH_SYSTEMD

SUB_FILES= pkg-message
Expand All @@ -36,16 +33,15 @@ GROUPS= gerbera
PLIST_SUB= USER=${USERS} GROUP=${GROUPS}

OPTIONS_DEFINE= CURL DEBUG DUKTAPE EXIV2 FFMPEG FFMPEGTHUMBNAILER \
LIBMAGIC MATROSKA TAGLIB TEST
OPTIONS_DEFAULT= CURL DUKTAPE EXIV2 FFMPEG LIBMAGIC TAGLIB LIBNPUPNP
MATROSKA TAGLIB TEST
OPTIONS_DEFAULT= CURL DUKTAPE EXIV2 FFMPEG TAGLIB LIBNPUPNP

OPTIONS_SINGLE= UPNPLIB
OPTIONS_SINGLE_UPNPLIB= LIBNPUPNP LIBUPNP

CURL_DESC= Support for online services via cURL
DUKTAPE_DESC= Javascript support for custom import scripts
FFMPEGTHUMBNAILER_DESC= Support for thumbnail generation
LIBMAGIC_DESC= Identify file mime types via libmagic
LIBNPUPNP_DESC= Use high performance libnpupnp library
LIBUPNP_DESC= Use libupnp library
MATROSKA_DESC= Extract video/mkv metadata via libmatroska
Expand All @@ -70,9 +66,6 @@ FFMPEG_LIB_DEPENDS= libavformat.so:multimedia/ffmpeg \
libavutil.so:multimedia/ffmpeg
FFMPEG_CMAKE_BOOL= WITH_AVCODEC

LIBMAGIC_LIB_DEPENDS= libmagic.so:sysutils/file
LIBMAGIC_CMAKE_BOOL= WITH_MAGIC

LIBNPUPNP_LIB_DEPENDS= libnpupnp.so:net/libnpupnp
LIBNPUPNP_CMAKE_BOOL= WITH_NPUPNP

Expand Down
8 changes: 3 additions & 5 deletions net/gerbera/distinfo
@@ -1,5 +1,3 @@
TIMESTAMP = 1694942560
SHA256 (gerbera-gerbera-v1.12.1_GH0.tar.gz) = 2144a7c4a13e8b43aa0c911fbeae65f05e2c42254ddd03be5c41f5fcf103a93c
SIZE (gerbera-gerbera-v1.12.1_GH0.tar.gz) = 4368573
SHA256 (37957aac0aea776e6f843af2358916f81056a405.patch) = ffa2fedae292fd02c30149af2c6ecd715f2e29ad1b53766958aaec1274b2b623
SIZE (37957aac0aea776e6f843af2358916f81056a405.patch) = 8400
TIMESTAMP = 1705147817
SHA256 (gerbera-gerbera-v2.0.0_GH0.tar.gz) = db2015a9e67ce896600221d912b402cbdeee9d1898761f6c6425c7182fffac2e
SIZE (gerbera-gerbera-v2.0.0_GH0.tar.gz) = 4219702
10 changes: 0 additions & 10 deletions net/gerbera/files/patch-CMakeLists.txt

This file was deleted.

@@ -0,0 +1,225 @@
From 3e2f026f2281aa511f1a9106cf48a1f5344ae06b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Karl=20Strau=C3=9Fberger?= <k_straussberger@netzland.net>
Date: Tue, 9 Jan 2024 13:12:10 +0100
Subject: [PATCH] Build Support for NPUPNP

---
.github/workflows/ci.yml | 23 ++++++++
CMakeLists.txt | 43 ++++++++++++---
ChangeLog.md | 5 ++
README.md | 2 +-
cmake/FindNPUPNP.cmake | 54 +++++++++++++++++++
cmake/FindUPNP.cmake | 6 +--
scripts/debian/build-deb.sh | 33 ++++++++++--
scripts/install-googletest.sh | 4 +-
scripts/install-npupnp.sh | 83 +++++++++++++++++++++++++++++
scripts/versions.sh | 4 +-
src/iohandler/process_io_handler.cc | 1 +
src/server.cc | 2 +
src/server.h | 2 +
13 files changed, 244 insertions(+), 18 deletions(-)
create mode 100644 cmake/FindNPUPNP.cmake
create mode 100755 scripts/install-npupnp.sh

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1c301ecd9..5299b7bee 100644
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -385,14 +385,45 @@ target_compile_options(libgerbera PUBLIC ${LFS_COMPILE_OPTIONS})
target_link_libraries(libgerbera PUBLIC ${LFS_LIBRARIES})

if (WITH_NPUPNP)
- find_package(PkgConfig QUIET)
- pkg_check_modules(NPUPNP QUIET libnpupnp>=4.2.1)
- if (NOT NPUPNP_FOUND)
- find_package(NPUPNP REQUIRED)
+ set(REQ_NPUPNP_VERSION 4.2.1)
+
+ find_package(NPUPNP ${REQ_NPUPNP_VERSION} QUIET)
+
+ if (NOT TARGET NPUPNP::NPUPNP)
+ find_package(npupnp ${REQ_NPUPNP_VERSION} QUIET)
+ if(TARGET npupnp::npupnp)
+ add_library(NPUPNP::NPUPNP ALIAS npupnp::npupnp)
+ endif()
endif()
- target_include_directories(libgerbera PUBLIC ${NPUPNP_INCLUDE_DIRS})
+ if(NOT TARGET NPUPNP::NPUPNP)
+ message(FATAL_ERROR "Gerbera failed to find libnpupnp! at least version ${REQ_UPNP_VERSION} is needed.")
+ endif()
+ # Conan autogenerated targets dont set a version, but to set name_VERSION var
+ get_target_property(_UPNP_VERSION NPUPNP::NPUPNP VERSION)
+ if (NOT _UPNP_VERSION)
+ set(_UPNP_VERSION ${npupnp_VERSION})
+ endif()
+ get_target_property(_UPNP_LIB NPUPNP::NPUPNP LOCATION)
+
+ # Check and warn for libnpupnp features
+ include(CheckCXXSymbolExists)
+ get_target_property(UPNP_INCLUDE_DIR NPUPNP::NPUPNP INTERFACE_INCLUDE_DIRECTORIES)
+ check_cxx_symbol_exists(UPNP_ENABLE_IPV6 "${UPNP_INCLUDE_DIR}/upnpconfig.h" UPNP_HAS_IPV6)
+ if (NOT UPNP_HAS_IPV6)
+ message(FATAL_ERROR "Gerbera requires libnpupnp with IPv6 support.")
+ endif()
+
+ check_cxx_symbol_exists(UPNP_HAVE_TOOLS "${UPNP_INCLUDE_DIR}/upnpconfig.h" UPNP_HAS_TOOLS)
+ if (NOT UPNP_HAS_TOOLS)
+ message(WARNING [=[
+ !! It is strongly recommended to build libupnp with --enable-tools !!
+ ]=])
+ endif()
+
+ message(STATUS "Found libnpupnp: ${_UPNP_LIB} (found version ${_UPNP_VERSION})")
+
target_compile_definitions(libgerbera PUBLIC USING_NPUPNP)
- target_link_libraries(libgerbera PUBLIC ${NPUPNP_LIBRARIES})
+ target_link_libraries(libgerbera PUBLIC NPUPNP::NPUPNP)
else()
set(REQ_UPNP_VERSION 1.14.6)
# LibUPnP official target since 1.16 (Lib version 18)
new file mode 100644
index 000000000..b83168295
--- /dev/null
+++ cmake/FindNPUPNP.cmake
@@ -0,0 +1,54 @@
+# - Try to find LibNPUPnP (npupnp) 4.1.2
+# Once done this will define
+# NPUPNP_FOUND - System has LibNPUPnP
+# UPNP_INCLUDE_DIRS - The LibNPUPnP include directories
+# NPUPNP_LIBRARIES - The libraries needed to use LibNPUPnP
+# NPUPNP_VERSION_STRING - The version of LibNPUPnP found
+# NPUPNP_HAS_IPV6 - If LibNPUPnP was built with IPv6 support
+# NPUPNP_HAS_REUSEADDR - If LibNPUPnP was built with SO_REUSEADDR support
+find_package(PkgConfig QUIET)
+pkg_search_module (PC_NPUPNP libnpupnp QUIET)
+
+find_path(UPNP_INCLUDE_DIR upnp.h
+ HINTS ${PC_NPUPNP_INCLUDEDIR} ${PC_UPNP_INCLUDE_DIRS}
+ PATH_SUFFIXES npupnp)
+
+#if (STATIC_LIBUPNP)
+# set(OLD_SUFFIX ${CMAKE_FIND_LIBRARY_SUFFIXES})
+# set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX})
+#endif()
+
+find_library(NPUPNP_LIBRARY
+ NAMES libnpupnp npupnp
+ HINTS ${PC_NPUPNP_LIBDIR} ${PC_NPUPNP_LIBRARY_DIRS})
+
+# Restore
+#if (STATIC_LIBUPNP)
+# set(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_SUFFIX})
+#endif()
+
+if(EXISTS ${UPNP_INCLUDE_DIR}/upnpconfig.h)
+ file (STRINGS ${UPNP_INCLUDE_DIR}/upnpconfig.h upnp_ver_str REGEX "^#define[ \t]+NPUPNP_VERSION_STRING[ \t]+\".+\"")
+ string(REGEX REPLACE "^#define[ \t]+NPUPNP_VERSION_STRING[ \t]+\"([^\"]+)\".*" "\\1" NPUPNP_VERSION "${upnp_ver_str}")
+endif()
+
+include(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(NPUPNP
+ REQUIRED_VARS NPUPNP_LIBRARY UPNP_INCLUDE_DIR
+ VERSION_VAR NPUPNP_VERSION)
+
+if (NPUPNP_FOUND)
+ if(NOT TARGET NPUPNP::NPUPNP)
+ add_library(NPUPNP::NPUPNP SHARED IMPORTED)
+ set_target_properties(NPUPNP::NPUPNP PROPERTIES
+ IMPORTED_LOCATION ${NPUPNP_LIBRARY}
+ INTERFACE_INCLUDE_DIRECTORIES ${UPNP_INCLUDE_DIR}
+ VERSION ${NPUPNP_VERSION}
+ )
+ endif()
+endif ()
+
+MARK_AS_ADVANCED(
+ UPNP_INCLUDE_DIR
+ NPUPNP_LIBRARY
+)
diff --git a/cmake/FindUPNP.cmake b/cmake/FindUPNP.cmake
index 587e1c5ef..246328806 100644
--- cmake/FindUPNP.cmake
+++ cmake/FindUPNP.cmake
@@ -3,9 +3,9 @@
# UPNP_FOUND - System has LibUPnP
# UPNP_INCLUDE_DIRS - The LibUPnP include directories
# UPNP_LIBRARIES - The libraries needed to use LibUPnP
-# UPNP_VERSION_STRING - The version of LinUPnP found
-# UPNP_HAS_IPV6 - If LinUPnP was built with IPv6 support
-# UPNP_HAS_REUSEADDR - If LinUPnP was built with SO_REUSEADDR support
+# UPNP_VERSION_STRING - The version of LibUPnP found
+# UPNP_HAS_IPV6 - If LibUPnP was built with IPv6 support
+# UPNP_HAS_REUSEADDR - If LibUPnP was built with SO_REUSEADDR support
find_package(PkgConfig QUIET)
pkg_search_module (PC_UPNP QUIET libupnp)

diff --git a/scripts/versions.sh b/scripts/versions.sh
index c859e701b..86612f3e3 100755
--- scripts/versions.sh
+++ scripts/versions.sh
@@ -30,6 +30,7 @@ if [[ "${GERBERA_ENV-head}" == "minimum" ]]; then
MATROSKA="1.5.2"
PUGIXML="1.10"
PUPNP="1.14.6"
+ NPUPNP="4.2.1"
SPDLOG="1.8.1"
WAVPACK="5.1.0"
TAGLIB="1.12"
@@ -46,6 +47,7 @@ elif [[ "${GERBERA_ENV-head}" == "default" ]]; then
MATROSKA="1.5.2"
PUGIXML="1.10"
PUPNP="1.14.17"
+ NPUPNP="5.1.2"
SPDLOG="1.11.0"
WAVPACK="5.4.0"
TAGLIB="1.12"
@@ -63,8 +65,8 @@ else
PUGIXML="1.14"
PUPNP="1.14.18"
SPDLOG="1.12.0"
+ NPUPNP="6.1.0"
WAVPACK="5.6.0"
TAGLIB="1.13.1"

fi
-
diff --git a/src/iohandler/process_io_handler.cc b/src/iohandler/process_io_handler.cc
index de174eab2..3ff9e8099 100644
--- src/iohandler/process_io_handler.cc
+++ src/iohandler/process_io_handler.cc
@@ -39,6 +39,7 @@

#include <fcntl.h>
#include <sys/select.h>
+#include <unistd.h>

#include "content/content_manager.h"

diff --git a/src/server.cc b/src/server.cc
index c8a0c2c75..bfd5d6477 100644
--- src/server.cc
+++ src/server.cc
@@ -231,8 +231,10 @@ void Server::run()
throw UpnpException(ret, fmt::format("run: UpnpSendAdvertisement {} failed", aliveAdvertisementInterval));
}

+#if !defined(USING_NPUPNP)
if (config->getBoolOption(CFG_UPNP_LITERAL_HOST_REDIRECTION))
UpnpSetAllowLiteralHostRedirection(1);
+#endif

UpnpSetHostValidateCallback(
[](auto host, auto cookie) -> int {
diff --git a/src/server.h b/src/server.h
index a91466b65..5826a1a77 100644
--- src/server.h
+++ src/server.h
@@ -34,6 +34,8 @@
#ifndef __SERVER_H__
#define __SERVER_H__

+#include <netinet/in.h>
+
#include "request_handler.h"

// forward declaration
13 changes: 8 additions & 5 deletions net/gerbera/pkg-plist
@@ -1,4 +1,5 @@
bin/gerbera
%%DATADIR%%/js/audio.js
%%DATADIR%%/js/common.js
%%DATADIR%%/js/import.js
%%DATADIR%%/js/metadata.js
Expand Down Expand Up @@ -48,7 +49,6 @@ bin/gerbera
%%DATADIR%%/web/js/jquery.gerbera.trail.js
%%DATADIR%%/web/js/jquery.gerbera.tree.js
%%DATADIR%%/web/js/jquery.gerbera.tweak.js
%%DATADIR%%/web/js/md5.js
%%DATADIR%%/web/mr_reg.xml
%%DATADIR%%/web/vendor/bootstrap/css/bootstrap-grid.min.css
%%DATADIR%%/web/vendor/bootstrap/css/bootstrap-grid.min.css.map
Expand All @@ -66,16 +66,19 @@ bin/gerbera
%%DATADIR%%/web/vendor/font-awesome/fonts/fontawesome-webfont.ttf
%%DATADIR%%/web/vendor/font-awesome/fonts/fontawesome-webfont.woff
%%DATADIR%%/web/vendor/font-awesome/fonts/fontawesome-webfont.woff2
%%DATADIR%%/web/vendor/jquery/jquery-3.6.0.min.js
%%DATADIR%%/web/vendor/jquery/jquery-3.6.0.min.map
%%DATADIR%%/web/vendor/jquery/jquery.min.js
%%DATADIR%%/web/vendor/jquery/jquery.min.map
%%DATADIR%%/web/vendor/jquery/jquery-ui.min.js
%%DATADIR%%/web/vendor/js-cookie.min.js
%%DATADIR%%/web/vendor/lato/LICENCE.md
%%DATADIR%%/web/vendor/lato/lato-v14-latin-ext_latin-regular.woff
%%DATADIR%%/web/vendor/lato/lato-v14-latin-ext_latin-regular.woff2
%%DATADIR%%/web/vendor/popper/popper.js
%%DATADIR%%/web/vendor/md5.min.js
%%DATADIR%%/web/vendor/md5.min.js.map
%%DATADIR%%/web/vendor/popper/popper.min.js
%%DATADIR%%/web/vendor/popper/popper.min.js.map
%%DATADIR%%/web/vendor/tether/tether.min.js
man/man1/gerbera.1.gz
share/man/man1/gerbera.1.gz
@owner %%USER%%
@group %%GROUP%%
@dir /var/db/gerbera
Expand Down

0 comments on commit 1ba2612

Please sign in to comment.