From 4e232c39be37bb4c3c45b5ab810775e7dd905aa0 Mon Sep 17 00:00:00 2001 From: Joakim Hulthe Date: Thu, 9 Apr 2026 21:16:08 +0200 Subject: [PATCH] Include install-scripts --- mullvad-vpn-daemon/APKBUILD | 18 ++++---- .../mullvad-vpn-daemon.post-deinstall | 42 +++---------------- .../mullvad-vpn-daemon.post-install | 12 +++--- .../mullvad-vpn-daemon.post-upgrade | 10 +++++ .../mullvad-vpn-daemon.pre-deinstall | 4 +- ...install => mullvad-vpn-daemon.pre-upgrade} | 2 +- 6 files changed, 36 insertions(+), 52 deletions(-) create mode 100644 mullvad-vpn-daemon/mullvad-vpn-daemon.post-upgrade rename mullvad-vpn-daemon/{mullvad-vpn-daemon.pre-install => mullvad-vpn-daemon.pre-upgrade} (88%) diff --git a/mullvad-vpn-daemon/APKBUILD b/mullvad-vpn-daemon/APKBUILD index 2c59bbc..70f4bc8 100644 --- a/mullvad-vpn-daemon/APKBUILD +++ b/mullvad-vpn-daemon/APKBUILD @@ -24,9 +24,7 @@ makedepends=" libnftnl-dev " checkdepends="" -# TODO: pre/post(de)install-scripts -#install="$pkgname.pre-install $pkgname.post-install $pkgname.pre-deinstall $pkgname.post-deinstall" -install="" +install="$pkgname.post-install $pkgname.pre-upgrade $pkgname.post-upgrade $pkgname.pre-deinstall $pkgname.post-deinstall" subpackages="$pkgname-systemd" source="" builddir="$srcdir/" @@ -49,10 +47,11 @@ build() { # * Specify `--target` so that the final binary ends up in target//release. cargo auditable build --release --locked \ --target "$CHOST" \ - -p mullvad-daemon \ -p mullvad-cli \ + -p mullvad-daemon \ -p mullvad-exclude \ - -p mullvad-problem-report + -p mullvad-problem-report \ + -p mullvad-setup } check() { @@ -61,18 +60,21 @@ check() { } package() { - install -m755 -D "$_cargo_target_dir/$CHOST/release/mullvad-daemon" \ - "$pkgdir"/usr/bin/mullvad-daemon - install -m755 -D "$_cargo_target_dir/$CHOST/release/mullvad" \ "$pkgdir"/usr/bin/mullvad + install -m755 -D "$_cargo_target_dir/$CHOST/release/mullvad-daemon" \ + "$pkgdir"/usr/bin/mullvad-daemon + install -m755 -D "$_cargo_target_dir/$CHOST/release/mullvad-exclude" \ "$pkgdir"/usr/bin/mullvad-exclude chmod u+s "$pkgdir"/usr/bin/mullvad-exclude install -m755 -D "$_cargo_target_dir/$CHOST/release/mullvad-problem-report" \ "$pkgdir"/usr/bin/mullvad-problem-report + + install -m755 -D "$_cargo_target_dir/$CHOST/release/mullvad-setup" \ + "$pkgdir"/usr/bin/mullvad-setup } systemd() { diff --git a/mullvad-vpn-daemon/mullvad-vpn-daemon.post-deinstall b/mullvad-vpn-daemon/mullvad-vpn-daemon.post-deinstall index 64f821d..08e399c 100644 --- a/mullvad-vpn-daemon/mullvad-vpn-daemon.post-deinstall +++ b/mullvad-vpn-daemon/mullvad-vpn-daemon.post-deinstall @@ -1,39 +1,9 @@ #!/usr/bin/env bash set -eu -function remove_logs_and_cache { - rm -r --interactive=never /var/log/mullvad-vpn/ || \ - echo "Failed to remove mullvad-vpn logs" - rm -r --interactive=never /var/cache/mullvad-vpn/ || \ - echo "Failed to remove mullvad-vpn cache" -} - -function remove_config { - rm -r --interactive=never /etc/mullvad-vpn || \ - echo "Failed to remove mullvad-vpn config" -} - -function remove_symlinks { - rm /usr/bin/mullvad-problem-report || \ - echo "Failed to remove mullvad-problem-report" -} - -# checking what kind of an action is taking place -case $@ in - # apt purge passes "purge" - "purge") - remove_logs_and_cache - remove_config - remove_symlinks - ;; - # apt remove passes "remove" - "remove") - remove_symlinks - ;; - # dnf remove passes a 0 - "0") - remove_logs_and_cache - remove_config - remove_symlinks - ;; -esac +rm -r --interactive=never /var/log/mullvad-vpn/ || \ + echo "Failed to remove mullvad-vpn logs" +rm -r --interactive=never /var/cache/mullvad-vpn/ || \ + echo "Failed to remove mullvad-vpn cache" +rm -r --interactive=never /etc/mullvad-vpn || \ + echo "Failed to remove mullvad-vpn config" diff --git a/mullvad-vpn-daemon/mullvad-vpn-daemon.post-install b/mullvad-vpn-daemon/mullvad-vpn-daemon.post-install index f1952a9..23a3b59 100644 --- a/mullvad-vpn-daemon/mullvad-vpn-daemon.post-install +++ b/mullvad-vpn-daemon/mullvad-vpn-daemon.post-install @@ -1,8 +1,10 @@ #!/usr/bin/env bash set -eu -ln -sf /opt/Mullvad\ VPN/resources/mullvad-problem-report /usr/bin/mullvad-problem-report - -systemctl enable "/usr/lib/systemd/system/mullvad-daemon.service" -systemctl start mullvad-daemon.service || echo "Failed to start mullvad-daemon.service" -systemctl enable "/usr/lib/systemd/system/mullvad-early-boot-blocking.service" +if which systemctl &> /dev/null && systemctl is-system-running | grep -vq offline &> /dev/null; then + if systemctl status mullvad-daemon &> /dev/null; then + systemctl enable "/usr/lib/systemd/system/mullvad-daemon.service" + systemctl start mullvad-daemon.service || echo "Failed to start mullvad-daemon.service" + systemctl enable "/usr/lib/systemd/system/mullvad-early-boot-blocking.service" + fi +fi diff --git a/mullvad-vpn-daemon/mullvad-vpn-daemon.post-upgrade b/mullvad-vpn-daemon/mullvad-vpn-daemon.post-upgrade new file mode 100644 index 0000000..23a3b59 --- /dev/null +++ b/mullvad-vpn-daemon/mullvad-vpn-daemon.post-upgrade @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +set -eu + +if which systemctl &> /dev/null && systemctl is-system-running | grep -vq offline &> /dev/null; then + if systemctl status mullvad-daemon &> /dev/null; then + systemctl enable "/usr/lib/systemd/system/mullvad-daemon.service" + systemctl start mullvad-daemon.service || echo "Failed to start mullvad-daemon.service" + systemctl enable "/usr/lib/systemd/system/mullvad-early-boot-blocking.service" + fi +fi diff --git a/mullvad-vpn-daemon/mullvad-vpn-daemon.pre-deinstall b/mullvad-vpn-daemon/mullvad-vpn-daemon.pre-deinstall index f164013..ce6973b 100644 --- a/mullvad-vpn-daemon/mullvad-vpn-daemon.pre-deinstall +++ b/mullvad-vpn-daemon/mullvad-vpn-daemon.pre-deinstall @@ -19,5 +19,5 @@ systemctl disable mullvad-daemon.service || true systemctl stop mullvad-early-boot-blocking.service || true systemctl disable mullvad-early-boot-blocking.service || true -/opt/Mullvad\ VPN/resources/mullvad-setup reset-firewall || echo "Failed to reset firewall" -/opt/Mullvad\ VPN/resources/mullvad-setup remove-device || echo "Failed to remove device from account" +mullvad-setup reset-firewall || echo "Failed to reset firewall" +mullvad-setup remove-device || echo "Failed to remove device from account" diff --git a/mullvad-vpn-daemon/mullvad-vpn-daemon.pre-install b/mullvad-vpn-daemon/mullvad-vpn-daemon.pre-upgrade similarity index 88% rename from mullvad-vpn-daemon/mullvad-vpn-daemon.pre-install rename to mullvad-vpn-daemon/mullvad-vpn-daemon.pre-upgrade index 7d380d3..65d32c9 100644 --- a/mullvad-vpn-daemon/mullvad-vpn-daemon.pre-install +++ b/mullvad-vpn-daemon/mullvad-vpn-daemon.pre-upgrade @@ -3,7 +3,7 @@ set -eu if which systemctl &> /dev/null && systemctl is-system-running | grep -vq offline &> /dev/null; then if systemctl status mullvad-daemon &> /dev/null; then - /opt/Mullvad\ VPN/resources/mullvad-setup prepare-restart || true + mullvad-setup prepare-restart || true systemctl stop mullvad-daemon.service systemctl disable mullvad-daemon.service systemctl disable mullvad-early-boot-blocking.service || true