Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Tvheadend and ffmpeg for DMS 7 #4545

Merged
merged 15 commits into from
Jun 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cross/chromaprint/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ include ../../mk/spksrc.cross-cmake.mk

CMAKE_ARGS += -DBUILD_TOOLS=ON
CMAKE_ARGS += -DCMAKE_INSTALL_RPATH=$(CMAKE_RPATH)
CMAKE_ARGS += -DCMAKE_CXX_FLAGS="-Wno-deprecated-declarations"
17 changes: 17 additions & 0 deletions cross/chromaprint/patches/001-disable-HAVE_AV_FRAME.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--- src/audio/ffmpeg_audio_reader.h.orig 2020-04-15 04:08:10.000000000 +0000
+++ src/audio/ffmpeg_audio_reader.h 2021-04-12 23:31:30.658596475 +0000
@@ -27,14 +27,6 @@ extern "C" {
#define av_packet_unref av_free_packet
#endif

-#ifndef HAVE_AV_FRAME_ALLOC
-#define av_frame_alloc avcodec_alloc_frame
-#endif
-
-#ifndef HAVE_AV_FRAME_FREE
-#define av_frame_free avcodec_free_frame
-#endif
-
#ifndef AV_ERROR_MAX_STRING_SIZE
#define AV_ERROR_MAX_STRING_SIZE 128
#endif
7 changes: 7 additions & 0 deletions cross/libaom/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ include ../../mk/spksrc.cross-cmake.mk
# libaom specific cmake options
CMAKE_ARGS += -DCONFIG_AV1_ENCODER=1

ifeq ($(call version_ge, ${TCVERSION}, 7.0),1)
CMAKE_ARGS += -DCMAKE_CXX_FLAGS=-D_GLIBCXX_USE_C99_MATH
ifeq ($(findstring $(ARCH),$(ARMv7_ARCHS) $(ARMv7L_ARCHS)),$(ARCH))
CMAKE_ARGS += -DENABLE_NEON=OFF
endif
endif

ifeq ($(findstring $(ARCH),$(ARMv5_ARCHS)),$(ARCH))
CMAKE_ARGS += -DAOM_TARGET_CPU=arm
endif
Expand Down
8 changes: 4 additions & 4 deletions cross/tvheadend/Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
PKG_NAME = tvheadend
PKG_VERS = 4.3
PKG_EXT = tar.gz
PKG_DOWNLOAD_METHOD = git
PKG_GIT_HASH = 9ed76c0a176b055a57b6e8bd2e0b6e29409269a9
PKG_DIST_SITE = https://github.com/tvheadend/tvheadend.git
PKG_DIST_NAME = $(PKG_GIT_HASH).$(PKG_EXT)
PKG_DIST_SITE = https://github.com/tvheadend/tvheadend/archive
PKG_DIST_FILE = $(PKG_NAME)-git$(PKG_GIT_HASH).$(PKG_EXT)
PKG_DIR = $(PKG_NAME)-git$(PKG_GIT_HASH)
PKG_DIR = $(PKG_NAME)-$(PKG_GIT_HASH)
th0ma7 marked this conversation as resolved.
Show resolved Hide resolved

DEPENDS = cross/openssl cross/uriparser cross/pcre2 cross/libiconv
DEPENDS = cross/openssl cross/uriparser cross/pcre2 cross/libiconv cross/fontconfig
DEPENDS += cross/libhdhomerun cross/libdvbcsa cross/dvb-apps cross/pngquant

HOMEPAGE = https://tvheadend.org/
Expand Down
6 changes: 3 additions & 3 deletions cross/tvheadend/digests
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
tvheadend-git9ed76c0a176b055a57b6e8bd2e0b6e29409269a9.tar.gz SHA1 821634cc8a40375ab22885032ee959a81de11970
tvheadend-git9ed76c0a176b055a57b6e8bd2e0b6e29409269a9.tar.gz SHA256 1378fcd819011b3161dc01ccc9b068099041cf4af7550777a6f1e64cacbaec41
tvheadend-git9ed76c0a176b055a57b6e8bd2e0b6e29409269a9.tar.gz MD5 70f71d73fc5bb1da2253764109d327cc
tvheadend-git9ed76c0a176b055a57b6e8bd2e0b6e29409269a9.tar.gz SHA1 6d8f86a1f4a9318537b06d55a9aea76245c961c0
tvheadend-git9ed76c0a176b055a57b6e8bd2e0b6e29409269a9.tar.gz SHA256 d9ea0d1d1596efc5d6fed1595391a7cb2fc2442aa292fe0b57b9ab6910b32046
tvheadend-git9ed76c0a176b055a57b6e8bd2e0b6e29409269a9.tar.gz MD5 ff0b7102c72be18146f3f44051d2270e
3 changes: 2 additions & 1 deletion spk/chromaprint/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SPK_NAME = chromaprint
SPK_VERS = 1.5.0
SPK_REV = 13
SPK_REV = 14
SPK_ICON = src/chromaprint.png

DEPENDS = cross/$(SPK_NAME)
Expand All @@ -19,6 +19,7 @@ LICENSE = LGPL2.1+
export FFMPEG_DIR = $(shell pwd)/../ffmpeg/work-$(ARCH)-$(TCVERSION)/install/var/packages/ffmpeg/target

ifneq ($(wildcard $(FFMPEG_DIR)),)
export ADDITIONAL_LDFLAGS = -Wl,--rpath-link,$(FFMPEG_DIR)/lib -Wl,--rpath,/var/packages/ffmpeg/target/lib
PRE_DEPEND_TARGET = chromaprint_pre_depend
SPK_DEPENDS = "ffmpeg>4.2"
endif
Expand Down
1 change: 1 addition & 0 deletions spk/chromaprint/src/conf/resource
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"video-driver":{}}
1 change: 1 addition & 0 deletions spk/comskip/src/conf/resource
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"video-driver":{}}
2 changes: 2 additions & 0 deletions spk/ffmpeg/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ SPK_REV = 36
SPK_ICON = src/ffmpeg.png
CHANGELOG = "1. Update Intel libva to version 2.10 and media drivers 2020Q4<br/>2. Multiple depedency updates (libass, SVT-AV1, libaom, x264, libbluray, libvpx)"

CONF_DIR = src/conf

DEPENDS = cross/$(SPK_NAME)

MAINTAINER = th0ma7
Expand Down
1 change: 1 addition & 0 deletions spk/ffmpeg/src/conf/resource
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"video-driver":{}}
16 changes: 10 additions & 6 deletions spk/ffmpeg/src/service-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@

service_postinst ()
{
# setuid for proper vaapi access
chmod u+s /var/packages/ffmpeg/target/bin/ffmpeg
chmod u+s /var/packages/ffmpeg/target/bin/vainfo
if [ $SYNOPKG_DSM_VERSION_MAJOR -lt 7 ];then
# setuid for proper vaapi access
chmod u+s /var/packages/ffmpeg/target/bin/ffmpeg
chmod u+s /var/packages/ffmpeg/target/bin/vainfo
fi
}

service_postupgrade ()
{
# setuid for proper vaapi access
chmod u+s /var/packages/ffmpeg/target/bin/ffmpeg
chmod u+s /var/packages/ffmpeg/target/bin/vainfo
if [ $SYNOPKG_DSM_VERSION_MAJOR -lt 7 ];then
# setuid for proper vaapi access
chmod u+s /var/packages/ffmpeg/target/bin/ffmpeg
chmod u+s /var/packages/ffmpeg/target/bin/vainfo
fi
}
18 changes: 7 additions & 11 deletions spk/tvheadend/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ SPK_NAME = tvheadend
SPK_SHORT_VERS = 4.3
SPK_GIT_HASH = 9ed76c0
SPK_GIT_DATE = 20201011
SPK_VERS = $(SPK_SHORT_VERS).$(SPK_GIT_DATE)~$(SPK_GIT_HASH)
SPK_VERS = $(SPK_SHORT_VERS).$(SPK_GIT_DATE)
th0ma7 marked this conversation as resolved.
Show resolved Hide resolved
TVH_VERS = $(SPK_SHORT_VERS)~$(SPK_GIT_HASH)
SPK_REV = 26
SPK_REV = 27
SPK_ICON = src/tvheadend.png
DSM_UI_DIR = app

Expand All @@ -13,7 +13,7 @@ DSM_UI_DIR = app
# 000-fix-version.patch from cross/tvheadend
export TVH_VERS

DEPENDS = cross/busybox cross/$(SPK_NAME)
DEPENDS = cross/$(SPK_NAME)

MAINTAINER = th0ma7
DESCRIPTION = Tvheadend is a TV streaming server and recorder for Linux, FreeBSD and Android supporting DVB-S, DVB-S2, DVB-C, DVB-T, ATSC, ISDB-T, IPTV, SAT IP and HDHomeRun as input sources. Tvheadend offers HTTP, HTSP and SAT IP streaming.
Expand Down Expand Up @@ -44,9 +44,6 @@ ADMIN_PORT = ${SERVICE_PORT}

POST_STRIP_TARGET = tvheadend_extra_install

BUSYBOX_CONFIG = usrmng
ENV += BUSYBOX_CONFIG="$(BUSYBOX_CONFIG)"

# Reuse ffmpeg libraries
# Requires to invoke: make [package|publish] ARCH= TCVERSION=
export FFMPEG_DIR = $(shell pwd)/../ffmpeg/work-$(ARCH)-$(TCVERSION)/install/var/packages/ffmpeg/target
Expand Down Expand Up @@ -78,9 +75,8 @@ tvheadend_pre_depend:
$(foreach lib,$(VAAPI_LIBS),ln -sfT $(FFMPEG_DIR)/lib/pkgconfig/$(lib) $(STAGING_INSTALL_PREFIX)/lib/pkgconfig/$(lib) ;)

tvheadend_extra_install:
install -m 755 -d $(STAGING_DIR)/var
install -m 755 -d $(STAGING_DIR)/var/accesscontrol
install -m 755 -d $(STAGING_DIR)/var/passwd
install -p -m 700 -d $(STAGING_DIR)/var/accesscontrol
install -p -m 700 -d $(STAGING_DIR)/var/passwd
# The following filenames stem from an arbitrary (valid) combination created by TVH
install -m 644 src/accesscontrol.json $(STAGING_DIR)/var/accesscontrol/d80ccc09630261ffdcae1497a690acc8
install -m 644 src/passwd.json $(STAGING_DIR)/var/passwd/a927e30a755504f9784f23a4efac5109
install -m 640 src/accesscontrol.json $(STAGING_DIR)/var/accesscontrol/d80ccc09630261ffdcae1497a690acc8
install -m 640 src/passwd.json $(STAGING_DIR)/var/passwd/a927e30a755504f9784f23a4efac5109
1 change: 1 addition & 0 deletions spk/tvheadend/src/conf/resource
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"video-driver":{}}
105 changes: 16 additions & 89 deletions spk/tvheadend/src/service-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
# Sourced script by generic installer and start-stop-status scripts

# Service configuration. Change http and htsp ports here and in conf/tvheadend.sc for non-standard ports
HTTPP=9981
HTSPP=9982
HTTP=9981
HTSP=9982

# Replace generic service startup, run service in background
GRPN=`id -gn ${EFF_USER}`
HOME_DIR="${SYNOPKG_PKGDEST}/var"
DVR_LOG_DIR="${SYNOPKG_PKGDEST}/var/dvr/log"
SAVE_DIR="/tmp/tvheadend-recording-backup"
SERVICE_COMMAND="${SYNOPKG_PKGDEST}/bin/tvheadend -f -u ${EFF_USER} -g ${GRPN} --http_port ${HTTPP} --htsp_port ${HTSPP} -c ${HOME_DIR} -p ${PID_FILE}"
GRPN=$(id -gn ${EFF_USER})
UPGRADE_CFG_DIR="${SYNOPKG_PKGVAR}/dvr/config"
SERVICE_COMMAND="${SYNOPKG_PKGDEST}/bin/tvheadend -f -u ${EFF_USER} -g ${GRPN} --http_port ${HTTP} --htsp_port ${HTSP} -c ${SYNOPKG_PKGVAR} -p ${PID_FILE}"
SVC_BACKGROUND=yes

# Group configuration to manage permissions of recording folders
Expand All @@ -19,108 +17,37 @@ GROUP=sc-media
service_postinst ()
{
# Encrypt password
wizard_password=`echo -n "TVHeadend-Hide-${wizard_password:=admin}" | openssl enc -a`
wizard_password=$(echo -n "TVHeadend-Hide-${wizard_password:=admin}" | openssl enc -a)

# Edit the password configuration according to the wizard
sed -i -e "s/@password@/${wizard_password}/g" ${SYNOPKG_PKGDEST}/var/passwd/a927e30a755504f9784f23a4efac5109

# Fix fontconfig links
CONFD_DIR="${SYNOPKG_PKGDEST}/etc/fonts/conf.d"
FONTS_DIR="${SYNOPKG_PKGDEST}/share/fontconfig/conf.avail"
echo "Fixing fontconfig links" >> ${INST_LOG}
for FONT_FILE in ${CONFD_DIR}/*.conf
do
FONT_NAME=`basename "${FONT_FILE}"`
$LN "${FONTS_DIR}/${FONT_NAME}" "${CONFD_DIR}/${FONT_NAME}" >> ${INST_LOG}
done

# Discard legacy obsolete busybox user account
BIN=${SYNOPKG_PKGDEST}/bin
$BIN/busybox --install $BIN
$BIN/delgroup "${USER}" "users" >> ${INST_LOG}
$BIN/deluser "${USER}" >> ${INST_LOG}
sed -i -e "s/@password@/${wizard_password}/g" ${SYNOPKG_PKGVAR}/passwd/a927e30a755504f9784f23a4efac5109
}

service_preupgrade ()
{
# For backwards compatibility on DSM6
if [ $SYNOPKG_DSM_VERSION_MAJOR -gt 5 ]; then
# Backup potential recordings from package root directory
echo "Save potential recordings from package root directory..." >> ${INST_LOG}
for logfile in ${DVR_LOG_DIR}/*
do
REC_FILE=`grep -e 'filename' ${logfile} | awk -F'"' '{print $4}'`
# Check whether recording actually exists, otherwise ignore the entry
if [ -e "${REC_FILE}" ]; then
REC_DIR=`dirname "${REC_FILE}"`
REAL_DIR=`realpath "${REC_DIR}"`
TRUNC_DIR=`echo "${REAL_DIR}" | cut -c9-28`
CHECK_VAR=`echo "${REAL_DIR}" | cut -c29-32`
if [ ! "${REC_FILE}" = "" ] && [ "${TRUNC_DIR}" = "/@appstore/tvheadend" ] && [ ! "${CHECK_VAR}" = "/var" ]; then
REC_NAME=`basename "${REC_FILE}"`
REST_DIR=`echo "${REAL_DIR}" | cut -c30-`
DEST_FILE="${SAVE_DIR}/${REST_DIR}/${REC_NAME}"
echo "Saving: ${REC_FILE}" >> ${INST_LOG}
$MKDIR "${SAVE_DIR}/${REST_DIR}"
$CP "${REC_FILE}" "${DEST_FILE}"
# Replace any remaining target links in log files first
sed -i -e "s,/var/packages/tvheadend/target/,/usr/local/tvheadend/,g" "${logfile}"
# Adapt recording paths in dvr log files for restored files (postupgrade)
sed -i -e "s,/tvheadend/,/tvheadend/var/,g" "${logfile}"
fi
fi
done
# Move recording directories from package root into var
UPGRADE_CFG_DIR="${SYNOPKG_PKGDEST}/var/dvr/config"
echo "Move any recording directories from package root directory into var..." >> ${INST_LOG}
for file in ${UPGRADE_CFG_DIR}/*
do
DVR_DIR=`grep -e 'storage\":' ${file} | awk -F'"' '{print $4}'`
REAL_DIR=`realpath "${DVR_DIR}"`
TRUNC_DIR=`echo "${REAL_DIR}" | cut -c9-28`
CHECK_VAR=`echo "${REAL_DIR}" | cut -c29-32`
# Replace any remaining target links in log files first
sed -i -e "s,/var/packages/tvheadend/target,/usr/local/tvheadend,g" "${file}"
if [ "${TRUNC_DIR}" = "/@appstore/tvheadend" ] && [ ! "${CHECK_VAR}" = "/var" ]; then
# Move recording paths in recording profiles into var
sed -i -e "s,/tvheadend,/tvheadend/var,g" "${file}"
fi
done
fi
}

service_postupgrade ()
{
# For backwards compatibility, restore recordings from old package root into var directory
if [ -d "${SAVE_DIR}" ]; then
echo "Restoring recordings into ${HOME_DIR}" >> ${INST_LOG}
$CP "${SAVE_DIR}"/. "${HOME_DIR}" >> ${INST_LOG}
$RM "${SAVE_DIR}"
fi

# Need to enforce correct permissions for recording directories on upgrades
echo "Adding ${GROUP} group permissions on recording directories:" >> ${INST_LOG}
UPGRADE_CFG_DIR="${SYNOPKG_PKGDEST}/var/dvr/config"
echo "Adding ${GROUP} group permissions on recording directories:"
for file in ${UPGRADE_CFG_DIR}/*
do
DVR_DIR=`grep -e 'storage\":' ${file} | awk -F'"' '{print $4}'`
DVR_DIR=$(grep -e 'storage\":' ${file} | awk -F'"' '{print $4}')
# Exclude directories in @appstore as ACL permissions srew up package installations
TRUNC_DIR=$(echo "$(realpath ${DVR_DIR})" | awk -F/ '{print "/"$3}')
if [ "${TRUNC_DIR}" = "/@appstore" ]; then
echo "Skip: ${DVR_DIR} (system directory)" >> ${INST_LOG}
else
echo "Done: ${DVR_DIR}" >> ${INST_LOG}
echo "Skip: ${DVR_DIR} (system directory)"
elif [ $SYNOPKG_DSM_VERSION_MAJOR -lt 7 ]; then
echo "Done: ${DVR_DIR}"
set_syno_permissions "${DVR_DIR}" "${GROUP}"
fi
done

# For backwards compatibility, restore ownership of package system directories
echo "Restore '${EFF_USER}' unix permissions on package system directories" >> ${INST_LOG}
if [ $SYNOPKG_DSM_VERSION_MAJOR -lt 6 ]; then
synoacltool -del "${SYNOPKG_PKGDEST}" >> ${INST_LOG} 2>&1
chown ${EFF_USER}:root "/var/packages/tvheadend" >> ${INST_LOG} 2>&1
else
chown ${EFF_USER}:${USER} "/var/packages/tvheadend/target" >> ${INST_LOG} 2>&1
set_unix_permissions "${SYNOPKG_PKGDEST}/var"
if [ $SYNOPKG_DSM_VERSION_MAJOR == 6 ]; then
echo "Restore '${EFF_USER}' unix permissions on package system directories"
chown ${EFF_USER}:${USER} "${SYNOPKG_PKGDEST}"
set_unix_permissions "${SYNOPKG_PKGVAR}"
fi
}