Skip to content

Commit

Permalink
Sonarr: (dotNET) v4 build
Browse files Browse the repository at this point in the history
  • Loading branch information
mreid-tt committed Dec 12, 2022
1 parent 9addc79 commit cae96ef
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 93 deletions.
24 changes: 19 additions & 5 deletions cross/sonarr/Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,35 @@
PKG_NAME = Sonarr
PKG_VERS = 3.0.5.1144
PKG_VERS = 4.0.0.87
PKG_EXT = tar.gz
PKG_DIST_NAME = $(PKG_NAME).main.$(PKG_VERS).linux.$(PKG_EXT)
PKG_DIST_SITE = https://download.sonarr.tv/v3/main/$(PKG_VERS)
PKG_DIST_NAME = $(PKG_NAME).widowmaker.$(PKG_VERS).linux-$(PKG_DIST_ARCH).$(PKG_EXT)
PKG_DIST_SITE = https://download.sonarr.tv/v4/widowmaker/$(PKG_VERS)
PKG_DIR = $(PKG_NAME)

DEPENDS =

UNSUPPORTED_ARCHS = $(i686_ARCHS) $(ARMv7L_ARCHS) $(ARMv5_ARCHS) $(PPC_ARCHS)

HOMEPAGE = https://sonarr.tv
COMMENT = Sonarr is a PVR for newsgroup users. It can monitor multiple RSS feeds for new episodes of your favourite shows and will grab, sorts and rename them. It can also be configured to automatically upgrade the quality of files already downloaded if a better quality format becomes available.
LICENSE = GNU GPL v3

INSTALL_TARGET = sonarr_install

# use digests with multiple files
PKG_DIST_ARCH_LIST = x64 arm arm64

include ../../mk/spksrc.archs.mk
PKG_DIST_ARCH = x64
ifeq ($(findstring $(ARCH),$(ARMv7_ARCHS)),$(ARCH))
PKG_DIST_ARCH = arm
else ifeq ($(findstring $(ARCH),$(ARMv8_ARCHS)),$(ARCH))
PKG_DIST_ARCH = arm64
endif

include ../../mk/spksrc.install-resources.mk

.PHONY: sonarr_install
sonarr_install:
mkdir -p $(STAGING_INSTALL_PREFIX)/share/$(PKG_DIR)
tar -cf - -C $(WORK_DIR)/$(PKG_DIR) . | tar -xf - -C $(STAGING_INSTALL_PREFIX)/share/$(PKG_DIR)
rm -rf $(WORK_DIR)/$(PKG_DIR)/Sonarr.Update
mkdir -p $(STAGING_INSTALL_PREFIX)/share/$(PKG_DIR)/bin
tar -cf - -C $(WORK_DIR)/$(PKG_DIR) . | tar -xf - -C $(STAGING_INSTALL_PREFIX)/share/$(PKG_DIR)/bin
12 changes: 9 additions & 3 deletions cross/sonarr/digests
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Sonarr.main.3.0.5.1144.linux.tar.gz SHA1 2335133139a46f1ce0d1b2cb1f566d30285d3d1e
Sonarr.main.3.0.5.1144.linux.tar.gz SHA256 77aff6978d4dc80027979c815bd5a79579dd9bb50d39b1b2d14b3bb9e18058aa
Sonarr.main.3.0.5.1144.linux.tar.gz MD5 675ce0ab2f1e643860ab1daab45b2842
Sonarr.widowmaker.4.0.0.87.linux-arm.tar.gz SHA1 c331ba587484d9407952f749d5f0a79e3ddeb9f0
Sonarr.widowmaker.4.0.0.87.linux-arm.tar.gz SHA256 9601e29c8721ce74e93eaa3d31cbee5268b31b95df534ea53d588488e660482f
Sonarr.widowmaker.4.0.0.87.linux-arm.tar.gz MD5 1b75c84b80b14e2a18ea72c3f953f24e
Sonarr.widowmaker.4.0.0.87.linux-arm64.tar.gz SHA1 15fbd75b7e62d81e9027e94859996efe7ad48754
Sonarr.widowmaker.4.0.0.87.linux-arm64.tar.gz SHA256 218e050b20d96655135327dac7282bef691212e99ad9ddd61038e62399671e37
Sonarr.widowmaker.4.0.0.87.linux-arm64.tar.gz MD5 ab54102a461ad4d999e47d8eb8e2a553
Sonarr.widowmaker.4.0.0.87.linux-x64.tar.gz SHA1 8e7fbe0a2b92364740a71d7e43f63ab6795b9cd0
Sonarr.widowmaker.4.0.0.87.linux-x64.tar.gz SHA256 dfdac229953f2b6d4584ea95cc570a31a7d4478a3d7db41ef000bd04921cae18
Sonarr.widowmaker.4.0.0.87.linux-x64.tar.gz MD5 38546f7562806c5d2d072b9df85950c8
23 changes: 14 additions & 9 deletions spk/sonarr/Makefile
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
SPK_NAME = nzbdrone
SPK_NAME = sonarr
SPK_VERS = $(shell date +%Y%m%d)
SPK_REV = 20
SPK_REV = 22
SPK_ICON = src/sonarr.png

# Mono not supported on ppc platforms. C.f. cross/mono/Makefile and references therein for details.
UNSUPPORTED_ARCHS = $(PPC_ARCHS)
DEPENDS = cross/sonarr cross/libstdc++ cross/sqlite

DEPENDS = cross/curl cross/mediainfo cross/sqlite cross/sonarr

SPK_DEPENDS = "mono>3.6"
UNSUPPORTED_ARCHS = $(DOTNET_UNSUPPORTED_ARCHS)

MAINTAINER = SynoCommunity
DESCRIPTION = Sonarr is a PVR for newsgroup and torrent users. It can monitor multiple RSS feeds for new episodes of your favourite shows and will grab, sorts and rename them. It can also be configured to automatically upgrade the quality of files already downloaded if a better quality format becomes available.
DESCRIPTION_FRE = Sonarr est un PVR pour les utilisateurs de groupes de discussion et torrents. Il peut surveiller plusieurs flux RSS pour les nouveaux épisodes de vos séries préférées et saisira, sortes et les renomme. Il peut également être configuré pour mettre à jour automatiquement la qualité des fichiers déjà téléchargés si un meilleur format de qualité devient disponible.
DESCRIPTION_SPN = Sonarr es un PVR para los usuarios de grupos de noticias y torrents. Se puede controlar múltiples canales RSS para nuevos episodios de sus programas favoritos y se agarra, tipo y les cambia el nombre. También puede ser configurado para actualizar automáticamente la calidad de los archivos ya descargados si un formato de mejor calidad disponible.
DISPLAY_NAME = Sonarr
STARTABLE = yes
CHANGELOG = "Enlarge the service start/stop timeout to 90 seconds."
CHANGELOG = "1. Enlarge the service start/stop timeout to 90 seconds<br>2. Avoid Sonarr downgrade on package update<br>3. Implement fix for alternate TMP directory<br>4. Upgrade to Sonarr 4.0.0.87"

HOMEPAGE = https://sonarr.tv
LICENSE = GPLv3
Expand All @@ -35,6 +32,14 @@ POST_STRIP_TARGET = sonarr_extra_install

include ../../mk/spksrc.spk.mk

# use alternate TMPDIR as /tmp might be too small and not accessible on DSM >= 7.1.
USE_ALTERNATE_TMPDIR = 1

PACKAGE_VERSION = $(SPK_NAME_ARCH)-$(SPK_TCVERS)_$(SPK_VERS)-$(SPK_REV)
PACKAGE_AUTHOR = [SynoCommunity](https://synocommunity.com)

.PHONY: sonarr_extra_install
sonarr_extra_install:
install -m 755 -d $(STAGING_DIR)/app
install -m 755 -d $(STAGING_DIR)/var/.config/Sonarr
install -m 644 src/config.xml $(STAGING_DIR)/var/.config/Sonarr/config.xml
@echo "PackageVersion=$(PACKAGE_VERSION)\nPackageAuthor=$(PACKAGE_AUTHOR)" > $(STAGING_DIR)/share/Sonarr/package_info
7 changes: 7 additions & 0 deletions spk/sonarr/src/config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Config>
<Branch>main</Branch>
<LaunchBrowser>False</LaunchBrowser>
<UpdateAutomatically>True</UpdateAutomatically>
<UpdateMechanism>BuiltIn</UpdateMechanism>
</Config>
132 changes: 56 additions & 76 deletions spk/sonarr/src/service-setup.sh
Original file line number Diff line number Diff line change
@@ -1,104 +1,84 @@
PATH="${SYNOPKG_PKGDEST}/bin:${PATH}"
MONO_PATH="/var/packages/mono/target/bin"
MONO="${MONO_PATH}/mono"
SONARR="${SYNOPKG_PKGDEST}/share/Sonarr/bin/Sonarr"

# Sonarr uses the home directory to store it's ".config"
# Sonarr uses custom Config and PID directories
HOME_DIR="${SYNOPKG_PKGVAR}"
CONFIG_DIR="${SYNOPKG_PKGVAR}/.config"

# Sonarr v2 -> v3 compatibility:
if [ -f "${SYNOPKG_PKGDEST}/share/NzbDrone/NzbDrone.exe" ]; then
# v2 installed
SONARR="${SYNOPKG_PKGDEST}/share/NzbDrone/NzbDrone.exe"
PID_FILE="${CONFIG_DIR}/NzbDrone/nzbdrone.pid"
else
# v3 installed
SONARR="${SYNOPKG_PKGDEST}/share/Sonarr/Sonarr.exe"
PID_FILE="${CONFIG_DIR}/Sonarr/sonarr.pid"
fi

# Allow correct Sonarr SPK version checking (v2 or v3)
if [ -f "${SYNOPKG_PKGINST_TEMP_DIR}/share/NzbDrone/NzbDrone.exe" ]; then
# v2 SPK
SPK_SONARR="${SYNOPKG_PKGINST_TEMP_DIR}/share/NzbDrone/NzbDrone.exe"
else
# v3 SPK
SPK_SONARR="${SYNOPKG_PKGINST_TEMP_DIR}/share/Sonarr/Sonarr.exe"
fi
SONARR_CONFIG_DIR="${CONFIG_DIR}/Sonarr"
PID_FILE="${SONARR_CONFIG_DIR}/sonarr.pid"

# Some have it stored in the root of package
LEGACY_CONFIG_DIR="${SYNOPKG_PKGDEST}/.config"

# workaround for mono bug with armv5 (https://github.com/mono/mono/issues/12537)
if [ "$SYNOPKG_DSM_ARCH" == "88f6281" -o "$SYNOPKG_DSM_ARCH" == "88f6282" ]; then
MONO="MONO_ENV_OPTIONS='-O=-aot,-float32' ${MONO}"
fi

# for DSM < 7 only:
GROUP="sc-download"
LEGACY_GROUP="sc-media"

SERVICE_COMMAND="env PATH=${MONO_PATH}:${PATH} HOME=${HOME_DIR} LD_LIBRARY_PATH=${SYNOPKG_PKGDEST}/lib ${MONO} ${SONARR}"
SERVICE_COMMAND="env HOME=${HOME_DIR} LD_LIBRARY_PATH=${SYNOPKG_PKGDEST}/lib ${SONARR}"
SVC_BACKGROUND=y
SVC_WAIT_TIMEOUT=90

validate_preinst ()
{
# use install_log to write to installer log file.
install_log "validate_preinst ${SYNOPKG_PKG_STATUS}"

# check if the installed distribution is a legacy version
if [ -f "${SYNOPKG_PKGDEST}/share/NzbDrone/NzbDrone.exe" ]; then
# v2 installed
exit 1
fi
}

service_postinst ()
{
mkdir -p ${CONFIG_DIR}
set_unix_permissions "${CONFIG_DIR}"
echo "Set update required"
# Make Sonarr do an update check on start to avoid possible Sonarr
# downgrade when synocommunity package is updated
touch "${SONARR_CONFIG_DIR}/update_required"

if [ "${SYNOPKG_DSM_VERSION_MAJOR}" -lt 7 ]; then
set_unix_permissions "${CONFIG_DIR}"
fi
}

service_preupgrade ()
{
# We have to account for legacy folder in the root
# It should go, after the upgrade, into /var/.config/
# The /var/ folder gets automatically copied by service-installer after this
if [ -d "${LEGACY_CONFIG_DIR}" ]; then
echo "Moving ${LEGACY_CONFIG_DIR} to ${CONFIG_DIR}"
mv ${LEGACY_CONFIG_DIR} ${CONFIG_DIR} >> ${INST_LOG} 2>&1
fi
if [ ! -d ${CONFIG_DIR} ]; then
# Create, in case it's missing for some reason
mkdir -p ${CONFIG_DIR} >> ${INST_LOG} 2>&1
if [ "${SYNOPKG_DSM_VERSION_MAJOR}" -ge 7 ]; then
# ensure config is in @appdata folder
if [ -d "${LEGACY_CONFIG_DIR}" ]; then
if [ "$(realpath "${LEGACY_CONFIG_DIR}")" != "$(realpath "${CONFIG_DIR}")" ]; then
echo "Move ${LEGACY_CONFIG_DIR} to ${CONFIG_DIR}"
mv "${LEGACY_CONFIG_DIR}" "${CONFIG_DIR}" 2>&1
fi
fi
fi

# Is Installed Sonarr Binary Ver. >= SPK Sonarr Binary Ver.?
CUR_VER=$(${MONO_PATH}/monodis --assembly ${SONARR} | grep "Version:" | awk '{print $2}')
echo "Installed Sonarr Binary: ${CUR_VER}"
SPK_VER=$(${MONO_PATH}/monodis --assembly ${SPK_SONARR} | grep "Version:" | awk '{print $2}')
echo "Requested Sonarr Binary: ${SPK_VER}"
function version_compare() { test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"; }
if version_compare $CUR_VER $SPK_VER; then
echo 'KEEP_CUR="yes"' > ${CONFIG_DIR}/KEEP_VAR
echo "[KEEPING] Installed Sonarr Binary - Upgrading Package Only"
mv ${SYNOPKG_PKGDEST}/share ${SYNOPKG_PKGVAR}
else
echo 'KEEP_CUR="no"' > ${CONFIG_DIR}/KEEP_VAR
echo "[REPLACING] Installed Sonarr Binary"
fi
# never update Sonarr distribution, use internal updater only
[ -d "${SYNOPKG_TEMP_UPGRADE_FOLDER}/backup" ] && rm -rf "${SYNOPKG_TEMP_UPGRADE_FOLDER}/backup"
echo "Backup existing distribution to ${SYNOPKG_TEMP_UPGRADE_FOLDER}/backup"
mkdir -p "${SYNOPKG_TEMP_UPGRADE_FOLDER}/backup" 2>&1
rsync -aX "${SYNOPKG_PKGDEST}/share" "${SYNOPKG_TEMP_UPGRADE_FOLDER}/backup/" 2>&1
}

service_postupgrade ()
{
# Restore Current Sonarr Binary If Current Ver. >= SPK Ver.
. ${CONFIG_DIR}/KEEP_VAR
if [ "$KEEP_CUR" == "yes" ]; then
echo "Restoring Sonarr version from before upgrade"
rm -fr ${SYNOPKG_PKGDEST}/share
mv ${SYNOPKG_PKGVAR}/share ${SYNOPKG_PKGDEST}/
set_unix_permissions "${SYNOPKG_PKGDEST}/share"
# restore Sonarr distribution
if [ -d "${SYNOPKG_TEMP_UPGRADE_FOLDER}/backup/share" ]; then
echo "Restore previous distribution from ${SYNOPKG_TEMP_UPGRADE_FOLDER}/backup"
rm -rf "${SYNOPKG_PKGDEST}/share/Sonarr/bin" 2>&1
# prevent overwrite of updated package_info
rsync -aX --exclude=package_info "${SYNOPKG_TEMP_UPGRADE_FOLDER}/backup/share/" "${SYNOPKG_PKGDEST}/share" 2>&1
fi

set_unix_permissions "${CONFIG_DIR}"

# If backup was created before new-style packages
# new updates/backups will fail due to permissions (see #3185)
if [ -d "/tmp/nzbdrone_backup" ] || [ -d "/tmp/nzbdrone_update" ] || [ -d "/tmp/sonarr_backup" ] || [ -d "/tmp/sonarr_update" ]; then
set_unix_permissions "/tmp/nzbdrone_backup"
set_unix_permissions "/tmp/nzbdrone_update"
set_unix_permissions "/tmp/sonarr_backup"
set_unix_permissions "/tmp/sonarr_update"
if [ "${SYNOPKG_DSM_VERSION_MAJOR}" -lt 7 ]; then
set_unix_permissions "${SYNOPKG_PKGDEST}/share"
# If backup was created before new-style packages
# new updates/backups will fail due to permissions (see #3185)
if [ -d "/tmp/nzbdrone_backup" ] || [ -d "/tmp/nzbdrone_update" ] || [ -d "/tmp/sonarr_backup" ] || [ -d "/tmp/sonarr_update" ]; then
set_unix_permissions "/tmp/nzbdrone_backup"
set_unix_permissions "/tmp/nzbdrone_update"
set_unix_permissions "/tmp/sonarr_backup"
set_unix_permissions "/tmp/sonarr_update"
fi
fi

# Remove upgrade Flag
rm ${CONFIG_DIR}/KEEP_VAR
}
}
Binary file modified spk/sonarr/src/sonarr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit cae96ef

Please sign in to comment.