Changed: List all required files and copy them, see #279

--HG--
branch : develop
This commit is contained in:
kervala 2016-07-27 11:54:35 +02:00
parent 6e8671c55a
commit 626eba195d
8 changed files with 86 additions and 58 deletions

View file

@ -51,3 +51,7 @@ IF(WITH_PCH)
ENDIF() ENDIF()
INSTALL(TARGETS ryzom_installer_qt RUNTIME DESTINATION ${RYZOM_GAMES_PREFIX} COMPONENT client) INSTALL(TARGETS ryzom_installer_qt RUNTIME DESTINATION ${RYZOM_GAMES_PREFIX} COMPONENT client)
IF(UNIX AND NOT APPLE)
INSTALL(FILES res/ryzom_installer.png DESTINATION ${RYZOM_SHARE_PREFIX} COMPONENT client)
ENDIF()

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

View file

@ -831,6 +831,51 @@ QString CConfigFile::getInstallerMenuLinkFullPath() const
#endif #endif
} }
QStringList CConfigFile::getInstallerRequiredFiles() const
{
// list of all files required by installer (and its executable too)
QStringList files;
#ifdef Q_OS_WIN
// VC++ runtimes
#if _MSC_VER == 1900
// VC++ 2015
files << "msvcp140.dll";
files << "msvcr140.dll";
#elif _MSC_VER == 1800
// VC++ 2013
files << "msvcp120.dll";
files << "msvcr120.dll";
#elif _MSC_VER == 1700
// VC++ 2012
files << "msvcp110.dll";
files << "msvcr110.dll";
#elif _MSC_VER == 1600
// VC++ 2010
files << "msvcp100.dll";
files << "msvcr100.dll";
#elif _MSC_VER == 1500
// VC++ 2008
files << "msvcp90.dll";
files << "msvcr90.dll";
#else
// unsupported compiler
#endif
#elif defined(Q_OS_MAC)
// TODO: for OS X
#else
// icon under Linux
files << "ryzom_installer.png";
#endif
// include current executable
files << QFileInfo(QApplication::applicationFilePath()).fileName();
return files;
}
QString CConfigFile::getSrcServerClientBNPFullPath() const QString CConfigFile::getSrcServerClientBNPFullPath() const
{ {
return QString("%1/unpack/exedll_%2.bnp").arg(getSrcServerDirectory()).arg(getClientArch()); return QString("%1/unpack/exedll_%2.bnp").arg(getSrcServerDirectory()).arg(getClientArch());

View file

@ -181,6 +181,8 @@ public:
QString getInstallerFullPath() const; QString getInstallerFullPath() const;
QString getInstallerMenuLinkFullPath() const; QString getInstallerMenuLinkFullPath() const;
QStringList getInstallerRequiredFiles() const;
QString getSrcServerClientBNPFullPath() const; QString getSrcServerClientBNPFullPath() const;
OperationStep getInstallNextStep() const; OperationStep getInstallNextStep() const;

View file

@ -47,6 +47,39 @@
#define new DEBUG_NEW #define new DEBUG_NEW
#endif #endif
// copy all specified files from current directory to destination directory
bool copyInstallerFiles(const QStringList &files, const QString &destination)
{
QString path = QApplication::applicationDirPath();
foreach(const QString &file, files)
{
// convert to absolute path
QString srcPath = path + "/" + file;
QString dstPath = destination + "/" + file;
if (QFile::exists(srcPath))
{
if (QFile::exists(dstPath))
{
if (!QFile::remove(dstPath))
{
qDebug() << "Unable to delete" << dstPath;
}
}
if (!QFile::copy(srcPath, dstPath))
{
qDebug() << "Unable to copy" << srcPath << "to" << dstPath;
return false;
}
}
}
return true;
}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
#if defined(_MSC_VER) && defined(_DEBUG) #if defined(_MSC_VER) && defined(_DEBUG)
@ -115,7 +148,7 @@ int main(int argc, char *argv[])
if (QApplication::applicationDirPath() != tempPath) if (QApplication::applicationDirPath() != tempPath)
{ {
// copy installer and required files to TEMP directory // copy installer and required files to TEMP directory
if (copyInstallerExecutable(tempPath)) if (copyInstallerFiles(config.getInstallerRequiredFiles(), tempPath))
{ {
QString tempFile = tempPath + "/" + QFileInfo(QApplication::applicationFilePath()).fileName(); QString tempFile = tempPath + "/" + QFileInfo(QApplication::applicationFilePath()).fileName();

View file

@ -715,13 +715,8 @@ void COperationDialog::copyInstaller()
if (!QFile::exists(newInstallerFullPath)) if (!QFile::exists(newInstallerFullPath))
{ {
QStringList filter;
filter << "msvcp100.dll";
filter << "msvcr100.dll";
filter << "ryzom_installer.png";
CFilesCopier copier(this); CFilesCopier copier(this);
copier.setIncludeFilter(filter); copier.setIncludeFilter(config->getInstallerRequiredFiles());
copier.addFile(oldInstallerFullPath); copier.addFile(oldInstallerFullPath);
copier.setSourceDirectory(config->getSrcServerDirectory().isEmpty() ? QApplication::applicationDirPath():config->getSrcServerDirectory()); copier.setSourceDirectory(config->getSrcServerDirectory().isEmpty() ? QApplication::applicationDirPath():config->getSrcServerDirectory());
copier.setDestinationDirectory(config->getInstallationDirectory()); copier.setDestinationDirectory(config->getInstallationDirectory());

View file

@ -239,52 +239,3 @@ bool resolveLink(const QWidget &window, const QString &pathLink, QString &pathOb
} }
#endif #endif
bool copyInstallerExecutable(const QString &destination)
{
QString path = QApplication::applicationDirPath();
QStringList files;
#ifdef Q_OS_WIN
// VC++ runtimes
#if _MSC_VER == 1900
files << "msvcp140.dll";
files << "msvcr140.dll";
#else _MSC_VER == 1600
files << "msvcp100.dll";
files << "msvcr100.dll";
#endif
#else
#endif
files << QFileInfo(QApplication::applicationFilePath()).fileName();
foreach(const QString &file, files)
{
// convert to absolute path
QString srcPath = path + "/" + file;
QString dstPath = destination + "/" + file;
if (QFile::exists(srcPath))
{
if (QFile::exists(dstPath))
{
if (!QFile::remove(dstPath))
{
qDebug() << "Unable to delete" << dstPath;
}
}
if (!QFile::copy(srcPath, dstPath))
{
qDebug() << "Unable to copy" << srcPath << "to" << dstPath;
return false;
}
}
}
return true;
}

View file

@ -51,6 +51,4 @@ wchar_t* qToWide(const QString &str);
bool createLink(const QString &link, const QString &name, const QString &executable, const QString &arguments, const QString &icon, const QString &workingDir); bool createLink(const QString &link, const QString &name, const QString &executable, const QString &arguments, const QString &icon, const QString &workingDir);
bool resolveLink(const QWidget &window, const QString &pathLink, QString &pathObj); bool resolveLink(const QWidget &window, const QString &pathLink, QString &pathObj);
bool copyInstallerExecutable(const QString &destination);
#endif #endif