Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

added mullvad-vpn at v2023.6 #78

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ iwgtk|[Archlinux AUR](https://aur.archlinux.org/packages/iwgtk)|Lightweight wire
liblcf|[Archlinux AUR](https://aur.archlinux.org/packages/liblcf)|Dependency of easyrpg-player.
min|[Archlinux AUR](https://aur.archlinux.org/packages/min)|A fast, minimal browser that protects your privacy.
mozc|[Archlinux AUR](https://aur.archlinux.org/packages/mozc)|Japanese input.
mullvad-vpn|[Archlinux AUR](https://aur.archlinux.org/packages/mullvad-vpn)|The Mullvad VPN client app for desktop.
openvpn-update-systemd-resolved|[Archlinux AUR](https://aur.archlinux.org/packages/openvpn-update-systemd-resolved)|OpenVPN systemd-resolved Updater.
rkdeveloptool|[Archlinux AUR](https://aur.archlinux.org/packages/rkdeveloptool)|Development tool for Rockchip SOC.
stripe-cli|[Archlinux AUR](https://aur.archlinux.org/packages/stripe-cli)|CLI for Stripe.
Expand Down
1 change: 1 addition & 0 deletions build_orders/_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ mozc
ibus-mozc
stripe-cli
min
mullvad-vpn
rkdeveloptool
cpu-x
ttf-ms-fonts
Expand Down
175 changes: 175 additions & 0 deletions packages/mullvad-vpn/PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
# Maintainer: Mark Wagie <mark dot wagie at proton dot me>
# Contributor: Matthew McGinn <mamcgi at gmail dot com>
# Contributor: alicewww <almw at protonmail dot com>
# Contributor: David Birks <david at tellus dot space>
# Contributor: Jeff Henson <jeff at henson dot io>
# Contributor: Linus Färnstrand <linus at mullvad dot net>
# Contributor: Emīls Piņķis <emil at mullvad dot net>
# Contributor: Andrej Mihajlov <and at mullvad dot net>
pkgname=mullvad-vpn
pkgver=2023.6
pkgrel=1
pkgdesc="The Mullvad VPN client app for desktop"
arch=('x86_64')
url="https://www.mullvad.net"
license=('GPL3')
depends=('gtk3' 'iputils' 'libnotify' 'nss')
makedepends=('cargo' 'git' 'go' 'libxcrypt-compat' 'nodejs>=16' 'npm>=8.3' 'protobuf')
options=('!lto')
install="$pkgname.install"
_tag=c2f7f75dee35c050540b90c6ebc9084969b1a93b # tags/2023.6^0
_commit=d5772339cee9c1a0d7671968746f02499b78e245
source=("git+https://github.com/mullvad/mullvadvpn-app.git#commit=${_tag}" # signed by Oskar Nyberg (raksooo), public key not uploaded yet
"git+https://github.com/mullvad/mullvadvpn-app-binaries.git#commit=${_commit}?signed"
'no-rpm.diff'
"$pkgname.sh")
sha256sums=('SKIP'
'SKIP'
'ea35edffea2cbbb05586abce19581fdd9f133801ed47e6af30fa64a29c5cf116'
'2262346cb57deb187fe32a88ccd873dab669598889269088e749197c6e88954f')
validpgpkeys=('225E40C8F1C8DEB7977ABF59F293063FECE2E8ED' # Linus Färnstrand <[email protected]>
'8339C7D2942EB854E3F27CE5AEE9DECFD582E984' # David Lönnhager (code signing) <[email protected]>
'4B986EF5222BA1B810230C602F391DE6B00D619C' # Oskar Nyberg (code signing) <[email protected]>
)

pkgver() {
cd "$srcdir/mullvadvpn-app"
git describe --tags | sed 's/-/./g'
}

prepare() {
cd mullvadvpn-app
git submodule init
git config submodule.dist-assets/binaries.url "$srcdir/mullvadvpn-app-binaries"
git -c protocol.file.allow=always submodule update

# Disable building rpm
patch --strip=1 gui/tasks/distribution.js < ../no-rpm.diff

export CARGO_HOME="$srcdir/cargo-home"
export RUSTUP_TOOLCHAIN=stable
cargo fetch --locked --target "$CARCH-unknown-linux-gnu"

pushd wireguard/libwg
export GOPATH="$srcdir/gopath"
mkdir -p "../../build/lib/$CARCH-unknown-linux-gnu"
go mod download -x
popd

pushd gui
echo "Installing JavaScript dependencies..."
export npm_config_cache="$srcdir/npm_cache"
npm ci
popd
}

build() {
cd mullvadvpn-app
export CARGO_HOME="$srcdir/cargo-home"
export RUSTUP_TOOLCHAIN=stable
export CARGO_TARGET_DIR=target
local RUSTC_VERSION=$(rustc --version)
local PRODUCT_VERSION=$(cargo run -q --bin mullvad-version)

echo "Building Mullvad VPN ${PRODUCT_VERSION}..."

echo "Building wireguard-go..."
pushd wireguard/libwg
export GOPATH="$srcdir/gopath"
export CGO_CPPFLAGS="${CPPFLAGS}"
export CGO_CFLAGS="${CFLAGS}"
export CGO_CXXFLAGS="${CXXFLAGS}"
export CGO_LDFLAGS="${LDFLAGS}"
export GOFLAGS="-buildmode=pie -trimpath -ldflags=-linkmode=external -mod=readonly -modcacherw"
go build -v -o "../../build/lib/$CARCH-unknown-linux-gnu"/libwg.a -buildmode c-archive
popd

# Clean module cache for makepkg -C
go clean -modcache

echo "Building Rust code in release mode using ${RUSTC_VERSION}..."

cargo_crates_to_build=(
-p mullvad-daemon --bin mullvad-daemon
-p mullvad-cli --bin mullvad
-p mullvad-setup --bin mullvad-setup
-p mullvad-problem-report --bin mullvad-problem-report
-p talpid-openvpn-plugin --lib
-p mullvad-exclude --bin mullvad-exclude
)
cargo build --frozen --release "${cargo_crates_to_build[@]}"

echo "Preparing for packaging Mullvad VPN ${PRODUCT_VERSION}..."
mkdir -p build/shell-completions
for sh in bash zsh fish; do
echo "Generating shell completion script for ${sh}..."
cargo run --bin mullvad --frozen --release -- shell-completions ${sh} \
build/shell-completions/
done

echo "Updating relays.json..."
cargo run --bin relay_list --frozen --release > dist-assets/relays.json

# Move binaries to correct locations in dist-assets
binaries=(
mullvad-daemon
mullvad
mullvad-problem-report
libtalpid_openvpn_plugin.so
mullvad-setup
mullvad-exclude
)
for binary in ${binaries[*]}; do
cp "target/release/${binary}" "dist-assets/${binary}"
done

# Build Electron GUI
pushd gui
echo "Packing Mullvad VPN ${PRODUCT_VERSION} artifact(s)..."
export npm_config_cache="$srcdir/npm_cache"
npm run pack:linux --release
popd
}

package() {
cd mullvadvpn-app

# Install main files
install -d "$pkgdir/opt/Mullvad VPN"
cp -r dist/linux-unpacked/* "$pkgdir/opt/Mullvad VPN/"

chmod 4755 "$pkgdir/opt/Mullvad VPN/chrome-sandbox"

# Install services
install -Dm644 dist-assets/linux/mullvad{-daemon,-early-boot-blocking}.service -t \
"$pkgdir/usr/lib/systemd/system/"

# Install binaries
install -Dm755 dist-assets/{mullvad,mullvad{-daemon,-exclude}} -t "$pkgdir/usr/bin/"

# Link to the problem report binary
ln -s "/opt/Mullvad VPN/resources/mullvad-problem-report" "$pkgdir/usr/bin/"

# Link to the GUI binary
install -m755 "$srcdir/$pkgname.sh" "$pkgdir/usr/bin/$pkgname"

# Install completions
install -Dm644 build/shell-completions/mullvad.bash \
"$pkgdir/usr/share/bash-completion/completions/mullvad"
install -Dm644 build/shell-completions/_mullvad -t \
"$pkgdir/usr/share/zsh/site-functions/"
install -Dm644 build/shell-completions/mullvad.fish -t \
"$pkgdir/usr/share/fish/vendor_completions.d/"

# Install desktop file & icons from deb
cd dist
ar x *.deb
bsdtar -xf data.tar.xz
install -Dm644 "usr/share/applications/$pkgname.desktop" -t \
"$pkgdir/usr/share/applications/"

for icon_size in 16 32 48 64 128 256 512 1024; do
icons_dir="usr/share/icons/hicolor/${icon_size}x${icon_size}/apps"
install -Dm644 "${icons_dir}/$pkgname.png" -t "$pkgdir/${icons_dir}/"
done
}
67 changes: 67 additions & 0 deletions packages/mullvad-vpn/mullvad-vpn.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
pre_install() {
if systemctl status mullvad-daemon &> /dev/null; then
echo 'Stopping & disabling Mullvad VPN daemon...'
/opt/Mullvad\ VPN/resources/mullvad-setup prepare-restart || true
systemctl disable --now mullvad-daemon
echo 'Disabling Mullvad early boot blocking service...'
systemctl disable mullvad-early-boot-blocking.service || true
cp /var/log/mullvad-vpn/daemon.log /var/log/mullvad-vpn/old-install-daemon.log \
|| echo "Failed to copy old daemon log"
fi

pkill -x "mullvad-gui" || true

rm -f /var/cache/mullvad-vpn/relays.json
rm -f /var/cache/mullvad-vpn/api-ip-address.txt
}

post_install() {
chmod u+s "/usr/bin/mullvad-exclude"

echo 'Starting & enabling Mullvad VPN daemon...'
systemctl enable --now mullvad-daemon
echo 'Enabling Mullvad early boot blocking service...'
systemctl enable mullvad-early-boot-blocking
}

pre_upgrade() {
pre_install
}

post_upgrade() {
systemctl daemon-reload

post_install
}

pre_remove() {
# SIGTERM for some reason causes the app to crash sometimes and SIGINT works as expected.
pkill -2 -x "mullvad-gui" || true
sleep 0.5
pkill -9 -x "mullvad-gui" || true

# the user might've disabled or stopped the services themselves already
echo 'Making sure the services are stopped & disabled...'
systemctl disable --now mullvad-daemon || true
systemctl disable --now 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"
}

post_remove() {
echo -------------------------------------------------------------
echo 'Optionally remove logs & cache:'
echo 'sudo rm -rf /var/log/mullvad-vpn/'
echo 'sudo rm -rf /var/cache/mullvad-vpn/'
echo ''
echo 'Optionally remove config:'
echo 'sudo rm -rf /etc/mullvad-vpn/'
echo ''
echo 'Optionally remove app settings:'
echo 'rm -rf ~/.config/Mullvad VPN/'
echo ''
echo 'Optionally remove auto-launcher:'
echo 'rm ~/.config/autostart/mullvad-vpn.desktop'
echo -------------------------------------------------------------
}
2 changes: 2 additions & 0 deletions packages/mullvad-vpn/mullvad-vpn.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
"/opt/Mullvad VPN/mullvad-vpn" "$@"
13 changes: 13 additions & 0 deletions packages/mullvad-vpn/no-rpm.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
--- distribution-a.js 2022-09-26 09:34:34.906953989 -0600
+++ distribution-b.js 2022-09-26 10:03:26.305152655 -0600
@@ -162,10 +162,6 @@
target: 'deb',
arch: getLinuxTargetArch(),
},
- {
- target: 'rpm',
- arch: getLinuxTargetArch(),
- },
],
artifactName: 'MullvadVPN-${version}_${arch}.${ext}',
category: 'Network',
Loading