Skip to content

Commit d86f3db

Browse files
braydonfMarkusPettersson98
authored andcommitted
Output deb and rpm packags to dist/ based on build targets
1 parent b60385a commit d86f3db

File tree

2 files changed

+47
-19
lines changed

2 files changed

+47
-19
lines changed

BuildInstructions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ Building this requires at least 1GB of memory.
204204
205205
## Notes on options
206206
207-
- `--daemon-only` - This will build daemon only Linux packages (e.g. `mullvad-vpn-daemon`). You will need to install additional build tools: `cargo install cargo-deb cargo-generate-rpm`. The output files will be located in `./target/debian/*` and `/target/generate-rpm/*`.
207+
- `--daemon-only` - This will build daemon only Linux packages (e.g. `mullvad-vpn-daemon`). You will need to install additional build tools: `cargo install cargo-deb cargo-generate-rpm`.
208208
- `--gotatun` - This will build with the `gotatun` Rust library instead the `wireguard-go-rs` Go library.
209209
210210
## Notes on targeting ARM64

build.sh

Lines changed: 46 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ NOTARIZE="false"
3333
UNIVERSAL="false"
3434
# Use gotatun instead of wireguard-go.
3535
GOTATUN="false"
36-
# If only the daemon should be built.
36+
# If only the daemon should be built and packaged separately (.deb and .rpm).
3737
DAEMON_ONLY="false"
3838
# Enable GotaTun by default on macOS.
3939
if [[ "$(uname -s)" == "Darwin" ]]; then
@@ -388,26 +388,54 @@ cargo run -p mullvad-api --bin relay_list "${CARGO_ARGS[@]}" > build/relays.json
388388
function build_daemon_packages {
389389
local pkg_success=0
390390

391-
if cargo deb --help &> /dev/null ; then
392-
log_info "Packaging Debian (*.deb) package..."
393-
if cargo deb --deb-version $PRODUCT_VERSION --no-build ; then
394-
pkg_success=1
391+
for specified_target in "${TARGETS[@]:-""}"; do
392+
local current_target=${specified_target:-"$HOST"}
393+
local arch="${current_target%%-*}"
394+
395+
local pkg_args=(-p mullvad-daemon)
396+
if [[ -n "$specified_target" ]]; then
397+
pkg_args+=(--target "$specified_target")
395398
fi
396-
else
397-
log_error "Unable to package Debian package."
398-
log_error "Please run \"cargo install cargo-deb\" to complete."
399-
fi
400399

401-
if cargo generate-rpm --help &> /dev/null ; then
402-
log_info "Packaging Fedora (*.rpm) package..."
403-
if cargo generate-rpm -p mullvad-daemon -s 'version = "'$PRODUCT_VERSION'"' ; then
404-
echo "${SCRIPT_DIR}/target/generate-rpm/"
405-
pkg_success=1
400+
local deb_arch="${arch}"
401+
local rpm_arch="${arch}"
402+
403+
case $arch in
404+
x86_64) deb_arch="amd64";;
405+
aarch64) deb_arch="arm64";;
406+
esac
407+
408+
local deb_name="mullvad-vpn-daemon_${PRODUCT_VERSION}_${deb_arch}.deb"
409+
local rpm_name="mullvad-vpn-daemon_${PRODUCT_VERSION}_${rpm_arch}.rpm"
410+
local deb_file="dist/${deb_name}"
411+
local rpm_file="dist/${rpm_name}"
412+
413+
if cargo deb --help &> /dev/null ; then
414+
log_info "Packaging Debian (*.deb) package for ${arch}..."
415+
if cargo deb "${pkg_args[@]}" \
416+
--deb-version "${PRODUCT_VERSION}" --no-build \
417+
-o "${deb_file}" > /dev/null ; then
418+
log_info "Packaged $deb_file"
419+
pkg_success=1
420+
fi
421+
else
422+
log_error "Unable to package Debian package."
423+
log_error "Please run \"cargo install cargo-deb\" to complete."
406424
fi
407-
else
408-
log_error "Unable to package Fedora package."
409-
log_error "Please run \"cargo install cargo-generate-rpm\" to complete."
410-
fi
425+
426+
if cargo generate-rpm --help &> /dev/null ; then
427+
log_info "Packaging Fedora (*.rpm) package for ${arch}..."
428+
if cargo generate-rpm "${pkg_args[@]}" \
429+
-s "version = \"${PRODUCT_VERSION}\"" \
430+
-o "${rpm_file}" ; then
431+
log_info "Packaged $rpm_file"
432+
pkg_success=1
433+
fi
434+
else
435+
log_error "Unable to package Fedora package."
436+
log_error "Please run \"cargo install cargo-generate-rpm\" to complete."
437+
fi
438+
done
411439

412440
if [ $pkg_success -eq 0 ]; then
413441
return 1

0 commit comments

Comments
 (0)