Skip to content
New issue

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

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

Already on GitHub? # to your account

Lidarr: avoid downgrade on package updates #5485

Merged
merged 4 commits into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions cross/lidarr-mono/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ PKG_DIST_NAME = $(PKG_NAME).develop.$(PKG_VERS).linux.$(PKG_EXT)
PKG_DIST_SITE = https://github.com/Lidarr/Lidarr/releases/download/v$(PKG_VERS)
PKG_DIR = Lidarr

# REMARKS: outdated version, not supported anymore

DEPENDS =

HOMEPAGE = https://lidarr.audio/
Expand Down
27 changes: 6 additions & 21 deletions spk/lidarr/Makefile
Original file line number Diff line number Diff line change
@@ -1,27 +1,23 @@
SPK_NAME = lidarr
SPK_VERS = $(shell date +%Y%m%d)
SPK_REV = 9
SPK_REV = 10
SPK_ICON = src/lidarr.png

DEPENDS = cross/lidarr cross/libstdc++ cross/sqlite

UNSUPPORTED_ARCHS = $(DOTNET_UNSUPPORTED_ARCHS)

MAINTAINER = Team Lidarr
MAINTAINER_URL = https://lidarr.audio/
DESCRIPTION = Lidarr is a music collection manager for Usenet and BitTorrent users. It can monitor multiple RSS feeds for new tracks from your favorite artists and will grab, sort and rename them. It can also be configured to automatically upgrade the quality of files already downloaded when a better quality format becomes available.
CHANGELOG = "1. Update Lidarr to v1.0.2.<br/>2. Use alternate TMP directory to provide enough space for internal updater.<br/>3. Enlarge the service start/stop timeout to 90 seconds."
CHANGELOG = "1. Update Lidarr to v1.0.2.<br/>2. Use alternate TMP directory to provide enough space for internal updater.<br/>3. Enlarge the service start/stop timeout to 90 seconds.<br/>4. Avoid Lidarr downgrade on package update."
DISPLAY_NAME = Lidarr
HOMEPAGE = https://lidarr.audio/
LICENSE = GPLv3
LICENSE_FILE = $(WORK_DIR)/Lidarr/LICENSE.md
HELPURL = https://wiki.servarr.com/Lidarr_Troubleshooting
SUPPORTURL = https://lidarr.audio/\#support

REQUIRED_MIN_DSM = 5.0

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

OPTIONAL_DEPENDS = cross/libstdc++ cross/$(SPK_NAME) cross/$(SPK_NAME)-mono
DEPENDS = cross/sqlite

STARTABLE = yes
SERVICE_USER = auto
SERVICE_SETUP = src/service-setup.sh
Expand All @@ -33,17 +29,6 @@ ADMIN_PORT = $(SERVICE_PORT)

WIZARDS_DIR = src/wizard/

# Mono build for unsupported .NET archs
include ../../mk/spksrc.archs.mk
ifeq ($(findstring $(ARCH),$(ARMv5_ARCHS) $(i686_ARCHS) $(ARMv7L_ARCHS)),$(ARCH))
DEPENDS += cross/$(SPK_NAME)-mono
SERVICE_SETUP = src/service-setup-mono.sh
CHANGELOG = "Enlarge the service start/stop timeout to 90 seconds."
SPK_DEPENDS = "mono>3.6:chromaprint>=1.5"
else
DEPENDS += cross/libstdc++ cross/$(SPK_NAME)
endif

POST_STRIP_TARGET = lidarr_extra_install

# use alternate TMPDIR as /tmp might be too small and not accessible on DSM >= 7.1.
Expand Down
Binary file modified spk/lidarr/src/lidarr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion spk/lidarr/src/service-setup-mono.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# REMARKS: outdated, not used anymore

PATH="${SYNOPKG_PKGDEST}/bin:/var/packages/chromaprint/target/bin/:${PATH}"
MONO_PATH="/var/packages/mono/target/bin"
MONO="${MONO_PATH}/mono"
Expand All @@ -23,7 +25,7 @@ GROUP="sc-download"

SERVICE_COMMAND="env PATH=${MONO_PATH}:${PATH} HOME=${HOME_DIR} LD_LIBRARY_PATH=${SYNOPKG_PKGDEST}/lib ${MONO} ${LIDARR}"
SVC_BACKGROUND=y
SVC_WAIT_TIMEOUT=60
SVC_WAIT_TIMEOUT=90
hgy59 marked this conversation as resolved.
Show resolved Hide resolved

service_postinst ()
{
Expand Down
56 changes: 35 additions & 21 deletions spk/lidarr/src/service-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ LIDARR="${SYNOPKG_PKGDEST}/share/Lidarr/bin/Lidarr"
# Lidarr uses custom Config and PID directories
HOME_DIR="${SYNOPKG_PKGVAR}"
CONFIG_DIR="${SYNOPKG_PKGVAR}/.config"
PID_FILE="${CONFIG_DIR}/Lidarr/lidarr.pid"
LIDARR_CONFIG_DIR="${CONFIG_DIR}/Lidarr"
PID_FILE="${LIDARR_CONFIG_DIR}/lidarr.pid"

# Some have it stored in the root of package
# Older installations have it in the wrong place for DSM 7
LEGACY_CONFIG_DIR="${SYNOPKG_PKGDEST}/.config"

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

SERVICE_COMMAND="env HOME=${HOME_DIR} LD_LIBRARY_PATH=${SYNOPKG_PKGDEST}/lib ${LIDARR}"
Expand All @@ -17,33 +19,45 @@ SVC_WAIT_TIMEOUT=90
service_postinst ()
{
# Move config.xml to .config
mkdir -p ${CONFIG_DIR}/Lidarr
mv ${SYNOPKG_PKGDEST}/app/config.xml ${CONFIG_DIR}/Lidarr/config.xml
set_unix_permissions "${CONFIG_DIR}"
mkdir -p ${LIDARR_CONFIG_DIR}
mv ${SYNOPKG_PKGDEST}/app/config.xml ${LIDARR_CONFIG_DIR}/config.xml

echo "Set update required"
# Make Lidarr do an update check on start to avoid possible Lidarr
# downgrade when synocommunity package is updated
touch ${LIDARR_CONFIG_DIR}/update_required
hgy59 marked this conversation as resolved.
Show resolved Hide resolved

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 ${SYNOPKG_PKGVAR}"
mv ${LEGACY_CONFIG_DIR} ${SYNOPKG_PKGVAR}
fi

if [ ! -d "${CONFIG_DIR}" ]; then
# Create, in case it's missing for some reason
mkdir -p ${CONFIG_DIR}
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

## never update Lidarr 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 ()
{
# Make Lidarr do an update check on start to avoid possible Lidarr
# downgrade when synocommunity package is updated
touch ${CONFIG_DIR}/Lidarr/update_required

set_unix_permissions "${CONFIG_DIR}"
## restore Lidarr 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/Lidarr/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
}