Added linux patcher!

This commit is contained in:
botanic 2014-02-07 20:10:07 -08:00
parent 6fb36fca8f
commit d63ca8ff3d
4 changed files with 115 additions and 23 deletions

View file

@ -237,6 +237,7 @@ MACRO(NL_SETUP_DEFAULT_OPTIONS)
OPTION(WITH_PCH "With Precompiled Headers" ON ) OPTION(WITH_PCH "With Precompiled Headers" ON )
OPTION(FINAL_VERSION "Build in Final Version mode" ON ) OPTION(FINAL_VERSION "Build in Final Version mode" ON )
OPTION(WITH_PERFHUD "Build with NVIDIA PerfHUD support" OFF ) OPTION(WITH_PERFHUD "Build with NVIDIA PerfHUD support" OFF )
OPTION(WITH_PATCH_SUPPORT "Build with in-game Patch Support" OFF )
# Default to static building on Windows. # Default to static building on Windows.
IF(WIN32) IF(WIN32)

View file

@ -423,11 +423,11 @@ CClientConfig::CClientConfig()
SelectionFXSize = 0.8f; SelectionFXSize = 0.8f;
// only force patching under Windows by default // only force patching under Windows by default
#ifdef NL_OS_WINDOWS #if WITH_PATCH_SUPPORT
PatchWanted = true; PatchWanted = true;
#else #else
PatchWanted = false; PatchWanted = false;
#endif #endif
PatchUrl = ""; PatchUrl = "";
PatchletUrl = ""; PatchletUrl = "";
PatchVersion = ""; PatchVersion = "";
@ -846,7 +846,6 @@ void CClientConfig::setValues()
if (nlstricmp(varPtr->asString(), "Auto") == 0 || nlstricmp(varPtr->asString(), "0") == 0) ClientCfg.Driver3D = CClientConfig::DrvAuto; if (nlstricmp(varPtr->asString(), "Auto") == 0 || nlstricmp(varPtr->asString(), "0") == 0) ClientCfg.Driver3D = CClientConfig::DrvAuto;
else if (nlstricmp(varPtr->asString(), "OpenGL") == 0 || nlstricmp(varPtr->asString(), "1") == 0) ClientCfg.Driver3D = CClientConfig::OpenGL; else if (nlstricmp(varPtr->asString(), "OpenGL") == 0 || nlstricmp(varPtr->asString(), "1") == 0) ClientCfg.Driver3D = CClientConfig::OpenGL;
else if (nlstricmp(varPtr->asString(), "Direct3D") == 0 || nlstricmp(varPtr->asString(), "2") == 0) ClientCfg.Driver3D = CClientConfig::Direct3D; else if (nlstricmp(varPtr->asString(), "Direct3D") == 0 || nlstricmp(varPtr->asString(), "2") == 0) ClientCfg.Driver3D = CClientConfig::Direct3D;
else if (nlstricmp(varPtr->asString(), "OpenGLES") == 0 || nlstricmp(varPtr->asString(), "3") == 0) ClientCfg.Driver3D = CClientConfig::OpenGLES;
} }
else else
cfgWarning ("Default value used for 'Driver3D' !!!"); cfgWarning ("Default value used for 'Driver3D' !!!");
@ -892,7 +891,9 @@ void CClientConfig::setValues()
READ_STRING_FV(CreateAccountURL) READ_STRING_FV(CreateAccountURL)
READ_STRING_FV(EditAccountURL) READ_STRING_FV(EditAccountURL)
READ_STRING_FV(ConditionsTermsURL) READ_STRING_FV(ConditionsTermsURL)
READ_STRING_FV(BetaAccountURL)
READ_STRING_FV(ForgetPwdURL) READ_STRING_FV(ForgetPwdURL)
READ_STRING_FV(FreeTrialURL)
READ_STRING_FV(LoginSupportURL) READ_STRING_FV(LoginSupportURL)
#ifndef RZ_NO_CLIENT #ifndef RZ_NO_CLIENT
@ -1057,11 +1058,18 @@ void CClientConfig::setValues()
///////////////////////// /////////////////////////
// NEW PATCHING SYSTEM // // NEW PATCHING SYSTEM //
READ_BOOL_FV(PatchWanted) READ_BOOL_FV(PatchWanted)
READ_STRING_FV(PatchServer)
READ_STRING_FV(PatchUrl)
READ_STRING_FV(PatchVersion)
READ_STRING_FV(RingReleaseNotePath)
READ_STRING_FV(ReleaseNotePath)
READ_BOOL_DEV(PatchWanted)
READ_STRING_DEV(PatchServer)
READ_STRING_DEV(PatchUrl) READ_STRING_DEV(PatchUrl)
READ_STRING_DEV(PatchVersion) READ_STRING_DEV(PatchVersion)
READ_STRING_DEV(RingReleaseNotePath) READ_STRING_DEV(RingReleaseNotePath)
READ_STRING_DEV(ReleaseNotePath) READ_STRING_DEV(ReleaseNotePath)
READ_STRING_FV(PatchServer)
///////////////////////// /////////////////////////
// NEW PATCHLET SYSTEM // // NEW PATCHLET SYSTEM //

View file

@ -18,6 +18,14 @@
// Includes // Includes
// //
#include <sys/stat.h>
#ifdef NL_OS_WINDOWS
//windows doesnt have unistd.h
#else
#include <unistd.h>
#endif
#include "stdpch.h" #include "stdpch.h"
#include <memory> #include <memory>
@ -38,9 +46,7 @@
#include "nel/misc/big_file.h" #include "nel/misc/big_file.h"
#include "nel/misc/i18n.h" #include "nel/misc/i18n.h"
#ifdef NL_OS_WINOWS #define NL_USE_SEVENZIP 1
#define NL_USE_SEVENZIP 1
#endif
// 7 zip includes // 7 zip includes
#ifdef NL_USE_SEVENZIP #ifdef NL_USE_SEVENZIP
@ -740,6 +746,7 @@ void CPatchManager::deleteBatchFile()
// **************************************************************************** // ****************************************************************************
void CPatchManager::createBatchFile(CProductDescriptionForClient &descFile, bool wantRyzomRestart, bool useBatchFile) void CPatchManager::createBatchFile(CProductDescriptionForClient &descFile, bool wantRyzomRestart, bool useBatchFile)
{ {
uint nblab = 0; uint nblab = 0;
FILE *fp = NULL; FILE *fp = NULL;
@ -753,7 +760,14 @@ void CPatchManager::createBatchFile(CProductDescriptionForClient &descFile, bool
string err = toString("Can't open file '%s' for writing: code=%d %s (error code 29)", UpdateBatchFilename.c_str(), errno, strerror(errno)); 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); throw Exception (err);
} }
//use bat if windows if not use sh
#ifdef NL_OS_WINDOWS
fprintf(fp, "@echo off\n"); fprintf(fp, "@echo off\n");
#else NL_OS_MAC
//mac patcher doesn't work yet
#else
fprintf(fp, "#!/bin/sh\npwd\n");
#endif
} }
// Unpack files with category ExtractPath non empty // Unpack files with category ExtractPath non empty
@ -808,8 +822,15 @@ void CPatchManager::createBatchFile(CProductDescriptionForClient &descFile, bool
if (useBatchFile) if (useBatchFile)
{ {
#ifdef NL_OS_WINDOWS
SrcPath = CPath::standardizeDosPath(SrcPath); SrcPath = CPath::standardizeDosPath(SrcPath);
DstPath = CPath::standardizeDosPath(DstPath); DstPath = CPath::standardizeDosPath(DstPath);
#elseif NL_OS_MAC
//no patcher on mac yet
#else
SrcPath = CPath::standardizePath(SrcPath);
DstPath = CPath::standardizePath(DstPath);
#endif
} }
std::string SrcName = SrcPath + vFilenames[fff]; std::string SrcName = SrcPath + vFilenames[fff];
@ -817,11 +838,21 @@ void CPatchManager::createBatchFile(CProductDescriptionForClient &descFile, bool
if (useBatchFile) if (useBatchFile)
{ {
//write windows .bat format else write sh format
#ifdef NL_OS_WINDOWS
fprintf(fp, ":loop%u\n", nblab); fprintf(fp, ":loop%u\n", nblab);
fprintf(fp, "attrib -r -a -s -h %s\n", DstName.c_str()); fprintf(fp, "attrib -r -a -s -h %s\n", DstName.c_str());
fprintf(fp, "del %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, "if exist %s goto loop%u\n", DstName.c_str(), nblab);
fprintf(fp, "move %s %s\n", SrcName.c_str(), DstPath.c_str()); fprintf(fp, "move %s %s\n", SrcName.c_str(), DstPath.c_str());
#elseif NL_OS_MAC
//no patcher on osx
#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 else
{ {
@ -838,10 +869,12 @@ void CPatchManager::createBatchFile(CProductDescriptionForClient &descFile, bool
// Finalize batch file // Finalize batch file
if (NLMISC::CFile::isExists("patch") && NLMISC::CFile::isDirectory("patch")) if (NLMISC::CFile::isExists("patch") && NLMISC::CFile::isDirectory("patch"))
{ {
#ifdef NL_OS_WINDOWS
if (useBatchFile) if (useBatchFile)
{ {
fprintf(fp, ":looppatch\n"); fprintf(fp, ":looppatch\n");
} }
#endif
vector<string> vFileList; vector<string> vFileList;
CPath::getPathContent ("patch", false, false, true, vFileList, NULL, false); CPath::getPathContent ("patch", false, false, true, vFileList, NULL, false);
@ -849,7 +882,13 @@ void CPatchManager::createBatchFile(CProductDescriptionForClient &descFile, bool
{ {
if (useBatchFile) if (useBatchFile)
{ {
#ifdef NL_OS_WINDOWS
fprintf(fp, "del %s\n", CPath::standardizeDosPath(vFileList[i]).c_str()); fprintf(fp, "del %s\n", CPath::standardizeDosPath(vFileList[i]).c_str());
#elseif NL_OS_MAC
//no patcher on MAC yet
#else
fprintf(fp, "rm -f %s\n", CPath::standardizePath(vFileList[i]).c_str());
#endif
} }
else else
{ {
@ -859,8 +898,14 @@ void CPatchManager::createBatchFile(CProductDescriptionForClient &descFile, bool
if (useBatchFile) if (useBatchFile)
{ {
#ifdef NL_OS_WINDOWS
fprintf(fp, "rd /Q /S patch\n"); fprintf(fp, "rd /Q /S patch\n");
fprintf(fp, "if exist patch goto looppatch\n"); fprintf(fp, "if exist patch goto looppatch\n");
#elseif NL_OS_MAC
//no patcher on mac yet
#else
fprintf(fp, "rm -rf patch\n");
#endif
} }
else else
{ {
@ -872,7 +917,11 @@ void CPatchManager::createBatchFile(CProductDescriptionForClient &descFile, bool
{ {
if (wantRyzomRestart) if (wantRyzomRestart)
{ {
#ifdef NL_OS_WINDOWS
fprintf(fp, "start %s %%1 %%2 %%3\n", RyzomFilename.c_str()); fprintf(fp, "start %s %%1 %%2 %%3\n", RyzomFilename.c_str());
#else
fprintf(fp, "/opt/tita/%s $1 $2 $3\n", RyzomFilename.c_str());
#endif
} }
bool writeError = ferror(fp) != 0; bool writeError = ferror(fp) != 0;
@ -887,6 +936,7 @@ void CPatchManager::createBatchFile(CProductDescriptionForClient &descFile, bool
throw NLMISC::EWriteError(UpdateBatchFilename.c_str()); throw NLMISC::EWriteError(UpdateBatchFilename.c_str());
} }
} }
} }
// **************************************************************************** // ****************************************************************************
@ -944,7 +994,36 @@ void CPatchManager::executeBatchFile()
// CloseHandle( pi.hThread ); // CloseHandle( pi.hThread );
#else #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 #endif
// exit(0); // exit(0);

View file

@ -323,6 +323,8 @@ void CPackageDescription::generatePatches(CBNPFileSet& packageIndex) const
for (uint32 i=packageIndex.fileCount();i--;) for (uint32 i=packageIndex.fileCount();i--;)
{ {
bool deleteRefAfterDelta= true;
bool usingTemporaryFile = false;
// generate file name root // generate file name root
std::string bnpFileName= _BnpDirectory+packageIndex.getFile(i).getFileName(); std::string bnpFileName= _BnpDirectory+packageIndex.getFile(i).getFileName();
std::string refNameRoot= _RefDirectory+NLMISC::CFile::getFilenameWithoutExtension(bnpFileName); std::string refNameRoot= _RefDirectory+NLMISC::CFile::getFilenameWithoutExtension(bnpFileName);
@ -345,6 +347,8 @@ void CPackageDescription::generatePatches(CBNPFileSet& packageIndex) const
prevVersionFileName= _RootDirectory + "empty"; prevVersionFileName= _RootDirectory + "empty";
NLMISC::COFile tmpFile(prevVersionFileName); NLMISC::COFile tmpFile(prevVersionFileName);
tmpFile.close(); tmpFile.close();
usingTemporaryFile = true;
deleteRefAfterDelta= false;
} }
else else
{ {