]> git.rm.cloudns.org Git - xonotic/xonotic.git/commitdiff
rsync: mostly replace Windows batch script with POSIX shell script
authorbones_was_here <bones_was_here@xonotic.au>
Wed, 19 Mar 2025 19:52:42 +0000 (05:52 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Fri, 21 Mar 2025 07:47:32 +0000 (17:47 +1000)
This makes advanced features easier to implement because the language is
more powerful and standardised, and allows most of the code to be shared
by all platforms.

The Linux script is better so this brings various improvements.

Fixes minor inconsistencies in Windows file excludes.

misc/tools/all/release.subr
misc/tools/rsync-updater/update-to-autobuild.bat
misc/tools/rsync-updater/update-to-autobuild.sh
misc/tools/rsync-updater/update-to-release.bat

index 428b3bff1cce44b175ca5cd7c23832b373ea5102..7fafe363e4e1b67a4752833b220af8391a2a8bd9 100644 (file)
@@ -681,7 +681,7 @@ 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
+               verbose "$d0"/misc/tools/msys2-linux.sh --schroot=sid rsync dash
                targetroot="$PWD/Xonotic"
                verbose cd "$HOME/msys64" # see msys2-linux.sh
                verbose cp --parents \
@@ -693,6 +693,8 @@ case "$cmd" in
                        usr/bin/msys-zstd-1.dll \
                        usr/bin/rsync.exe \
                        "$targetroot/misc/tools/rsync-updater/"
+               # msys2 sh.exe is currently bash
+               verbose cp usr/bin/dash.exe "$targetroot/misc/tools/rsync-updater/usr/bin/sh.exe"
                ;;
        release)
                release_common
index 0c8491ae8671eb92105cbaf57ddcf1b3d69d6647..1c7aeb97ff3e8e71ee945734681349a2845a9651 100644 (file)
 @echo off\r
 setlocal\r
 \r
-if "%1" == "did-copy" goto copied\r
+if "%did_copy%" == "true" goto copied\r
 cd %~dp0\r
+:: Windows can't update .exe and .dll files while they're running,\r
+:: it can update the .bat file but that can cause execution glitches.\r
+:: Shell scripts can also glitch if updated while running\r
+:: but can be protected, which update-to-autobuild.sh and rsync-ssl are.\r
 rmdir /s /q %TEMP%\xonotic-rsync-updater  2>NUL\r
 mkdir %TEMP%\xonotic-rsync-updater\r
 copy /b %~nx0 %TEMP%\xonotic-rsync-updater\  >NUL\r
 :: windows has no cp -r equivalent, this seems least-bad\r
 robocopy usr %TEMP%\xonotic-rsync-updater\usr /e   >NUL\r
-%TEMP%\xonotic-rsync-updater\%~n0 did-copy\r
+set did_copy=true\r
+%TEMP%\xonotic-rsync-updater\%~n0 %*\r
 :: can only get here if above batch file couldn't be created\r
 pause\r
 exit /b\r
 \r
 :copied\r
+set PATH=%TEMP%\xonotic-rsync-updater\usr\bin;%PATH%\r
+:: $PATH $PWD $TEMP and $TMP get automatic cygwin path conversion but $0 doesn't,\r
+:: sourcing the main script and setting a custom $0 also works around broken symlink support.\r
+sh -c ". ./update-to-autobuild.sh" ./%~n0.sh %*\r
 \r
-set /p choice=This script will DELETE any custom files in the Xonotic folder. Do you want to continue [Y/N]?\r
-if /i not "%choice%" == "Y" goto end\r
-\r
-set buildtype=release\r
-if "%~n0" == "update-to-autobuild" set buildtype=autobuild\r
-\r
-set options=-Prtzil --delete-after --delete-excluded --stats\r
-\r
-if exist ..\..\..\.git goto xonoticdatagit\r
-if exist Xonotic goto xonoticswitchtonormal\r
-if exist Xonotic-high goto xonoticswitchtohigh\r
-if exist ..\..\..\data goto xonoticdata\r
-goto xonotic\r
-:xonoticdatagit\r
-       echo NOTE: this is a git repository download. Using the regular update method.\r
-       ..\..\..\all update\r
-       goto end\r
-:xonoticswitchtohigh\r
-       set PATH=misc\tools\rsync-updater;%PATH%\r
-       cd ..\..\..\r
-       if exist misc\tools\rsync-updater\rsync.exe goto xonoticdatahighfuzzy\r
-       echo FATAL: rsync not in misc\tools\rsync-updater. This update script cannot be used.\r
-       goto end\r
-:xonoticswitchtonormal\r
-       set PATH=misc\tools\rsync-updater;%PATH%\r
-       cd ..\..\..\r
-       if exist misc\tools\rsync-updater\rsync.exe goto xonoticdatanormalfuzzy\r
-       echo FATAL: rsync not in misc\tools\rsync-updater. This update script cannot be used.\r
-       goto end\r
-:xonoticdata\r
-       if exist ..\..\..\misc\tools\rsync-updater\rsync.exe goto xonoticdatarsync\r
-       echo FATAL: rsync not in misc\tools\rsync-updater. This update script cannot be used.\r
-       goto end\r
-:xonoticdatarsync\r
-       set PATH=misc\tools\rsync-updater;%PATH%\r
-       cd ..\..\..\r
-       if exist data\xonotic-rsync-data-high.pk3 goto xonoticdatahigh\r
-       if exist data\xonotic-*-data-high.pk3 goto xonoticdatahighfuzzy\r
-       if exist data\xonotic-rsync-data.pk3 goto xonoticdatanormal\r
-       if exist data\xonotic-*-data.pk3 goto xonoticdatanormalfuzzy\r
-       echo FATAL: unrecognized Xonotic build. This update script cannot be used.\r
-       goto end\r
-:xonoticdatahigh\r
-               set package=Xonotic-high\r
-               goto endxonoticdata\r
-:xonoticdatahighfuzzy\r
-               set package=Xonotic-high\r
-               set options=%options% -y\r
-               goto endxonoticdata\r
-:xonoticdatanormal\r
-               set package=Xonotic\r
-               goto endxonoticdata\r
-:xonoticdatanormalfuzzy\r
-               set package=Xonotic\r
-               set options=%options% -y\r
-               goto endxonoticdata\r
-:endxonoticdata\r
-       set target=./\r
-       goto endxonotic\r
-:xonotic\r
-       set package=Xonotic\r
-       set target=Xonotic/\r
-       goto endxonotic\r
-:endxonotic\r
-set url=beta.xonotic.org/%buildtype%-%package%\r
-\r
-set excludes=\r
-if not "%XONOTIC_INCLUDE_ALL%" == "" goto endbit\r
-set excludes=%excludes% --exclude=/xonotic-linux*\r
-set excludes=%excludes% --exclude=/xonotic-osx-*\r
-set excludes=%excludes% --exclude=/Xonotic*.app\r
-set excludes=%excludes% --exclude=/gmqcc/gmqcc.linux*\r
-set excludes=%excludes% --exclude=/gmqcc/gmqcc.osx\r
-\r
-if "%ProgramFiles(x86)%" == "" goto bit32\r
-:bit64\r
-       if not "%XONOTIC_INCLUDE_32BIT%" == "" goto endbit\r
-       set excludes=%excludes% --exclude=/xonotic-x86.exe\r
-       set excludes=%excludes% --exclude=/xonotic-x86-dedicated.exe\r
-       set excludes=%excludes% --exclude=/gmqcc/gmqcc.exe\r
-       set excludes=%excludes% --exclude=/bin32\r
-       set excludes=%excludes% --exclude=/*.dll\r
-       goto endbit\r
-:bit32\r
-       set excludes=%excludes% --exclude=/xonotic.exe\r
-       set excludes=%excludes% --exclude=/xonotic-dedicated.exe\r
-       set excludes=%excludes% --exclude=/gmqcc/gmqcc-x64.exe\r
-       set excludes=%excludes% --exclude=/bin64\r
-       goto endbit\r
-:endbit\r
-\r
-cd %target%\r
-echo Updating %CD% from %url% ...\r
-%TEMP%\xonotic-rsync-updater\usr\bin\rsync %options% %excludes% rsync://%url%/ %target%\r
-\r
-:end\r
 pause\r
 :: hack: delete running batch file without error by deleting after batch exit\r
 (goto) 2>NUL & rmdir /s /q %TEMP%\xonotic-rsync-updater\r
index c48629fb4e1cfb6088ae587d6486ee7e40588207..930aebabaf3ac1e910f040c07d9e4d3a65135290 100755 (executable)
@@ -30,7 +30,10 @@ case "${0##*/}" in
                ;;
 esac
 
-options="-Prtzil --executability --delete-after --delete-excluded --stats"
+options="-Prtzil --delete-after --delete-excluded --stats"
+if [ "$OS" != "Windows_NT" ]; then
+       options="$options --executability"
+fi
 
 package="Xonotic"
 target="../../.."
@@ -67,7 +70,29 @@ fi
 url="beta.xonotic.org/$buildtype-$package"
 
 excludes=
-if [ -z "$XONOTIC_INCLUDE_ALL" ]; then
+if [ -n "$XONOTIC_INCLUDE_ALL" ]; then
+       : noot noot
+elif [ "$OS" = "Windows_NT" ]; then
+       excludes="$excludes --exclude=/xonotic-linux*"
+       excludes="$excludes --exclude=/xonotic-osx-*"
+       excludes="$excludes --exclude=/Xonotic*.app"
+       excludes="$excludes --exclude=/gmqcc/gmqcc.linux*"
+       excludes="$excludes --exclude=/gmqcc/gmqcc.osx"
+
+       if [ "$PROCESSOR_ARCHITECTURE" = AMD64 ]; then
+               if [ -z "$XONOTIC_INCLUDE_32BIT" ]; then
+               excludes="$excludes --exclude=/xonotic-x86.exe"
+               excludes="$excludes --exclude=/xonotic-x86-dedicated.exe"
+               excludes="$excludes --exclude=/xonotic-x86-wgl.exe"
+               excludes="$excludes --exclude=/bin32"
+               fi
+       else
+               excludes="$excludes --exclude=/xonotic.exe"
+               excludes="$excludes --exclude=/xonotic-dedicated.exe"
+               excludes="$excludes --exclude=/xonotic-wgl.exe"
+               excludes="$excludes --exclude=/bin64"
+       fi
+else
        excludes="$excludes --exclude=/*.exe"
        excludes="$excludes --exclude=/bin32"
        excludes="$excludes --exclude=/*.dll"
index 115a32db5ddb5ac2b308a341956b8aff610bd759..1c7aeb97ff3e8e71ee945734681349a2845a9651 100644 (file)
 @echo off\r
 setlocal\r
 \r
-if "%1" == "did-copy" goto copied\r
+if "%did_copy%" == "true" goto copied\r
 cd %~dp0\r
+:: Windows can't update .exe and .dll files while they're running,\r
+:: it can update the .bat file but that can cause execution glitches.\r
+:: Shell scripts can also glitch if updated while running\r
+:: but can be protected, which update-to-autobuild.sh and rsync-ssl are.\r
 rmdir /s /q %TEMP%\xonotic-rsync-updater  2>NUL\r
 mkdir %TEMP%\xonotic-rsync-updater\r
 copy /b %~nx0 %TEMP%\xonotic-rsync-updater\  >NUL\r
 :: windows has no cp -r equivalent, this seems least-bad\r
 robocopy usr %TEMP%\xonotic-rsync-updater\usr /e   >NUL\r
-%TEMP%\xonotic-rsync-updater\%~n0 did-copy\r
+set did_copy=true\r
+%TEMP%\xonotic-rsync-updater\%~n0 %*\r
 :: can only get here if above batch file couldn't be created\r
 pause\r
 exit /b\r
 \r
 :copied\r
+set PATH=%TEMP%\xonotic-rsync-updater\usr\bin;%PATH%\r
+:: $PATH $PWD $TEMP and $TMP get automatic cygwin path conversion but $0 doesn't,\r
+:: sourcing the main script and setting a custom $0 also works around broken symlink support.\r
+sh -c ". ./update-to-autobuild.sh" ./%~n0.sh %*\r
 \r
-set /p choice=This script will DELETE any custom files in the Xonotic folder. Do you want to continue [Y/N]?\r
-if /i not "%choice%" == "Y" goto end\r
-\r
-set buildtype=release\r
-if "%~n0" == "update-to-autobuild" set buildtype=autobuild\r
-\r
-set options=-Prtzil --delete-after --delete-excluded --stats\r
-\r
-if exist ..\..\..\.git goto xonoticdatagit\r
-if exist ..\..\..\data goto xonoticdata\r
-if exist Xonotic goto xonoticswitchtonormal\r
-if exist Xonotic-high goto xonoticswitchtohigh\r
-goto xonotic\r
-:xonoticdatagit\r
-       echo NOTE: this is a git repository download. Using the regular update method.\r
-       ..\..\..\all update\r
-       goto end\r
-:xonoticswitchtohigh\r
-       set PATH=misc\tools\rsync-updater;%PATH%\r
-       cd ..\..\..\r
-       if exist misc\tools\rsync-updater\rsync.exe goto xonoticdatahighfuzzy\r
-       echo FATAL: rsync not in misc\tools\rsync-updater. This update script cannot be used.\r
-       goto end\r
-:xonoticswitchtonormal\r
-       set PATH=misc\tools\rsync-updater;%PATH%\r
-       cd ..\..\..\r
-       if exist misc\tools\rsync-updater\rsync.exe goto xonoticdatanormalfuzzy\r
-       echo FATAL: rsync not in misc\tools\rsync-updater. This update script cannot be used.\r
-       goto end\r
-:xonoticdata\r
-       if exist ..\..\..\misc\tools\rsync-updater\rsync.exe goto xonoticdatarsync\r
-       echo FATAL: rsync not in misc\tools\rsync-updater. This update script cannot be used.\r
-       goto end\r
-:xonoticdatarsync\r
-       set PATH=misc\tools\rsync-updater;%PATH%\r
-       cd ..\..\..\r
-       if exist data\xonotic-rsync-data-high.pk3 goto xonoticdatahigh\r
-       if exist data\xonotic-*-data-high.pk3 goto xonoticdatahighfuzzy\r
-       if exist data\xonotic-rsync-data.pk3 goto xonoticdatanormal\r
-       if exist data\xonotic-*-data.pk3 goto xonoticdatanormalfuzzy\r
-       echo FATAL: unrecognized Xonotic build. This update script cannot be used.\r
-       goto end\r
-:xonoticdatahigh\r
-               set package=Xonotic-high\r
-               goto endxonoticdata\r
-:xonoticdatahighfuzzy\r
-               set package=Xonotic-high\r
-               set options=%options% -y\r
-               goto endxonoticdata\r
-:xonoticdatanormal\r
-               set package=Xonotic\r
-               goto endxonoticdata\r
-:xonoticdatanormalfuzzy\r
-               set package=Xonotic\r
-               set options=%options% -y\r
-               goto endxonoticdata\r
-:endxonoticdata\r
-       set target=./\r
-       goto endxonotic\r
-:xonotic\r
-       set package=Xonotic\r
-       set target=Xonotic/\r
-       goto endxonotic\r
-:endxonotic\r
-set url=beta.xonotic.org/%buildtype%-%package%\r
-\r
-set excludes=\r
-if not "%XONOTIC_INCLUDE_ALL%" == "" goto endbit\r
-set excludes=%excludes% --exclude=/xonotic-linux*\r
-set excludes=%excludes% --exclude=/xonotic-osx-*\r
-set excludes=%excludes% --exclude=/Xonotic*.app\r
-set excludes=%excludes% --exclude=/gmqcc/gmqcc.linux*\r
-set excludes=%excludes% --exclude=/gmqcc/gmqcc.osx\r
-\r
-if "%ProgramFiles(x86)%" == "" goto bit32\r
-:bit64\r
-       if not "%XONOTIC_INCLUDE_32BIT%" == "" goto endbit\r
-       set excludes=%excludes% --exclude=/xonotic-x86.exe\r
-       set excludes=%excludes% --exclude=/xonotic-x86-dedicated.exe\r
-       set excludes=%excludes% --exclude=/gmqcc/gmqcc.exe\r
-       set excludes=%excludes% --exclude=/bin32\r
-       set excludes=%excludes% --exclude=/*.dll\r
-       goto endbit\r
-:bit32\r
-       set excludes=%excludes% --exclude=/xonotic.exe\r
-       set excludes=%excludes% --exclude=/xonotic-dedicated.exe\r
-       set excludes=%excludes% --exclude=/gmqcc/gmqcc-x64.exe\r
-       set excludes=%excludes% --exclude=/bin64\r
-       goto endbit\r
-:endbit\r
-\r
-cd %target%\r
-echo Updating %CD% from %url% ...\r
-%TEMP%\xonotic-rsync-updater\usr\bin\rsync %options% %excludes% rsync://%url%/ %target%\r
-\r
-:end\r
 pause\r
 :: hack: delete running batch file without error by deleting after batch exit\r
 (goto) 2>NUL & rmdir /s /q %TEMP%\xonotic-rsync-updater\r