Skip to content

Commit

Permalink
Merge branch 'add-linux-repo-version-script-cont'
Browse files Browse the repository at this point in the history
  • Loading branch information
raksooo committed Feb 4, 2025
2 parents b9b74b3 + c1cbce2 commit 2f3c791
Showing 1 changed file with 93 additions and 0 deletions.
93 changes: 93 additions & 0 deletions desktop/scripts/print-package-versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#!/usr/bin/env bash
#
# Prints the versions of the packages currently in our Linux repositories.

set -eu

function usage() {
echo "Usage: $0 [options]"
echo ""
echo "Example usage: $0 --rpm --production --beta"
echo
echo "Options:"
echo " -h | --help Show this help message and exit."
echo " -v | --verbose Print stderr of all commands."
echo " -vv Print both stderr and stdout of all commands."
echo " --deb Check version of deb package (default)."
echo " --rpm Check version of rpm package (default)."
echo " --production | --prod Check packages in production repositories (default)."
echo " --staging Check packages in staging repositories."
echo " --development | --dev Check packages in development repositories."
echo " --stable Check packages in stable repositories (default)."
echo " --beta Check packages in beta repositories."
exit 1
}

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$SCRIPT_DIR"

# shellcheck source=ci/linux-repository-builder/build-linux-repositories-config.sh
source build-linux-repositories-config.sh
# shellcheck source=scripts/utils/log
source ../../scripts/utils/log

deb="false"
rpm="false"
repository_server_public_url="$PRODUCTION_LINUX_REPOSITORY_PUBLIC_URL"
release_channel="stable"

silent_stdout=">/dev/null"
silent_stderr="2>/dev/null"

while [[ "$#" -gt 0 ]]; do
case $1 in
-h|--help) usage;;
-v|--verbose) silent_stderr="" ;;
-vv)
silent_stdout=""
silent_stderr=""
;;
--deb) deb="true";;
--rpm) rpm="true";;
--production|--prod) repository_server_public_url="$PRODUCTION_LINUX_REPOSITORY_PUBLIC_URL";;
--staging) repository_server_public_url="$STAGING_LINUX_REPOSITORY_PUBLIC_URL";;
--development|--dev) repository_server_public_url="$DEV_LINUX_REPOSITORY_PUBLIC_URL";;
--stable) release_channel="stable";;
--beta) release_channel="beta";;
*)
log_error "Unknown parameter: $1\n"
usage
;;
esac
shift
done

if [[ $deb == "false" && $rpm == "false" ]]; then
deb="true";
rpm="true";
fi

if [[ $deb == "true" ]]; then
if [[ $rpm == "true" ]]; then
log_header "deb"
fi

bash -c " podman run --rm -it debian:latest sh -c \
\"apt update $silent_stderr $silent_stdout; \
apt install -y curl $silent_stderr $silent_stdout; \
curl -fsSLo /usr/share/keyrings/mullvad-keyring.asc $repository_server_public_url/deb/mullvad-keyring.asc; \
echo \\\"deb [signed-by=/usr/share/keyrings/mullvad-keyring.asc arch=amd64] $repository_server_public_url/deb/$release_channel bookworm main\\\" > /etc/apt/sources.list.d/mullvad.list; \
apt update $silent_stderr $silent_stdout; \
apt list mullvad-vpn mullvad-browser $silent_stderr | grep -E 'mullvad-(vpn|browser)'\" $silent_stderr"
fi

if [[ $rpm == "true" ]]; then
if [[ $deb == "true" ]]; then
log_header "rpm"
fi

bash -c "podman run --rm -it fedora:latest sh -c \
\"dnf install -y 'dnf-command(config-manager)' $silent_stdout; \
dnf config-manager --add-repo $repository_server_public_url/rpm/$release_channel/mullvad.repo $silent_stdout; \
dnf list --refresh mullvad-vpn mullvad-browser $silent_stderr | grep -E 'mullvad-(vpn|browser)'\" $silent_stderr"
fi

0 comments on commit 2f3c791

Please sign in to comment.