Fixed: patch_gen is now using packLZMA function to compress a file instead of using lzma executable

This commit is contained in:
kervala 2016-02-02 10:22:47 +01:00
parent 92c598c81e
commit 54aaa51736
2 changed files with 11 additions and 29 deletions

View file

@ -1,13 +1,15 @@
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/ryzom/client/src/seven_zip)
SET(MAIN_SRC patch_gen_common.cpp patch_gen_main.cpp patch_gen_main.h) SET(MAIN_SRC patch_gen_common.cpp patch_gen_main.cpp patch_gen_main.h)
SET(SERVICE_SRC patch_gen_common.cpp patch_gen_service.cpp patch_gen_service.h) SET(SERVICE_SRC patch_gen_common.cpp patch_gen_service.cpp patch_gen_service.h)
ADD_EXECUTABLE(patch_gen ${MAIN_SRC}) ADD_EXECUTABLE(patch_gen ${MAIN_SRC})
TARGET_LINK_LIBRARIES(patch_gen ryzom_gameshare nelmisc nelnet nelligo nelgeorges) TARGET_LINK_LIBRARIES(patch_gen ryzom_sevenzip ryzom_gameshare nelmisc nelnet nelligo nelgeorges)
NL_DEFAULT_PROPS(patch_gen "Ryzom, Tools: Patch Generator") NL_DEFAULT_PROPS(patch_gen "Ryzom, Tools: Patch Generator")
NL_ADD_RUNTIME_FLAGS(patch_gen) NL_ADD_RUNTIME_FLAGS(patch_gen)
ADD_EXECUTABLE(patch_gen_service WIN32 ${SERVICE_SRC}) ADD_EXECUTABLE(patch_gen_service WIN32 ${SERVICE_SRC})
TARGET_LINK_LIBRARIES(patch_gen_service ryzom_gameshare nelmisc nelnet nelligo nelgeorges) TARGET_LINK_LIBRARIES(patch_gen_service ryzom_sevenzip ryzom_gameshare nelmisc nelnet nelligo nelgeorges)
NL_DEFAULT_PROPS(patch_gen_service "Ryzom, Tools: Patch Generator Service") NL_DEFAULT_PROPS(patch_gen_service "Ryzom, Tools: Patch Generator Service")
NL_ADD_RUNTIME_FLAGS(patch_gen_service) NL_ADD_RUNTIME_FLAGS(patch_gen_service)

View file

@ -27,6 +27,7 @@
#include "nel/misc/command.h" #include "nel/misc/command.h"
#include "nel/misc/sstring.h" #include "nel/misc/sstring.h"
#include "game_share/singleton_registry.h" #include "game_share/singleton_registry.h"
#include "seven_zip.h"
using namespace std; using namespace std;
using namespace NLMISC; using namespace NLMISC;
@ -74,37 +75,16 @@ void ApplyPatch(const std::string& srcFileName,const std::string& destFileName,c
#endif // NL_OS_WINDOWS #endif // NL_OS_WINDOWS
} }
void GenerateLZMA(const std::string sourceFile, const std::string &outputFile) void GenerateLZMA(const std::string &sourceFile, const std::string &outputFile)
{ {
{ {
// old syntax incompatible with new versions nlinfo("Compressing %s to %s using LZMA...", sourceFile.c_str(), outputFile.c_str());
std::string cmd = "lzma e";
cmd += " " + sourceFile + " " + outputFile;
nlinfo("Executing system command: %s", cmd.c_str());
} }
#ifdef NL_OS_WINDOWS
_spawnlp(_P_WAIT, "lzma.exe","lzma.exe", "e", sourceFile.c_str(), outputFile.c_str(), NULL);
#else // NL_OS_WINDOWS
// new lzma only supports one file name on command line, so make a copy
CFile::copyFile(outputFile, sourceFile);
// new lzma syntax, -z = compress, -9 = best compression if (!packLZMA(sourceFile, outputFile))
std::string cmd = NLMISC::toString("lzma -z -9 %s", outputFile.c_str());
sint error = system(cmd.c_str());
if (error)
{ {
nlwarning("'%s' failed with error code %d", cmd.c_str(), error); nlwarning("LZMA compress failed");
CFile::deleteFile(outputFile);
} }
else
{
// lzma always append a .lzma extension, so rename compressed file to wanted one
CFile::moveFile(outputFile, outputFile + ".lzma");
}
#endif // NL_OS_WINDOWS
} }
@ -230,7 +210,7 @@ void CPackageDescription::storeToPdr(CPersistentDataRecord& pdr) const
void CPackageDescription::readIndex(CBNPFileSet& packageIndex) const void CPackageDescription::readIndex(CBNPFileSet& packageIndex) const
{ {
std::string indexPath = _RootDirectory + _IndexFileName; std::string indexPath = _RootDirectory + _IndexFileName;
nlinfo("Reading history file: %s ...", indexPath.c_str()); nlinfo("Reading history file: %s ...", indexPath.c_str());
// clear out old contents before reading from input file // clear out old contents before reading from input file
@ -294,7 +274,7 @@ void CPackageDescription::generateClientIndex(CProductDescriptionForClient& theC
std::string patchNumber = toString("%05u", packageIndex.getVersionNumber()); std::string patchNumber = toString("%05u", packageIndex.getVersionNumber());
std::string patchDirectory = _PatchDirectory + patchNumber; std::string patchDirectory = _PatchDirectory + patchNumber;
std::string patchFile = patchDirectory + "/" + _ClientIndexFileName; std::string patchFile = patchDirectory + "/" + _ClientIndexFileName;
nlinfo("Generating client index: %s...", patchFile.c_str()); nlinfo("Generating client index: %s...", patchFile.c_str());
// make sure the version sub directory exist // make sure the version sub directory exist