diff options
| author | Linus Färnstrand <linus@mullvad.net> | 2023-11-14 17:30:25 +0100 |
|---|---|---|
| committer | Linus Färnstrand <linus@mullvad.net> | 2023-11-16 13:54:58 +0100 |
| commit | 605ca80d131d1304b3d833cc4c33b0f6d62ab474 (patch) | |
| tree | d67b438724c4d076e167f025c0d1ce810acc1b8a | |
| parent | 3ef753ca0752b0d737ad8e1f7f35e1d79a2ccdca (diff) | |
| download | mullvadvpn-605ca80d131d1304b3d833cc4c33b0f6d62ab474.tar.xz mullvadvpn-605ca80d131d1304b3d833cc4c33b0f6d62ab474.zip | |
Add script for preparing RPM repositories on build server
| -rwxr-xr-x | ci/buildserver-build.sh | 11 | ||||
| -rw-r--r-- | ci/buildserver-config.sh | 2 | ||||
| -rwxr-xr-x | ci/prepare-rpm-repository.sh | 57 |
3 files changed, 68 insertions, 2 deletions
diff --git a/ci/buildserver-build.sh b/ci/buildserver-build.sh index db172031eb..f9d8af60fa 100755 --- a/ci/buildserver-build.sh +++ b/ci/buildserver-build.sh @@ -46,10 +46,15 @@ esac function publish_linux_repositories { local artifact_dir=$1 local version=$2 - local deb_repo_dir="$SCRIPT_DIR/deb/$version" + local deb_repo_dir="$SCRIPT_DIR/deb/$version" + echo "Preparing Apt repository in $deb_repo_dir" "$SCRIPT_DIR/prepare-apt-repository.sh" "$artifact_dir" "$version" "$deb_repo_dir" + local rpm_repo_dir="$SCRIPT_DIR/rpm/$version" + echo "Preparing RPM repository in $rpm_repo_dir" + "$SCRIPT_DIR/prepare-rpm-repository.sh" "$artifact_dir" "$version" "$rpm_repo_dir" + "$SCRIPT_DIR/publish-linux-repositories.sh" --dev "$version" "$deb_repo_dir" # If this is a release build, also push to staging. # Publishing to production is done manually. @@ -226,7 +231,9 @@ function build_ref { fi fi - publish_linux_repositories "$artifact_dir" "$version" + if [[ "$(uname -s)" == "Linux" ]]; then + publish_linux_repositories "$artifact_dir" "$version" + fi (cd "$artifact_dir" && upload "$version") || return 1 # shellcheck disable=SC2216 yes | rm -r "$artifact_dir" diff --git a/ci/buildserver-config.sh b/ci/buildserver-config.sh index 789a9b98d2..64cca6b336 100644 --- a/ci/buildserver-config.sh +++ b/ci/buildserver-config.sh @@ -12,6 +12,8 @@ SUPPORTED_DEB_CODENAMES=("sid" "testing" "bookworm" "bullseye") SUPPORTED_DEB_CODENAMES+=("jammy" "focal" "lunar") export SUPPORTED_DEB_CODENAMES +export SUPPORTED_RPM_ARCHITECTURES=("x86_64" "aarch64") + # Servers to upload Linux deb/rpm repositories to export DEV_LINUX_REPOSITORY_SERVERS=("se-got-cdn-001.devmole.eu" "se-got-cdn-002.devmole.eu") export STAGING_LINUX_REPOSITORY_SERVERS=("se-got-cdn-001.stagemole.eu" "se-got-cdn-002.stagemole.eu") diff --git a/ci/prepare-rpm-repository.sh b/ci/prepare-rpm-repository.sh new file mode 100755 index 0000000000..6ed73742f7 --- /dev/null +++ b/ci/prepare-rpm-repository.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash +# +# Usage: ./prepare-rpm-repository.sh <artifact dir> <app version> <repository dir> +# +# Will create an rpm repository in <repository dir> and add all .rpm files from +# <artifact dir> matching <app version> to the repository. + +set -eu + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +source "$SCRIPT_DIR/buildserver-config.sh" + +artifact_dir=$1 +version=$2 +repo_dir=$3 + +function generate_repository_configuration { + echo -e "[mullvad-rpm] +name=Mullvad VPN +baseurl=https://repository.mullvad.net/rpm/\$basearch +type=rpm +enabled=1 +gpgcheck=1 +gpgkey=https://repository.mullvad.net/rpm/mullvad-keyring.asc" +} + +function create_repository { + local arch_repo_dir=$1 + local rpm_path=$2 + + mkdir -p "$arch_repo_dir" + + # Copy RPM file into repository + cp "$rpm_path" "$arch_repo_dir"/ + + # Generate repository metadata files (containing among other things checksums + # for the above artifact) + createrepo_c "$arch_repo_dir" + + # Sign repository metadata (created by createrepo_c above) + # --yes is passed to automatically overwrite existing files + # in the case where the build server re-builds something we already + # have built. + gpg --detach-sign --armor --yes "$arch_repo_dir/repodata/repomd.xml" +} + +for arch in "${SUPPORTED_RPM_ARCHITECTURES[@]}"; do + rpm_path="$artifact_dir"/MullvadVPN-"$version"_"$arch".rpm + if [[ ! -e "$rpm_path" ]]; then + echo "RPM at $rpm_path does not exist" >&2 + exit 1 + fi + create_repository "$repo_dir/$arch" "$rpm_path" +done + +generate_repository_configuration > "$repo_dir/mullvad.repo" |
