Test 2
This commit is contained in:
parent
c24887120c
commit
234157ab04
5 changed files with 70 additions and 58 deletions
|
|
@ -2,13 +2,13 @@
|
|||
setlocal
|
||||
|
||||
REM Copy GAMEUPDATE.bat to a new file
|
||||
copy patch.bat patch2.bat
|
||||
copy "gameupdate\patch.bat" "gameupdate\patch2.bat"
|
||||
|
||||
REM Run the new file
|
||||
call patch2.bat
|
||||
call "gameupdate\patch2.bat"
|
||||
|
||||
REM Delete the new file
|
||||
del patch2.bat
|
||||
del "gameupdate\patch2.bat"
|
||||
|
||||
endlocal
|
||||
@echo on
|
||||
|
|
@ -3,11 +3,11 @@
|
|||
# Enable error handling
|
||||
set -e
|
||||
|
||||
# Copy patch.bat to a new file
|
||||
cp patch.sh patch2.sh
|
||||
# Copy patch.sh to a new file in gameupdate
|
||||
cp "gameupdate/patch.sh" "gameupdate/patch2.sh"
|
||||
|
||||
# Run the new file
|
||||
bash patch2.sh
|
||||
bash "gameupdate/patch2.sh"
|
||||
|
||||
# Delete the new file
|
||||
rm patch2.sh
|
||||
rm "gameupdate/patch2.sh"
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
username=dazed-translations
|
||||
repo=exorcist-evangeline
|
||||
branch=main
|
||||
branch=main
|
||||
|
|
@ -1,6 +1,14 @@
|
|||
@echo off
|
||||
setlocal EnableExtensions EnableDelayedExpansion
|
||||
|
||||
REM Determine important paths
|
||||
set "SCRIPT_DIR=%~dp0"
|
||||
set "ROOT_DIR=%CD%"
|
||||
set "CONFIG_FILE=%SCRIPT_DIR%patch-config.txt"
|
||||
|
||||
echo Using root directory: "%ROOT_DIR%"
|
||||
echo Using config: "%CONFIG_FILE%"
|
||||
|
||||
echo Checking for pwsh...
|
||||
set _my_shell=pwsh
|
||||
|
||||
|
|
@ -27,15 +35,15 @@ if !errorlevel! neq 0 (
|
|||
|
||||
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."
|
||||
REM Check if patch-config.txt exists in gameupdate folder
|
||||
if not exist "%CONFIG_FILE%" (
|
||||
echo "Config file (gameupdate\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 (
|
||||
for /f "usebackq tokens=1,2 delims==" %%a in ("%CONFIG_FILE%") do (
|
||||
if "%%a"=="username" set "username=%%b"
|
||||
if "%%a"=="repo" set "repo=%%b"
|
||||
if "%%a"=="branch" set "branch=%%b"
|
||||
|
|
@ -43,20 +51,20 @@ for /f "tokens=1,2 delims==" %%a in (patch-config.txt) do (
|
|||
|
||||
REM Get the latest hash
|
||||
echo "Getting latest commit SHA hash"
|
||||
!_my_shell! -Command "(Invoke-RestMethod -Uri 'https://gitgud.io/api/v4/projects/%username%%%2F%repo%/repository/branches/%branch%').commit.id" > latest_patch_sha.txt
|
||||
!_my_shell! -Command "(Invoke-RestMethod -Uri 'https://gitgud.io/api/v4/projects/%username%%%2F%repo%/repository/branches/%branch%').commit.id" > "%ROOT_DIR%\latest_patch_sha.txt"
|
||||
|
||||
REM Read the latest SHA from the file
|
||||
set /p latest_patch_sha=<latest_patch_sha.txt
|
||||
set /p latest_patch_sha=<"%ROOT_DIR%\latest_patch_sha.txt"
|
||||
|
||||
REM Check if previous_patch_sha.txt exists
|
||||
if not exist previous_patch_sha.txt (
|
||||
REM Check if previous_patch_sha.txt exists in root
|
||||
if not exist "%ROOT_DIR%\previous_patch_sha.txt" (
|
||||
echo "Previous SHA hash not found!"
|
||||
echo "Assuming first time patching..."
|
||||
goto download_extract
|
||||
)
|
||||
|
||||
REM Read the stored SHA from previous check
|
||||
set /p previous_patch_sha=<previous_patch_sha.txt
|
||||
set /p previous_patch_sha=<"%ROOT_DIR%\previous_patch_sha.txt"
|
||||
|
||||
REM Trim whitespace from SHA strings
|
||||
set "previous_patch_sha=%previous_patch_sha: =%"
|
||||
|
|
@ -71,7 +79,7 @@ if "%latest_patch_sha%" neq "%previous_patch_sha%" (
|
|||
)
|
||||
|
||||
REM Delete latest_patch_sha.txt
|
||||
del latest_patch_sha.txt
|
||||
del "%ROOT_DIR%\latest_patch_sha.txt"
|
||||
|
||||
endlocal
|
||||
pause
|
||||
|
|
@ -80,42 +88,42 @@ exit /b
|
|||
:download_extract
|
||||
|
||||
REM Escape single quotes in paths
|
||||
set "escaped_cd=%CD:'=''%"
|
||||
set "escaped_root=%ROOT_DIR:'=''%"
|
||||
|
||||
REM Download zip file
|
||||
REM Download zip file to root
|
||||
echo "Downloading latest patch..."
|
||||
!_my_shell! -Command "Set-Location -LiteralPath '%escaped_cd%'; $ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest -Uri 'https://gitgud.io/%username%/%repo%/-/archive/%branch%/%repo%-%branch%.zip' -OutFile 'repo.zip'"
|
||||
!_my_shell! -Command "Set-Location -LiteralPath '%escaped_root%'; $ProgressPreference = 'SilentlyContinue'; 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
|
||||
REM Extract contents, overwriting conflicts into root
|
||||
echo "Extracting..."
|
||||
!_my_shell! -Command "Set-Location -LiteralPath '%escaped_cd%'; Expand-Archive -Path '.\repo.zip' -DestinationPath '.' -Force"
|
||||
!_my_shell! -Command "Set-Location -LiteralPath '%escaped_root%'; Expand-Archive -Path '.\repo.zip' -DestinationPath '.' -Force"
|
||||
if !errorlevel! neq 0 (
|
||||
echo Extraction failed!
|
||||
del repo.zip
|
||||
rmdir /s /q "%repo%-%branch%"
|
||||
del "%ROOT_DIR%\repo.zip"
|
||||
rmdir /s /q "%ROOT_DIR%\%repo%-%branch%"
|
||||
pause
|
||||
exit /b
|
||||
)
|
||||
echo "Applying patch..."
|
||||
xcopy /s /e /y "%repo%-%branch%\*" "."
|
||||
xcopy /s /e /y "%ROOT_DIR%\%repo%-%branch%\*" "%ROOT_DIR%\"
|
||||
if !errorlevel! neq 0 (
|
||||
echo Patch application failed!
|
||||
del repo.zip
|
||||
rmdir /s /q "%repo%-%branch%"
|
||||
del "%ROOT_DIR%\repo.zip"
|
||||
rmdir /s /q "%ROOT_DIR%\%repo%-%branch%"
|
||||
pause
|
||||
exit /b
|
||||
)
|
||||
REM Clean up
|
||||
echo "Cleaning up..."
|
||||
del repo.zip
|
||||
rmdir /s /q "%repo%-%branch%"
|
||||
del latest_patch_sha.txt
|
||||
REM Store latest SHA for next check
|
||||
echo %latest_patch_sha% > previous_patch_sha.txt
|
||||
del "%ROOT_DIR%\repo.zip"
|
||||
rmdir /s /q "%ROOT_DIR%\%repo%-%branch%"
|
||||
del "%ROOT_DIR%\latest_patch_sha.txt"
|
||||
REM Store latest SHA for next check in root
|
||||
echo %latest_patch_sha% > "%ROOT_DIR%\previous_patch_sha.txt"
|
||||
endlocal
|
||||
pause
|
||||
exit /b
|
||||
|
|
@ -1,5 +1,11 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
ROOT_DIR="$(pwd)"
|
||||
CONFIG_FILE="$SCRIPT_DIR/patch-config.txt"
|
||||
|
||||
check_dependency() {
|
||||
if ! command -v "$1" > /dev/null 2>&1; then
|
||||
echo "Error: '$1' is not installed. Please install it using 'pkg install $1'."
|
||||
|
|
@ -12,8 +18,6 @@ check_dependency jq
|
|||
check_dependency unzip
|
||||
check_dependency curl
|
||||
|
||||
CONFIG_FILE="patch-config.txt"
|
||||
|
||||
# Check if CONFIG_FILE exists
|
||||
if [ ! -f "$CONFIG_FILE" ]; then
|
||||
echo "Config file '$CONFIG_FILE' not found! Assuming no patching needed."
|
||||
|
|
@ -24,63 +28,63 @@ fi
|
|||
sed -i 's/\r$//' "$CONFIG_FILE"
|
||||
|
||||
# Debug information
|
||||
echo "Current directory: $(pwd)"
|
||||
echo "Config file path: $(pwd)/$CONFIG_FILE"
|
||||
echo "Root directory: $ROOT_DIR"
|
||||
echo "Config file path: $CONFIG_FILE"
|
||||
|
||||
# Read configuration from file
|
||||
. "$(pwd)/$CONFIG_FILE"
|
||||
. "$CONFIG_FILE"
|
||||
|
||||
# Get the latest hash
|
||||
echo "Getting latest commit SHA hash"
|
||||
latest_patch_sha=$(curl -s "https://gitgud.io/api/v4/projects/$username%2F$repo/repository/branches/$branch" | jq -r '.commit.id')
|
||||
|
||||
download_extract() {
|
||||
# Download zip file
|
||||
# Download zip file into root
|
||||
echo "Downloading latest patch..."
|
||||
curl -sL "https://gitgud.io/$username/$repo/-/archive/$branch/$repo-$branch.zip" -o repo.zip
|
||||
curl -sL "https://gitgud.io/$username/$repo/-/archive/$branch/$repo-$branch.zip" -o "$ROOT_DIR/repo.zip"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Download failed!"
|
||||
rm -f repo.zip
|
||||
rm -rf "$repo-$branch"
|
||||
rm -f "$ROOT_DIR/repo.zip"
|
||||
rm -rf "$ROOT_DIR/$repo-$branch"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Extract contents, overwriting conflicts
|
||||
# Extract contents, overwriting conflicts into root
|
||||
echo "Extracting..."
|
||||
unzip -qo repo.zip
|
||||
unzip -qo "$ROOT_DIR/repo.zip" -d "$ROOT_DIR"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Extraction failed!"
|
||||
rm -f repo.zip
|
||||
rm -rf "$repo-$branch"
|
||||
rm -f "$ROOT_DIR/repo.zip"
|
||||
rm -rf "$ROOT_DIR/$repo-$branch"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "Applying patch..."
|
||||
cp -r "$repo-$branch/"* .
|
||||
cp -r "$ROOT_DIR/$repo-$branch/"* "$ROOT_DIR/"
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Patch application failed!"
|
||||
rm -f repo.zip
|
||||
rm -rf "$repo-$branch"
|
||||
rm -f "$ROOT_DIR/repo.zip"
|
||||
rm -rf "$ROOT_DIR/$repo-$branch"
|
||||
return 1
|
||||
fi
|
||||
|
||||
echo "Cleaning up..."
|
||||
rm repo.zip
|
||||
rm -rf "$repo-$branch"
|
||||
rm -f latest_patch_sha.txt
|
||||
rm -f "$ROOT_DIR/repo.zip"
|
||||
rm -rf "$ROOT_DIR/$repo-$branch"
|
||||
rm -f "$ROOT_DIR/latest_patch_sha.txt"
|
||||
|
||||
# Store latest SHA for next check
|
||||
echo "$latest_patch_sha" > previous_patch_sha.txt
|
||||
# Store latest SHA for next check in root
|
||||
echo "$latest_patch_sha" > "$ROOT_DIR/previous_patch_sha.txt"
|
||||
}
|
||||
|
||||
# Check if previous_patch_sha.txt exists
|
||||
if [ ! -f previous_patch_sha.txt ]; then
|
||||
# Check if previous_patch_sha.txt exists in root
|
||||
if [ ! -f "$ROOT_DIR/previous_patch_sha.txt" ]; then
|
||||
echo "Previous SHA hash not found!"
|
||||
echo "Assuming first time patching..."
|
||||
download_extract
|
||||
else
|
||||
# Read the stored SHA from previous check
|
||||
previous_patch_sha=$(cat previous_patch_sha.txt)
|
||||
previous_patch_sha=$(cat "$ROOT_DIR/previous_patch_sha.txt")
|
||||
|
||||
# Compare trimmed SHAs
|
||||
if [ "$latest_patch_sha" != "$previous_patch_sha" ]; then
|
||||
|
|
@ -89,4 +93,4 @@ else
|
|||
else
|
||||
echo "Patch is up to date."
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
Loading…
Reference in a new issue