From 5224935a94349ff60541c8d6c016973bc00b7e04 Mon Sep 17 00:00:00 2001 From: bones_was_here Date: Wed, 26 Feb 2025 11:50:02 +1000 Subject: [PATCH] rsync: reduce duplication of literals, print the update operation more clearly Linux: clarifies the message about the update being performed Windows: adds that message --- .../rsync-updater/update-to-autobuild.bat | 15 ++++++----- .../rsync-updater/update-to-autobuild.sh | 26 +++++++------------ .../tools/rsync-updater/update-to-release.bat | 15 ++++++----- 3 files changed, 27 insertions(+), 29 deletions(-) diff --git a/misc/tools/rsync-updater/update-to-autobuild.bat b/misc/tools/rsync-updater/update-to-autobuild.bat index bfa0b492..c1ebb47c 100644 --- a/misc/tools/rsync-updater/update-to-autobuild.bat +++ b/misc/tools/rsync-updater/update-to-autobuild.bat @@ -53,27 +53,28 @@ goto xonotic echo FATAL: unrecognized Xonotic build. This update script cannot be used. goto end :xonoticdatahigh - set url=rsync://beta.xonotic.org/%buildtype%-Xonotic-high/ + set package=Xonotic-high goto endxonoticdata :xonoticdatahighfuzzy - set url=rsync://beta.xonotic.org/%buildtype%-Xonotic-high/ + set package=Xonotic-high set options=%options% -y goto endxonoticdata :xonoticdatanormal - set url=rsync://beta.xonotic.org/%buildtype%-Xonotic/ + set package=Xonotic goto endxonoticdata :xonoticdatanormalfuzzy - set url=rsync://beta.xonotic.org/%buildtype%-Xonotic/ + set package=Xonotic set options=%options% -y goto endxonoticdata :endxonoticdata set target=./ goto endxonotic :xonotic - set url=rsync://beta.xonotic.org/%buildtype%-Xonotic/ + set package=Xonotic set target=Xonotic/ goto endxonotic :endxonotic +set url=beta.xonotic.org/%buildtype%-%package% set excludes= if not "%XONOTIC_INCLUDE_ALL%" == "" goto endbit @@ -101,7 +102,9 @@ if "%ProgramFiles(x86)%" == "" goto bit32 :endbit for %%f in (*.exe *.dll) do copy /b %%f %TEMP%\xonotic-rsync-updater\ -%TEMP%\xonotic-rsync-updater\rsync %options% %excludes% %url% %target% +cd %target% +echo Updating %CD% from %url% ... +%TEMP%\xonotic-rsync-updater\rsync %options% %excludes% rsync://%url%/ %target% %TEMP%\xonotic-rsync-updater\chmod -R a+x %target% :end diff --git a/misc/tools/rsync-updater/update-to-autobuild.sh b/misc/tools/rsync-updater/update-to-autobuild.sh index b0751792..d4872f64 100755 --- a/misc/tools/rsync-updater/update-to-autobuild.sh +++ b/misc/tools/rsync-updater/update-to-autobuild.sh @@ -27,49 +27,39 @@ esac options="-Prtzil --executability --delete-after --delete-excluded --stats" +package="Xonotic" +target="../../.." if [ -d "../../../.git" ]; then echo >&2 "NOTE: this is a git repository download. Using the regular update method." exec ../../../all update elif [ -e "Xonotic" ]; then echo "found manually created 'Xonotic' file" - echo "targetting the normal $buildtype version" - url="rsync://beta.xonotic.org/$buildtype-Xonotic/" - target="../../.." options="$options -y" # use fuzzy matching because file names may differ elif [ -e "Xonotic-high" ]; then echo "found manually created 'Xonotic-high' file" - echo "targetting the high $buildtype version" - url="rsync://beta.xonotic.org/$buildtype-Xonotic-high/" - target="../../.." + package="Xonotic-high" options="$options -y" # use fuzzy matching because file names may differ elif [ -d "../../../data" ]; then if [ -f ../../../data/xonotic-rsync-data-high.pk3 ]; then echo "found rsync high data files" - echo "targetting the high $buildtype version" - url="rsync://beta.xonotic.org/$buildtype-Xonotic-high/" + package="Xonotic-high" elif [ -f ../../../data/xonotic-*-data-high.pk3 ]; then echo "found release high data files" - echo "targetting the high $buildtype version" - url="rsync://beta.xonotic.org/$buildtype-Xonotic-high/" + package="Xonotic-high" options="$options -y" # use fuzzy matching because file names differ elif [ -f ../../../data/xonotic-rsync-data.pk3 ]; then echo "found Xonotic rsync data files" - echo "targetting the normal $buildtype version" - url="rsync://beta.xonotic.org/$buildtype-Xonotic/" elif [ -f ../../../data/xonotic-*-data.pk3 ]; then echo "found Xonotic release data files" - echo "targetting the normal $buildtype version" - url="rsync://beta.xonotic.org/$buildtype-Xonotic/" options="$options -y" # use fuzzy matching because file names differ else echo >&2 "FATAL: unrecognized Xonotic build. This update script cannot be used." exit 1 fi - target="../../.." else - url="rsync://beta.xonotic.org/$buildtype-Xonotic/" target="Xonotic/" fi +url="beta.xonotic.org/$buildtype-$package" excludes= if [ -z "$XONOTIC_INCLUDE_ALL" ]; then @@ -99,4 +89,6 @@ if [ -z "$XONOTIC_INCLUDE_ALL" ]; then esac fi -rsync $options $excludes "$url" "$target" +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" +rsync $options $excludes "rsync://$url/" "$target" diff --git a/misc/tools/rsync-updater/update-to-release.bat b/misc/tools/rsync-updater/update-to-release.bat index e2c21195..53dcab92 100644 --- a/misc/tools/rsync-updater/update-to-release.bat +++ b/misc/tools/rsync-updater/update-to-release.bat @@ -53,27 +53,28 @@ goto xonotic echo FATAL: unrecognized Xonotic build. This update script cannot be used. goto end :xonoticdatahigh - set url=rsync://beta.xonotic.org/%buildtype%-Xonotic-high/ + set package=Xonotic-high goto endxonoticdata :xonoticdatahighfuzzy - set url=rsync://beta.xonotic.org/%buildtype%-Xonotic-high/ + set package=Xonotic-high set options=%options% -y goto endxonoticdata :xonoticdatanormal - set url=rsync://beta.xonotic.org/%buildtype%-Xonotic/ + set package=Xonotic goto endxonoticdata :xonoticdatanormalfuzzy - set url=rsync://beta.xonotic.org/%buildtype%-Xonotic/ + set package=Xonotic set options=%options% -y goto endxonoticdata :endxonoticdata set target=./ goto endxonotic :xonotic - set url=rsync://beta.xonotic.org/%buildtype%-Xonotic/ + set package=Xonotic set target=Xonotic/ goto endxonotic :endxonotic +set url=beta.xonotic.org/%buildtype%-%package% set excludes= if not "%XONOTIC_INCLUDE_ALL%" == "" goto endbit @@ -101,7 +102,9 @@ if "%ProgramFiles(x86)%" == "" goto bit32 :endbit for %%f in (*.exe *.dll) do copy /b %%f %TEMP%\xonotic-rsync-updater\ -%TEMP%\xonotic-rsync-updater\rsync %options% %excludes% %url% %target% +cd %target% +echo Updating %CD% from %url% ... +%TEMP%\xonotic-rsync-updater\rsync %options% %excludes% rsync://%url%/ %target% %TEMP%\xonotic-rsync-updater\chmod -R a+x %target% :end -- 2.39.5