71 lines
No EOL
1.6 KiB
Batchfile
71 lines
No EOL
1.6 KiB
Batchfile
@echo off
|
|
setlocal EnableExtensions EnableDelayedExpansion
|
|
|
|
echo Checking for pwsh...
|
|
set _my_shell=pwsh
|
|
|
|
REM Check if pwsh.exe exists
|
|
where /q !_my_shell!
|
|
if !errorlevel! neq 0 (
|
|
echo pwsh not found. Falling back to powershell...
|
|
REM If pwsh is not found, set to powershell
|
|
set _my_shell=powershell
|
|
|
|
REM Check if powershell.exe exists
|
|
echo Checking for powershell...
|
|
where /q !_my_shell!
|
|
if !errorlevel! neq 0 (
|
|
echo.Error: Powershell not found!
|
|
pause
|
|
exit /B 1
|
|
) else (
|
|
echo powershell found.
|
|
)
|
|
) else (
|
|
echo pwsh found.
|
|
)
|
|
|
|
echo Using !_my_shell! for script execution.
|
|
|
|
REM Check if patch-config.txt exists
|
|
if not exist patch-config.txt (
|
|
echo "Config file (patch-config.txt) not found! Assuming no patching needed."
|
|
pause
|
|
exit /b
|
|
)
|
|
|
|
REM Read configuration from file
|
|
for /f "tokens=1,2 delims==" %%a in (patch-config.txt) do (
|
|
if "%%a"=="username" set "username=%%b"
|
|
if "%%a"=="repo" set "repo=%%b"
|
|
if "%%a"=="branch" set "branch=%%b"
|
|
)
|
|
goto download_extract
|
|
endlocal
|
|
pause
|
|
exit /b
|
|
|
|
:download_extract
|
|
REM Download zip file
|
|
echo "Downloading latest patch..."
|
|
!_my_shell! -Command "Invoke-WebRequest -Uri 'https://gitgud.io/%username%/%repo%/-/archive/%branch%/%repo%-%branch%.zip' -OutFile 'repo.zip'"
|
|
if !errorlevel! neq 0 (
|
|
pause
|
|
exit /b
|
|
)
|
|
|
|
REM Extract contents, overwriting conflicts
|
|
echo "Extracting..."
|
|
!_my_shell! -Command "Expand-Archive -Path '.\repo.zip' -DestinationPath '.' -Force"
|
|
echo "Applying patch..."
|
|
xcopy /s /e /y "%repo%-%branch%\*" "."
|
|
|
|
REM Clean up
|
|
echo "Cleaning up..."
|
|
del repo.zip
|
|
rmdir /s /q "%repo%-%branch%"
|
|
|
|
REM Store latest SHA for next check
|
|
endlocal
|
|
pause
|
|
exit /b |