Fix install-scripts, and bundle relay list

This commit is contained in:
Joakim Hulthe
2026-04-20 22:28:17 +02:00
committed by Joakim Hulthe
parent 29043fedc1
commit 7af09af8d1
7 changed files with 55 additions and 28 deletions

View File

@@ -24,7 +24,15 @@ makedepends="
libnftnl-dev libnftnl-dev
" "
checkdepends="" checkdepends=""
install="$pkgname.post-install $pkgname.pre-upgrade $pkgname.post-upgrade $pkgname.pre-deinstall $pkgname.post-deinstall" install="
$pkgname.post-install
$pkgname.pre-upgrade
$pkgname.post-upgrade
$pkgname.pre-deinstall
$pkgname.post-deinstall
$pkgname-systemd.post-install
$pkgname-systemd.post-upgrade
"
subpackages="$pkgname-systemd" subpackages="$pkgname-systemd"
source="" source=""
builddir="$srcdir/" builddir="$srcdir/"
@@ -44,6 +52,8 @@ build() {
# Specify `--target` so that the build artifacts ends up in target/<target>/release to # Specify `--target` so that the build artifacts ends up in target/<target>/release to
# avoid clashes with host system when running in a container with a mounted target folder. # avoid clashes with host system when running in a container with a mounted target folder.
# Compile all binaries
cargo auditable build --release --locked \ cargo auditable build --release --locked \
--target "$CHOST" \ --target "$CHOST" \
-p mullvad-cli \ -p mullvad-cli \
@@ -51,6 +61,12 @@ build() {
-p mullvad-exclude \ -p mullvad-exclude \
-p mullvad-problem-report \ -p mullvad-problem-report \
-p mullvad-setup -p mullvad-setup
# Generate vendored relay list
cargo run --release --locked \
-p mullvad-api --bin relay_list \
--target "$CHOST" \
> "$builddir/relays.json"
} }
check() { check() {
@@ -74,6 +90,10 @@ package() {
install -m755 -D "$_cargo_target_dir/$CHOST/release/mullvad-setup" \ install -m755 -D "$_cargo_target_dir/$CHOST/release/mullvad-setup" \
"$pkgdir"/usr/bin/mullvad-setup "$pkgdir"/usr/bin/mullvad-setup
# Bundle the vendored relay list. It's copied to /var/cache/mullvad-vpn/ by the post-* scripts.
install -m644 -D "$builddir/relays.json" \
"$pkgdir"/usr/share/mullvad-vpn/relays.json
} }
systemd() { systemd() {

View File

@@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -eu
# Are we running systemd?
if which systemctl &> /dev/null && systemctl is-system-running | grep -vq offline &> /dev/null; then
# Does `mullvad-daemon.service` exist?
if systemctl list-unit-files mullvad-daemon.service &> /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

View File

@@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -eu
# Are we running systemd?
if which systemctl &> /dev/null && systemctl is-system-running | grep -vq offline &> /dev/null; then
# Does `mullvad-daemon.service` exist?
if systemctl list-unit-files mullvad-daemon.service &> /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

View File

@@ -1,10 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -eu set -eu
if which systemctl &> /dev/null && systemctl is-system-running | grep -vq offline &> /dev/null; then # Overwrite the cached relay list with the one embedded in the package.
if systemctl status mullvad-daemon &> /dev/null; then mkdir -p /var/cache/mullvad-vpn \
systemctl enable "/usr/lib/systemd/system/mullvad-daemon.service" && cp /usr/share/mullvad-vpn/relays.json /var/cache/mullvad-vpn/relays.json \
systemctl start mullvad-daemon.service || echo "Failed to start mullvad-daemon.service" || echo "failed to install /var/cache/mullvad-vpn/relays.json"
systemctl enable "/usr/lib/systemd/system/mullvad-early-boot-blocking.service"
fi
fi

View File

@@ -1,10 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -eu set -eu
if which systemctl &> /dev/null && systemctl is-system-running | grep -vq offline &> /dev/null; then # Overwrite the cached relay list with the one embedded in the package.
if systemctl status mullvad-daemon &> /dev/null; then mkdir /var/cache/mullvad-vpn
systemctl enable "/usr/lib/systemd/system/mullvad-daemon.service" cp /usr/share/mullvad-vpn/relays.json /var/cache/mullvad-vpn/relays.json
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

View File

@@ -1,18 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -eu set -eu
echo "Running prerm."
is_number_re='^[0-9]+$'
# Check if we're running during an upgrade step on Fedora
# https://fedoraproject.org/wiki/Packaging:Scriptlets#Syntax
if [[ "$1" =~ $is_number_re ]] && [ "$1" -gt 0 ]; then
exit 0;
fi
if [[ "$1" == "upgrade" ]]; then
exit 0;
fi
# the user might've disabled or stopped the service themselves already # the user might've disabled or stopped the service themselves already
systemctl stop mullvad-daemon.service || true systemctl stop mullvad-daemon.service || true
systemctl disable mullvad-daemon.service || true systemctl disable mullvad-daemon.service || true

View File

@@ -1,7 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -eu set -eu
# Are we running systemd?
if which systemctl &> /dev/null && systemctl is-system-running | grep -vq offline &> /dev/null; then if which systemctl &> /dev/null && systemctl is-system-running | grep -vq offline &> /dev/null; then
# Is `mullvad-daemon.service` running?
if systemctl status mullvad-daemon &> /dev/null; then if systemctl status mullvad-daemon &> /dev/null; then
mullvad-setup prepare-restart || true mullvad-setup prepare-restart || true
systemctl stop mullvad-daemon.service systemctl stop mullvad-daemon.service
@@ -12,5 +14,5 @@ if which systemctl &> /dev/null && systemctl is-system-running | grep -vq offlin
fi fi
fi fi
rm -f /var/cache/mullvad-vpn/relays.json # Since we are upgrading mullvad-daemon, it will probably have current IP baked into itself.
rm -f /var/cache/mullvad-vpn/api-ip-address.txt rm -f /var/cache/mullvad-vpn/api-ip-address.txt