diff --git a/code/ryzom/client/src/login_patch.cpp b/code/ryzom/client/src/login_patch.cpp index 8d4088d13..40ab45af5 100644 --- a/code/ryzom/client/src/login_patch.cpp +++ b/code/ryzom/client/src/login_patch.cpp @@ -818,12 +818,10 @@ void CPatchManager::createBatchFile(CProductDescriptionForClient &descFile, bool #ifdef NL_OS_WINDOWS // only fix backslashes for .bat batchRelativeDstPath = CPath::standardizeDosPath(batchRelativeDstPath); -#endif - // write windows .bat format else write sh format -#ifdef NL_OS_WINDOWS - string realDstPath = toString("\"%%DSTPATH%%\\%s\"", batchRelativeDstPath.c_str()); - string realSrcPath = toString("\"%%SRCPATH%%\\%s\"", FileName.c_str()); + // use DSTPATH and SRCPATH variables and append filenames + string realDstPath = toString("\"%%ROOTPATH%%\\%s\"", batchRelativeDstPath.c_str()); + string realSrcPath = toString("\"%%UNPACKPATH%%\\%s\"", FileName.c_str()); content += toString(":loop%u\n", nblab); content += toString("attrib -r -a -s -h %s\n", realDstPath.c_str()); @@ -831,6 +829,10 @@ void CPatchManager::createBatchFile(CProductDescriptionForClient &descFile, bool content += toString("if exist %s goto loop%u\n", realDstPath.c_str(), nblab); content += toString("move %s %s\n", realSrcPath.c_str(), realDstPath.c_str()); #else + // use DSTPATH and SRCPATH variables and append filenames + string realDstPath = toString("\"$ROOTPATH\\%s\"", batchRelativeDstPath.c_str()); + string realSrcPath = toString("\"$UNPACKPATH\\%s\"", FileName.c_str()); + content += toString("rm -rf %s\n", realDstPath.c_str()); // TODO: add test of returned $? content += toString("mv %s %s\n", realSrcPath.c_str(), realDstPath.c_str()); @@ -869,9 +871,9 @@ void CPatchManager::createBatchFile(CProductDescriptionForClient &descFile, bool if (!succeeded) { #ifdef NL_OS_WINDOWS - patchContent += toString("del \"%s\"\n", CPath::standardizeDosPath(vFileList[i]).c_str()); + patchContent += toString("del \"%%ROOTPATH%%\\patch\\%s\"\n", vFileList[i].c_str()); #else - patchContent += toString("rm -f \"%s\"\n", CPath::standardizePath(vFileList[i]).c_str()); + patchContent += toString("rm -f \"$ROOTPATH/patch/%s\"\n", vFileList[i].c_str()); #endif } } @@ -883,10 +885,10 @@ void CPatchManager::createBatchFile(CProductDescriptionForClient &descFile, bool content += patchContent; - content += toString("rd /Q /S \"%s\"\n", patchDirectory.c_str()); - content += toString("if exist \"%s\" goto looppatch\n", patchDirectory.c_str()); + content += "rd /Q /S \"%%ROOTPATH%%\\patch\"\n"; + content += "if exist \"%%ROOTPATH%%\\patch\" goto looppatch\n"; #else - content += toString("rm -rf \"%s\"\n", patchDirectory.c_str()); + content += "rm -rf \"$ROOTPATH/patch\"\n"); #endif } else @@ -914,22 +916,22 @@ void CPatchManager::createBatchFile(CProductDescriptionForClient &descFile, bool //use bat if windows if not use sh #ifdef NL_OS_WINDOWS contentPrefix += "@echo off\n"; - contentPrefix += "set RYZOM_CLIENT=%1\n"; - contentPrefix += "set SRCPATH=%2\n"; - contentPrefix += "set DSTPATH=%3\n"; + contentPrefix += "set RYZOM_CLIENT=\"%1\"\n"; + contentPrefix += "set UNPACKPATH=\"%2\"\n"; + contentPrefix += "set ROOTPATH=\"%3\"\n"; contentPrefix += "set LOGIN=%4\n"; contentPrefix += "set PASSWORD=%5\n"; contentPrefix += "set SHARDID=%6\n"; - contentPrefix += toString("set UPGRADE_FILE=%%DSTPATH%%\\%s\n", UpgradeBatchFilename.c_str()); + contentPrefix += toString("set UPGRADE_FILE=\"%%ROOTPATH%%\\%s\"\n", UpgradeBatchFilename.c_str()); #else contentPrefix += "#!/bin/sh\n"; - contentPrefix += "RYZOM_CLIENT=$1\n"; - contentPrefix += "SRCPATH=$2\n"; - contentPrefix += "DSTPATH=$3\n"; + contentPrefix += "RYZOM_CLIENT=\"$1\"\n"; + contentPrefix += "UNPACKPATH=\"$2\"\n"; + contentPrefix += "ROOTPATH=\"$3\"\n"; contentPrefix += "LOGIN=$4\n"; contentPrefix += "PASSWORD=$5\n"; contentPrefix += "SHARDID=$6\n"; - contentPrefix += toString("UPGRADE_FILE=$DSTPATH\\%s\n", UpgradeBatchFilename.c_str()); + contentPrefix += toString("UPGRADE_FILE=\"$ROOTPATH\\%s\"\n", UpgradeBatchFilename.c_str()); #endif contentPrefix += "\n"; @@ -947,26 +949,24 @@ void CPatchManager::createBatchFile(CProductDescriptionForClient &descFile, bool if (wantRyzomRestart) { - string contentSuffix; - -#ifdef NL_OS_WINDOWS - // launch upgrade script if present (it'll execute additional steps like moving or deleting files) - contentSuffix += "if exist \"%UPGRADE_FILE%\" call \"%UPGRADE_FILE%\"\n"; - // client shouldn't be in memory anymore else it couldn't be overwritten - contentSuffix += toString("start \"\" /D \"%%DSTPATH%%\" \"%%RYZOM_CLIENT%%\" %s %%LOGIN%% %%PASSWORD%% %%SHARDID%%\n", additionalParams.c_str()); + contentSuffix += toString("start \"\" /D \"%%ROOTPATH%%\" \"%%RYZOM_CLIENT%%\" %s %%LOGIN%% %%PASSWORD%% %%SHARDID%%\n", additionalParams.c_str()); + } #else // wait until client not in memory anymore contentSuffix += toString("until ! pgrep %s > /dev/null; do sleep 1; done\n", CFile::getFilename(RyzomFilename).c_str()); + } - // launch upgrade script if present (it'll execute additional steps like moving or deleting files) - contentSuffix += "if [ -e \"$UPGRADE_FILE\" ]; then chmod +x \"$UPGRADE_FILE\" && \"$UPGRADE_FILE\"; fi\n"; + // launch upgrade script if present (it'll execute additional steps like moving or deleting files) + contentSuffix += "if [ -e \"$UPGRADE_FILE\" ]; then chmod +x \"$UPGRADE_FILE\" && \"$UPGRADE_FILE\"; fi\n"; - // be sure file is executable - contentSuffix += "chmod +x \"$RYZOM_CLIENT\"\n"); + // be sure file is executable + contentSuffix += "chmod +x \"$RYZOM_CLIENT\"\n"; + if (wantRyzomRestart) + { // change to previous client directory - contentSuffix += "cd \"$DSTPATH\"\n"); + contentSuffix += "cd \"$ROOTPATH\"\n"; // launch new client contentSuffix += toString("\"$RYZOM_CLIENT\" %s $LOGIN $PASSWORD $SHARDID\n", additionalParams.c_str());