@setlocal
:: This script installs the test perforce repository
:: for training purposes.
:: Find the root directory of this script - seems to work fine for UNC paths now as well as mapped SCRIPT_PATHs
set SCRIPT_PATH=%~dp0
set INSTALL_PATH=%SCRIPT_PATH%..\testroot
ECHO SCRIPT_PATH is %SCRIPT_PATH%
set P4ROOT=%INSTALL_PATH%
mkdir "%P4ROOT%"
cd "%P4ROOT%"
:: Remove existing installation
del /f/q db.*
:: The following are in case of a reinstall
attrib -r checkpoint
:: Unzipper
copy "%SCRIPT_PATH%7za.exe" .
:: This is the zip file containing the sample depot, checkpoint etc
copy "%SCRIPT_PATH%Training.zip" .
copy "%SCRIPT_PATH%p4.exe" .
copy "%SCRIPT_PATH%p4d.exe" .
copy "%SCRIPT_PATH%server.bat" .
:: User can now remove the USB stick as all files are copied!
:: Rest of the work is done in this separate .bat file.
set UNZIP="%p4root%\7za.exe"
:: Unzip depot files etc, also checkpoint(s)
%UNZIP% x -y -tzip Training.zip
"%p4root%\p4d.exe" -r "%p4root%" -jr "%p4root%\checkpoint" > nul 2>&1
"%p4root%\p4d.exe" -r "%p4root%" -xu
call server.bat
:finish
@endlocal