From e5e2e97910af8e9bc41a79d2bb311e112da0d862 Mon Sep 17 00:00:00 2001 From: ed Date: Sun, 6 Sep 2026 22:08:42 +0000 Subject: [PATCH] archlinux: add post_upgrade --- contrib/package/arch/PKGBUILD | 8 ++++---- contrib/package/arch/copyparty.install | 27 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 contrib/package/arch/copyparty.install diff --git a/contrib/package/arch/PKGBUILD b/contrib/package/arch/PKGBUILD index c714a9b75..25fd0d607 100644 --- a/contrib/package/arch/PKGBUILD +++ b/contrib/package/arch/PKGBUILD @@ -24,7 +24,8 @@ optdepends=("ffmpeg: thumbnails for videos, images (slower) and audio, music tag "python-argon2-cffi: hashed passwords in config" ) source=("https://github.com/9001/${pkgname}/releases/download/v${pkgver}/${pkgname}-${pkgver}.tar.gz") -backup=("etc/${pkgname}/copyparty.conf" ) +backup=("etc/copyparty.conf") +install=copyparty.install sha256sums=("14d590644943c3ed14e21093cce79e06f1ae206adeeda16032d15a7241ff4344") build() { @@ -36,12 +37,11 @@ package() { cd "${srcdir}/${pkgname}-${pkgver}" python -m installer --destdir="$pkgdir" dist/*.whl - install -dm755 "${pkgdir}/etc/${pkgname}" install -Dm755 "bin/prisonparty.sh" "${pkgdir}/usr/bin/prisonparty" - install -Dm644 "contrib/systemd/${pkgname}.conf" "${pkgdir}/etc/${pkgname}/copyparty.conf" + install -Dm644 "contrib/systemd/${pkgname}.conf" "${pkgdir}/etc/copyparty.conf" install -Dm644 "contrib/systemd/${pkgname}@.service" "${pkgdir}/usr/lib/systemd/system/${pkgname}@.service" install -Dm644 "contrib/systemd/${pkgname}-user.service" "${pkgdir}/usr/lib/systemd/user/${pkgname}.service" install -Dm644 "contrib/systemd/prisonparty@.service" "${pkgdir}/usr/lib/systemd/system/prisonparty@.service" - install -Dm644 "contrib/systemd/index.md" "${pkgdir}/var/lib/${pkgname}-jail/README.md" + install -Dm644 "contrib/systemd/index.md" "${pkgdir}/var/lib/${pkgname}-jail/srv/README.md" install -Dm644 "LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE" } diff --git a/contrib/package/arch/copyparty.install b/contrib/package/arch/copyparty.install new file mode 100644 index 000000000..c20936ccc --- /dev/null +++ b/contrib/package/arch/copyparty.install @@ -0,0 +1,27 @@ +post_upgrade() { + + # v1.20.22 moved the config-file, affecting the system-service only + if [[ $(vercmp "$2" 1.20.22) -lt 0 ]]; then + + oldpath="/etc/copyparty/copyparty.conf" + newpath="/etc/copyparty.conf" + + echo "==> Migrating config-file from $oldpath to $newpath" + + if [[ ! -f "$oldpath" ]]; then + oldpath="$oldpath.pacsave" + fi + + if [[ -f "$newpath.pacnew" ]]; then + echo "==> WARNING: A config-file already existed in the new location [$newpath]. The existing file will be used as-is." + + elif [[ -f "$oldpath" ]]; then + mv -v "$oldpath" "$newpath" + rmdir /etc/copyparty 2>/dev/null || true + fi + + systemctl cat copyparty@.service | awk '/=PRTY_CONFIG=/ && !/=\/etc\/copyparty.conf/ {exit 1}' || { + echo "==> WARNING: The copyparty system-service has been edited by hand since installation, so it will not read config from the new default config path [$newpath]. Please use PRTY_CONFIG=$newpath if that is correct for your setup." + } + fi +}