# HG changeset patch # User Matthew Lagoe@MatthewLagoe-PC.int.ops.subrigo.net # Date 1342656257 25200 # Node ID 7ef95c7553dea469d6b49c2749a5ce598ec644ea # Parent 67f3c68addd4b7f00f77237de25eedee25ed5266 Updater Patch diff -r 67f3c68addd4 -r 7ef95c7553de code/ryzom/client/src/CMakeLists.txt --- a/code/ryzom/client/src/CMakeLists.txt Wed Apr 11 15:30:38 2012 +0200 +++ b/code/ryzom/client/src/CMakeLists.txt Wed Jul 18 17:04:17 2012 -0700 @@ -1,8 +1,5 @@ # These are Windows/MFC apps -IF(WIN32) -# ADD_SUBDIRECTORY(bug_report) SET(SEVENZIP_LIBRARY "ryzom_sevenzip") -ENDIF(WIN32) ADD_SUBDIRECTORY(client_sheets) ADD_SUBDIRECTORY(seven_zip) diff -r 67f3c68addd4 -r 7ef95c7553de code/ryzom/client/src/client_cfg.cpp --- a/code/ryzom/client/src/client_cfg.cpp Wed Apr 11 15:30:38 2012 +0200 +++ b/code/ryzom/client/src/client_cfg.cpp Wed Jul 18 17:04:17 2012 -0700 @@ -418,11 +418,7 @@ SelectionFXSize = 0.8f; // only force patching under Windows by default -#ifdef NL_OS_WINDOWS PatchWanted = true; -#else - PatchWanted = false; -#endif PatchUrl = ""; PatchletUrl = ""; PatchVersion = ""; diff -r 67f3c68addd4 -r 7ef95c7553de code/ryzom/client/src/login_patch.cpp --- a/code/ryzom/client/src/login_patch.cpp Wed Apr 11 15:30:38 2012 +0200 +++ b/code/ryzom/client/src/login_patch.cpp Wed Jul 18 17:04:17 2012 -0700 @@ -18,6 +18,9 @@ // Includes // +#include +#include + #include "stdpch.h" #include @@ -38,9 +41,7 @@ #include "nel/misc/big_file.h" #include "nel/misc/i18n.h" -#ifdef NL_OS_WINOWS - #define NL_USE_SEVENZIP 1 -#endif +#define NL_USE_SEVENZIP 1 // 7 zip includes #ifdef NL_USE_SEVENZIP @@ -740,6 +741,7 @@ // **************************************************************************** void CPatchManager::createBatchFile(CProductDescriptionForClient &descFile, bool wantRyzomRestart, bool useBatchFile) { + uint nblab = 0; FILE *fp = NULL; @@ -753,7 +755,12 @@ string err = toString("Can't open file '%s' for writing: code=%d %s (error code 29)", UpdateBatchFilename.c_str(), errno, strerror(errno)); throw Exception (err); } + //use bat if windows if not use sh + #ifdef NL_OS_WINDOWS fprintf(fp, "@echo off\n"); + #else + fprintf(fp, "#!/bin/sh\n"); + #endif } // Unpack files with category ExtractPath non empty @@ -808,8 +815,13 @@ if (useBatchFile) { + #ifdef NL_OS_WINDOWS SrcPath = CPath::standardizeDosPath(SrcPath); DstPath = CPath::standardizeDosPath(DstPath); + #else + SrcPath = CPath::standardizePath(SrcPath); + DstPath = CPath::standardizePath(DstPath); + #endif } std::string SrcName = SrcPath + vFilenames[fff]; @@ -817,11 +829,19 @@ if (useBatchFile) { + //write windows .bat format else write sh format + #ifdef NL_OS_WINDOWS fprintf(fp, ":loop%u\n", nblab); fprintf(fp, "attrib -r -a -s -h %s\n", DstName.c_str()); fprintf(fp, "del %s\n", DstName.c_str()); fprintf(fp, "if exist %s goto loop%u\n", DstName.c_str(), nblab); fprintf(fp, "move %s %s\n", SrcName.c_str(), DstPath.c_str()); + #else + fprintf(fp, "chmod 777 %s\n", DstName.c_str()); + fprintf(fp, "rm -rf %s\n", DstName.c_str()); + fprintf(fp, "mv %s %s\n", SrcName.c_str(), DstPath.c_str()); + #endif + } else { @@ -838,18 +858,24 @@ // Finalize batch file if (NLMISC::CFile::isExists("patch") && NLMISC::CFile::isDirectory("patch")) { + #ifdef NL_OS_WINDOWS if (useBatchFile) { fprintf(fp, ":looppatch\n"); } - + #endif + vector vFileList; CPath::getPathContent ("patch", false, false, true, vFileList, NULL, false); for(uint32 i = 0; i < vFileList.size(); ++i) { if (useBatchFile) { + #ifdef NL_OS_WINDOWS fprintf(fp, "del %s\n", CPath::standardizeDosPath(vFileList[i]).c_str()); + #else + fprintf(fp, "rm -f %s\n", CPath::standardizePath(vFileList[i]).c_str()); + #endif } else { @@ -859,8 +885,12 @@ if (useBatchFile) { + #ifdef NL_OS_WINDOWS fprintf(fp, "rd /Q /S patch\n"); fprintf(fp, "if exist patch goto looppatch\n"); + #else + fprintf(fp, "rm -rf patch\n"); + #endif } else { @@ -872,7 +902,11 @@ { if (wantRyzomRestart) { + #ifdef NL_OS_WINDOWS fprintf(fp, "start %s %%1 %%2 %%3\n", RyzomFilename.c_str()); + #else + fprintf(fp, "./%s $1 $2 $3\n", RyzomFilename.c_str()); + #endif } bool writeError = ferror(fp) != 0; @@ -887,6 +921,7 @@ throw NLMISC::EWriteError(UpdateBatchFilename.c_str()); } } + } // **************************************************************************** @@ -944,7 +979,36 @@ // CloseHandle( pi.hThread ); #else - // TODO for Linux and Mac OS + // Start the child process. + bool r2Mode = false; + #ifndef RY_BG_DOWNLOADER + r2Mode = ClientCfg.R2Mode; + #endif + string strCmdLine; + + strCmdLine = "./" + UpdateBatchFilename; + + chmod(strCmdLine.c_str(), S_IRWXU); + if (r2Mode) + { + if (execl(strCmdLine.c_str(), LoginLogin.c_str(), LoginPassword.c_str()) == -1) + { + int errsv = errno; + nlerror("Execl Error: %d %s", errsv, strCmdLine.c_str(), (char *) NULL); + } else { + nlinfo("Ran batch file r2Mode Success"); + } + } + else + { + if (execl(strCmdLine.c_str(), LoginLogin.c_str(), LoginPassword.c_str(), LoginShardId, (char *) NULL) == -1) + { + int errsv = errno; + nlerror("Execl r2mode Error: %d %s", errsv, strCmdLine.c_str()); + } else { + nlinfo("Ran batch file Success"); + } + } #endif // exit(0);