summaryrefslogtreecommitdiff
path: root/net-vpn/mullvadvpn-app/mullvadvpn-app-2026.5.ebuild
blob: bdbf512a7a9c8e4167a7a39935dc4ac415219971 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

RPM_COMPRESS_TYPE="xz"
inherit desktop rpm systemd shell-completion xdg

MYPV="${PV/_beta/-beta}"
DESCRIPTION="Tool used to manage daemon setup"
HOMEPAGE="https://github.com/mullvad/mullvadvpn-app https://mullvad.net/"
SRC_URI="
	amd64? ( https://github.com/mullvad/mullvadvpn-app/releases/download/${MYPV}/MullvadVPN-${MYPV}_x86_64.rpm )
	arm64? ( https://github.com/mullvad/mullvadvpn-app/releases/download/${MYPV}/MullvadVPN-${MYPV}_aarch64.rpm )
"

S="${WORKDIR}"
LICENSE="GPL-3"
SLOT="0"

# Betas are kept unkeyworded; users can opt in to testing by accepting '**' instead of '~amd64'/
# '~arm64' keywords.
#
# See https://bugs.gentoo.org/966989
if [[ "${PV}" != *_beta* ]]; then
	KEYWORDS="-* ~amd64 ~arm64"
fi

RESTRICT="bindist mirror strip"

RDEPEND="
	app-accessibility/at-spi2-core:2
	dev-libs/expat
	dev-libs/glib:2
	dev-libs/nspr
	dev-libs/nss
	media-libs/alsa-lib
	media-libs/mesa
	net-print/cups
	sys-apps/dbus
	x11-libs/cairo
	x11-libs/gtk+:3
	x11-libs/libdrm
	x11-libs/libX11
	x11-libs/libxcb
	x11-libs/libXcomposite
	x11-libs/libXdamage
	x11-libs/libXext
	x11-libs/libXfixes
	x11-libs/libxkbcommon
	x11-libs/libXrandr
	x11-libs/pango
	|| (
		net-firewall/nftables
		net-firewall/iptables[nftables]
	)
"

QA_PREBUILT="*"

src_install() {
	sed -i "s|SCRIPT_DIR=.*|SCRIPT_DIR=\"/opt/Mullvad VPN/\"|g" "${S}/opt/Mullvad VPN/mullvad-vpn" || die

	# Using doins -r would strip executable bits from all binaries
	cp -pPR opt "${D}"/ || die "Failed to copy files"
	fperms +x "/opt/Mullvad VPN/chrome_crashpad_handler"
	fperms 4755 "/opt/Mullvad VPN/chrome-sandbox"

	dobin ./usr/bin/mullvad
	dobin ./usr/bin/mullvad-daemon
	dobin ./usr/bin/mullvad-exclude
	dosym -r "/opt/Mullvad VPN/mullvad-vpn" /usr/bin/mullvad-vpn
	dosym -r "/opt/Mullvad VPN/resources/mullvad-problem-report" /usr/bin/mullvad-problem-report

	# mullvad-exclude uses cgroups to manage exclusions, which requires root permissions, but is
	# also most often used to exclude graphical applications which can't or shouldn't run as root
	# (i.e., can't be run under `sudo/doas /usr/bin/mullvad-exclude ...`, because `sudo`/`doas`
	# change user). The setuid bit allows any user to exclude executables under their own UID.
	fperms 4755 /usr/bin/mullvad-exclude

	newinitd "${FILESDIR}"/mullvad-daemon.initd mullvad-daemon

	systemd_newunit ./usr/lib/systemd/system/mullvad-daemon.service mullvad-daemon.service
	systemd_newunit ./usr/lib/systemd/system/mullvad-early-boot-blocking.service mullvad-early-boot-blocking.service

	newbashcomp ./usr/share/bash-completion/completions/mullvad mullvad
	newfishcomp ./usr/share/fish/vendor_completions.d/mullvad.fish mullvad
	newzshcomp ./usr/share/zsh/site-functions/_mullvad _mullvad

	domenu ./usr/share/applications/mullvad-vpn.desktop
	local x
	for x in 16 32 48 64 128 256 512; do
		doicon -s "${x}" "./usr/share/icons/hicolor/${x}x${x}/apps/mullvad-vpn.png"
	done
}

pkg_postrm() {
	xdg_pkg_postrm

	if [[ -z ${REPLACED_BY_VERSION} ]]; then
		if ! command -v pgrep &>/dev/null || pgrep -f "mullvad-(daemon|gui)"; then
			elog "Mullvad has been uninstalled. To stop the service,"
			elog "1. Quit the Mullvad app"
			elog "   * Manually: 'Disconnect & quit' from the Mullvad menu"
			elog "     OR"
			elog "   * Command line: pkill -f mullvad-gui"
			elog "2. Stop the daemon"
			elog "   * OpenRC: rc-service mullvad-daemon stop"
			elog "     OR"
			elog "   * systemd: systemctl stop mullvad-daemon"
			elog "     OR"
			elog "   * other: pkill -f mullvad-daemon"
		fi
	fi
}

pkg_postinst() {
	xdg_pkg_postinst

	if [[ -n ${REPLACING_VERSIONS} ]]; then
		if command -v pgrep &>/dev/null && pgrep -f "mullvad-(daemon|gui)" &>/dev/null; then
			elog "Mullvad has been updated. To restart the service,"
			elog "1. Restart the daemon"
			elog "   * OpenRC: rc-service mullvad-daemon restart"
			elog "     OR"
			elog "   * systemd: systemctl restart mullvad-daemon"
			elog "2. Restart the app"
			elog "   * Manually: 'Disconnect & quit' from the Mullvad menu and relaunch using"
			elog "               your preferred desktop launcher"
			elog "     OR"
			elog "   * Command line: pkill -f mullvad-gui && '/opt/Mullvad VPN/mullvad-vpn' & disown"
		else
			elog "Mullvad has been updated. To start the service,"
			elog "1. Start the daemon"
			elog "   * OpenRC: rc-service mullvad-daemon start"
			elog "     OR"
			elog "   * systemd: systemctl start mullvad-daemon"
			elog "2. Launch the app"
			elog "   * Manually: use your preferred desktop launcher"
			elog "     OR"
			elog "   * Command line: '/opt/Mullvad VPN/mullvad-vpn' & disown"
		fi
	else
		elog "Mullvad has been installed. To start the service,"
		elog "1. Enable and start the daemon"
		elog "   * OpenRC: rc-update add mullvad-daemon default"
		elog "             rc-service mullvad-daemon start"
		elog "     OR"
		elog "   * systemd: systemctl enable mullvad-daemon"
		elog "              systemctl start mullvad-daemon"
		elog "2. Launch the app"
		elog "   * Manually: use your preferred desktop launcher"
		elog "     OR"
		elog "   * Command line: '/opt/Mullvad VPN/mullvad-vpn' & disown"
	fi
}