]> git.rm.cloudns.org Git - xonotic/xonotic.git/commitdiff
rsync: implement mirror support with push updates and autoselect
authorbones_was_here <bones_was_here@xonotic.au>
Tue, 18 Mar 2025 05:35:44 +0000 (15:35 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Sat, 22 Mar 2025 23:18:29 +0000 (09:18 +1000)
misc/infrastructure/update-rsync.sh [deleted file]
misc/infrastructure/xonotic-release-build.cron
misc/tools/all/release.subr
misc/tools/rsync-updater/mirrors.txt [new file with mode: 0644]
misc/tools/rsync-updater/update-to-autobuild.sh

diff --git a/misc/infrastructure/update-rsync.sh b/misc/infrastructure/update-rsync.sh
deleted file mode 100755 (executable)
index dbad194..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/sh
-
-set -ex
-
-d=$1
-
-cd /var/rsync/autobuild
-
-for BUILD in '' -high -mappingsupport; do
-       rm -rf .new
-       mkdir .new
-       cd .new
-       if ! unzip ~/Xonotic-"$d$BUILD".zip; then
-               good=false
-               #for f in ~/Xonotic-"$d$BUILD".zip; do
-               #       unzip "$f" && good=true && break
-               #done
-               $good
-       fi
-       cd Xonotic/data
-       for X in *"$d"*; do
-               pre=${X%$d*}
-               post=${X##*$d}
-               mv "$X" "$pre"rsync"$post"
-       done
-       cd ../../..
-       rm -rf Xonotic.old
-       mv Xonotic"$BUILD" Xonotic.old || true
-       mv .new/Xonotic Xonotic"$BUILD"
-       rmdir .new
-       rm -rf Xonotic.old
-done
index 9491caba6651d9c1532f403107d7f0179bcf7407..d1e08f34c35cd94dd42b263ff5069bbf09e2cb90 100755 (executable)
@@ -99,13 +99,40 @@ if [ -z "$RELEASETYPEDIR" ]; then
 fi
 rsync -vaSHP Xonotic*.zip Xonotic*.sha512 autobuild-release-uploader@beta.xonotic.org:"$RELEASETYPEDIR"
 if [ -z "$RELEASETYPEDIR" ]; then
-       ssh autobuild-release-uploader@beta.xonotic.org sh ../../update-rsync.sh "$d"
+       # Update one package at a time (to reduce temp space requirement), on all mirrors simultaneously
+       rm -rf rsynctmp && mkdir rsynctmp && cd rsynctmp
+       for suffix in '' -high -mappingsupport; do
+               package="Xonotic$suffix"
+               unzip ../Xonotic-"$d$suffix".zip
+               [ "$package" != Xonotic ] && mv Xonotic "$package"
+               while read firstword restoflineignored; do
+                       mirror=${firstword%%//*}
+                       [ -z $mirror ] && continue
+                       # if desired an extra word could be parsed from mirrors.txt to change /var/rsync
+                       # ports and usernames should be specified in .ssh/config
+                       rpath=/var/rsync/autobuild
+                       rsync -rtzlyhhS --delete-delay --executability --stats --link-dest="$rpath/$package" \
+                               "$package/" "$mirror:$rpath/.$package.new/" \
+                       && ssh "$mirror" "
+                               set -e
+                               cd $rpath
+                               rm -rf .$package.old
+                               [ -e $package ] && mv $package .$package.old
+                               mv .$package.new $package
+                               rm -rf .$package.old
+                       " || echo "<font color=\"red\">Failed to update $package on rsync mirror $mirror</font>" | $IRCSPAM \
+                       &
+               done < ../misc/tools/rsync-updater/mirrors.txt
+               wait
+               rm -rf "$package"
+       done
+       cd .. && rm -rf rsynctmp
 
        # also upload pipeline files for .gitlab-ci.yml in xonotic-data.pk3dir
        cp data/stormkeep-????????????????????????????????????????-????????????????????????????????????????.pk3 stormkeep.pk3
        cd data/xonotic-maps.pk3dir # need correct path inside pk3
-       7z a -tzip -mx=9 ../../stormkeep.pk3 maps/stormkeep.mapinfo maps/stormkeep.waypoints*
-       cd ~/xonotic-release-build
+               7z a -tzip -mx=9 ../../stormkeep.pk3 maps/stormkeep.mapinfo maps/stormkeep.waypoints*
+       cd ../..
        PIPELINE_FILES="gmqcc/gmqcc Xonotic/xonotic-linux64-dedicated stormkeep.pk3"
        rsync -vSP $PIPELINE_FILES autobuild-release-uploader@beta.xonotic.org:../pipeline-bin/
        rm -f stormkeep.pk3
index fee5d75e48536116a1d6af595f25a760c5b09608..62334a3188f8091921ca9d8e77b10b0461540e59 100644 (file)
@@ -681,19 +681,21 @@ case "$cmd" in
        release-rsync)
                release_common
                # make sure everything we need is installed and updated
-               verbose "$d0"/misc/tools/msys2-linux.sh --schroot=sid rsync dash openssl
+               verbose "$d0"/misc/tools/msys2-linux.sh --schroot=sid rsync dash openssl sed
                targetroot="$PWD/Xonotic"
                verbose cd "$HOME/msys64" # see msys2-linux.sh
                verbose cp --parents \
                        usr/bin/msys-2.0.dll \
                        usr/bin/msys-crypto-3.dll \
                        usr/bin/msys-iconv-2.dll \
+                       usr/bin/msys-intl-8.dll \
                        usr/bin/msys-lz4-1.dll \
                        usr/bin/msys-ssl-3.dll \
                        usr/bin/msys-xxhash-0.dll \
                        usr/bin/msys-zstd-1.dll \
                        usr/bin/openssl.exe \
                        usr/bin/rsync.exe \
+                       usr/bin/sed.exe \
                        usr/ssl/cert.pem \
                        "$targetroot/misc/tools/rsync-updater/"
                # msys2 sh.exe is currently bash
diff --git a/misc/tools/rsync-updater/mirrors.txt b/misc/tools/rsync-updater/mirrors.txt
new file mode 100644 (file)
index 0000000..d38ad19
--- /dev/null
@@ -0,0 +1,3 @@
+// One mirror per line, the first word is the FQDN, other parameters could be added.
+rsync.xonotic.org // location: DE, admins: Xonotic Core Team
+rsync.xonotic.au  // location: AU, admins: rly and bones_was_here
index 17cb618c3b9d87975e7c424bf474401ba47215f0..16a9f9a629fad81d893c25eccc180d843ddb956b 100755 (executable)
@@ -14,7 +14,7 @@ if ! command -v rsync-ssl >/dev/null; then
 fi
 
 # openssl is the only option, as gnutls-cli is broken in rsync-ssl and stunnel doesn't verify the cert.
-rsynccmd=rsync-ssl
+rsynccmd="rsync-ssl --timeout=3"
 if ! command -v openssl > /dev/null; then
        if [ $interactive = false ]; then
                printf >&2 "\033[1;31mFATAL: openssl not found, please install the openssl package!\033[m\n"
@@ -27,7 +27,7 @@ if ! command -v openssl > /dev/null; then
                read -r secchoice
                [ "$secchoice" = n ] || [ "$secchoice" = N ] && exit 1
        done
-       rsynccmd=rsync
+       rsynccmd="rsync --contimeout=3"
 fi
 
 case "${0##*/}" in
@@ -79,7 +79,7 @@ elif [ -e "Xonotic-high" ]; then
        printf "\033[1;35mFound manually created 'Xonotic-high' package override\033[m\n"
        package="Xonotic-high"
 fi
-url="rsync.xonotic.org/$buildtype/$package"
+source="$buildtype/$package"
 
 excludes=
 if [ -n "$XONOTIC_INCLUDE_ALL" ]; then
@@ -131,8 +131,38 @@ else
        esac
 fi
 
+bestmirror=rsync.xonotic.org
+if [ -z "$(rsync --help | sed -En 's/(--write-devices)/\1/p')" ]; then
+       printf "\033[1;33mNOTE: your rsync version is too old for mirror autoselect and modern compression, expect bad performance. Please update to rsync 3.2.0 or later!\033[m\n"
+else
+       printf "Updating mirror list ... "
+       out=$($rsynccmd -t "rsync://$bestmirror/autobuild/Xonotic/misc/tools/rsync-updater/mirrors.txt" mirrors.txt 2>&1) \
+               && printf "\033[0;32mOK\033[m\n" \
+               || printf "\033[1;31mERROR\n\033[0;31m$out\033[m\n" | sed '2,${s/^/  /}'
+
+       bestspeed=0
+       while read firstword restoflineignored; do
+               mirror=${firstword%%//*}
+               [ -z $mirror ] && continue
+               printf "Testing mirror \033[36m$mirror\033[m ... \033[m"
+               # not the most rigorous benchmark, but fit for purpose and unaffected by local filesystem perf
+               if out=$($rsynccmd --compress-choice=none --write-devices --stats "rsync://$mirror/$source/COPYING" /dev/null 2>&1); then
+                       # parse the speed from the --stats output (integer part only), and strip any commas (thousands separators)
+                       speed=$(printf "$out" | sed -En 's/.*  ([0-9,]+)\.?[0-9]* bytes\/sec$/\1/p' | sed 's/,//g')
+                       if [ $speed -gt $bestspeed ]; then
+                               bestspeed=$speed
+                               bestmirror=$mirror
+                       fi
+                       printf "\033[0;32mOK, speed $speed\033[m\n"
+               else
+                       printf "\033[1;31mERROR\n\033[0;31m$out\033[m\n" | sed '2,${s/^/  /}'
+               fi
+       done < mirrors.txt
+       if [ $bestspeed -eq 0 ]; then printf "\033[1;31mAll mirror tests failed, no internet?\033[m\n"; exit 1; fi
+fi
+
 resolvedtarget=$(cd $target && [ "${PWD#$HOME}" != "$PWD" ] && printf "~${PWD#$HOME}" || printf "$PWD")
-printf "Updating \033[1;34m$resolvedtarget\033[m from \033[0;36m$url \033[m...\n"
+printf "Updating \033[1;34m$resolvedtarget\033[m from \033[0;36m$bestmirror/$source \033[m...\n"
 
 targetname=$(cd "$target" && printf "${PWD##*/}")
 if [ "$1" = "-y" ] || [ "$1" = "--yes" ]; then
@@ -148,4 +178,4 @@ until [ "$choice" = y ] || [ "$choice" = Y ]; do
 done
 
 # exec ensures this script stops before it's updated to prevent potential glitches
-exec $rsynccmd $options $excludes "rsync://$url/" "$target"
+exec $rsynccmd $options $excludes "rsync://$bestmirror/$source/" "$target"