From cb878500ad7d213075db4ee7d8aa79d1cd6383c4 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 17 Oct 2016 11:12:06 +0200 Subject: [PATCH 1/8] Fixed: Ryzom Installer executable under OS X --HG-- branch : develop --- .../tools/client/ryzom_installer/res/ryzom_installer.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/ryzom/tools/client/ryzom_installer/res/ryzom_installer.ini b/code/ryzom/tools/client/ryzom_installer/res/ryzom_installer.ini index 7ce0988d5..225f35e49 100644 --- a/code/ryzom/tools/client/ryzom_installer/res/ryzom_installer.ini +++ b/code/ryzom/tools/client/ryzom_installer/res/ryzom_installer.ini @@ -1,9 +1,9 @@ -version=3 +version=4 [common] installation_directory= installer_filename_windows=ryzom_installer_qt_r.exe -installer_filename_osx=RyzomInstaller.app/Contents/MacOS/RyzomInstaller +installer_filename_osx="Ryzom Installer.app/Contents/MacOS/Ryzom Installer" installer_filename_linux=ryzom_installer_qt [product] From 0101cdfacfdec57b790563b46bd9f62f92e191ec Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 17 Oct 2016 11:13:49 +0200 Subject: [PATCH 2/8] Fixed: Recursive copy --HG-- branch : develop --- .../ryzom_installer/src/filescopier.cpp | 114 ++++++++---------- .../client/ryzom_installer/src/filescopier.h | 4 +- 2 files changed, 50 insertions(+), 68 deletions(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/filescopier.cpp b/code/ryzom/tools/client/ryzom_installer/src/filescopier.cpp index 069de1283..978d094c1 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/filescopier.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/filescopier.cpp @@ -63,71 +63,62 @@ bool CFilesCopier::exec() FilesToCopy files; + // create the list of files to copy CFilesCopier::getFilesList(files); + // copy them return copyFiles(files); } -void CFilesCopier::getFilesList(FilesToCopy &files) +void CFilesCopier::getFile(const QFileInfo &fileInfo, const QDir &srcDir, FilesToCopy &files) const { - QDir dir(m_sourceDirectory); + // full path to file + QString fullPath = fileInfo.absoluteFilePath(); - QFileInfoList entries = dir.entryInfoList(m_includeFilter); + // full path where to copy file + QString dstPath = m_destinationDirectory + "/" + srcDir.relativeFilePath(fullPath); + + if (fileInfo.isDir()) + { + // create directory + QDir().mkpath(dstPath); + + QDir subDir(fullPath); + + // get list of all files in directory + QFileInfoList entries = subDir.entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot); + + // proces seach file recursively + foreach(const QFileInfo &entry, entries) + { + getFile(entry, srcDir, files); + } + } + else + { + // add the file to list with all useful information + FileToCopy file; + file.filename = fileInfo.fileName(); + file.src = fileInfo.filePath(); + file.dst = dstPath; + file.size = fileInfo.size(); + file.date = fileInfo.lastModified().toTime_t(); + file.permissions = fileInfo.permissions(); + + files << file; + } +} + +void CFilesCopier::getFilesList(FilesToCopy &files) const +{ + QDir srcDir(m_sourceDirectory); + + // only copy all files from filter + QFileInfoList entries = srcDir.entryInfoList(m_includeFilter); foreach(const QFileInfo &entry, entries) { - QString fullPath = entry.absoluteFilePath(); - - QString dstPath = m_destinationDirectory + "/" + dir.relativeFilePath(fullPath); - - if (entry.isDir()) - { - QDir().mkpath(dstPath); - - QDir subDir(fullPath); - - QDirIterator it(subDir, QDirIterator::Subdirectories); - - while (it.hasNext()) - { - fullPath = it.next(); - - if (it.fileName().startsWith('.')) continue; - - QFileInfo fileInfo = it.fileInfo(); - - dstPath = m_destinationDirectory + "/" + dir.relativeFilePath(fullPath); - - if (fileInfo.isDir()) - { - QDir().mkpath(dstPath); - } - else - { - FileToCopy file; - file.filename = it.fileName(); - file.src = it.filePath(); - file.dst = dstPath; - file.size = it.fileInfo().size(); - file.date = it.fileInfo().lastModified().toTime_t(); - file.permissions = it.fileInfo().permissions(); - - files << file; - } - } - } - else - { - FileToCopy file; - file.filename = entry.fileName(); - file.src = entry.filePath(); - file.dst = dstPath; - file.size = entry.size(); - file.date = entry.lastModified().toTime_t(); - file.permissions = entry.permissions(); - - files << file; - } + getFile(entry, srcDir, files); } // copy additional files @@ -135,18 +126,7 @@ void CFilesCopier::getFilesList(FilesToCopy &files) { QFileInfo fileInfo(fullpath); - if (fileInfo.isFile()) - { - FileToCopy file; - file.filename = fileInfo.fileName(); - file.src = fileInfo.filePath(); - file.dst = m_destinationDirectory + "/" + fileInfo.fileName(); - file.size = fileInfo.size(); - file.date = fileInfo.lastModified().toTime_t(); - file.permissions = fileInfo.permissions(); - - files << file; - } + getFile(fileInfo, srcDir, files); } } diff --git a/code/ryzom/tools/client/ryzom_installer/src/filescopier.h b/code/ryzom/tools/client/ryzom_installer/src/filescopier.h index 8b505fb68..f0f2651a8 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/filescopier.h +++ b/code/ryzom/tools/client/ryzom_installer/src/filescopier.h @@ -54,7 +54,9 @@ protected: typedef QList FilesToCopy; - void getFilesList(FilesToCopy &files); + void getFile(const QFileInfo &info, const QDir &srcDir, FilesToCopy &files) const; + void getFilesList(FilesToCopy &files) const; + bool copyFiles(const FilesToCopy &files); IOperationProgressListener *m_listener; From 48f013a86e5653e585e166da358c05202415234d Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 17 Oct 2016 11:16:34 +0200 Subject: [PATCH 3/8] Changed: Use getInstallerCurrentFilePath() instead of QApplication::applicationFilePath() --HG-- branch : develop --- .../tools/client/ryzom_installer/src/configfile.cpp | 11 +++-------- .../tools/client/ryzom_installer/src/configfile.h | 1 - code/ryzom/tools/client/ryzom_installer/src/main.cpp | 2 +- .../client/ryzom_installer/src/migratedialog.cpp | 2 +- .../client/ryzom_installer/src/operationdialog.cpp | 2 +- 5 files changed, 6 insertions(+), 12 deletions(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp index 839c85272..2ff5abd05 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp @@ -492,11 +492,6 @@ QString CConfigFile::getParentDirectory() return current.absolutePath(); } -QString CConfigFile::getApplicationDirectory() -{ - return QApplication::applicationDirPath(); -} - QString CConfigFile::getOldInstallationDirectory() { // HKEY_CURRENT_USER/SOFTWARE/Nevrax/RyzomInstall/InstallId=1917716796 (string) @@ -818,7 +813,7 @@ QStringList CConfigFile::getInstallerRequiredFiles() const #endif // include current executable - files << QFileInfo(QApplication::applicationFilePath()).fileName(); + files << QFileInfo(getInstallerCurrentFilePath()).fileName(); #elif defined(Q_OS_MAC) // everything is in a directory files << "Ryzom Installer.app"; @@ -827,7 +822,7 @@ QStringList CConfigFile::getInstallerRequiredFiles() const files << "ryzom_installer.png"; // include current executable - files << QFileInfo(QApplication::applicationFilePath()).fileName(); + files << QFileInfo(getInstallerCurrentFilePath()).fileName(); #endif return files; @@ -875,7 +870,7 @@ OperationStep CConfigFile::getInstallNextStep() const if (!isRyzomInstalledIn(currentDirectory)) { // Ryzom is in the same directory as Ryzom Installer - currentDirectory = getApplicationDirectory(); + currentDirectory = getInstallerCurrentDirPath(); if (!isRyzomInstalledIn(currentDirectory)) { diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.h b/code/ryzom/tools/client/ryzom_installer/src/configfile.h index a7b2a8919..1f71ad56b 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.h +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.h @@ -90,7 +90,6 @@ public: // default directories static QString getCurrentDirectory(); static QString getParentDirectory(); - static QString getApplicationDirectory(); static QString getOldInstallationDirectory(); static QString getNewInstallationDirectory(); static QString getOldInstallationLanguage(); diff --git a/code/ryzom/tools/client/ryzom_installer/src/main.cpp b/code/ryzom/tools/client/ryzom_installer/src/main.cpp index 9b587c0b2..5e0bea7a9 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/main.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/main.cpp @@ -180,7 +180,7 @@ int main(int argc, char *argv[]) // copy installer and required files to TEMP directory if (QDir().mkdir(tempPath) && copyInstallerFiles(config.getInstallerRequiredFiles(), tempPath)) { - QString tempFile = tempPath + "/" + QFileInfo(QApplication::applicationFilePath()).fileName(); + QString tempFile = tempPath + "/" + QFileInfo(getInstallerCurrentFilePath()).fileName(); // launch copy in TEMP directory with same arguments if (QProcess::startDetached(tempFile, QApplication::arguments())) return 0; diff --git a/code/ryzom/tools/client/ryzom_installer/src/migratedialog.cpp b/code/ryzom/tools/client/ryzom_installer/src/migratedialog.cpp index 2315d38ec..92c4da4e6 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/migratedialog.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/migratedialog.cpp @@ -38,7 +38,7 @@ CMigrateDialog::CMigrateDialog():QDialog() if (!CConfigFile::getInstance()->isRyzomInstalledIn(m_currentDirectory)) { // Ryzom is in the same directory as Ryzom Installer - m_currentDirectory = CConfigFile::getInstance()->getApplicationDirectory(); + m_currentDirectory = CConfigFile::getInstance()->getInstallerCurrentDirPath(); if (!CConfigFile::getInstance()->isRyzomInstalledIn(m_currentDirectory)) { diff --git a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp index 25bbd9b17..3b65152d3 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp @@ -729,7 +729,7 @@ void COperationDialog::copyInstaller() // rename old client to installer - QString oldInstallerFullPath = QApplication::applicationFilePath(); + QString oldInstallerFullPath = config->getInstallerCurrentFilePath(); QString newInstallerFullPath = config->getInstallerInstalledFilePath(); if (!newInstallerFullPath.isEmpty()) From f40e6deb7a2b86e4c59b784264af7d1bb5b06dbc Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 17 Oct 2016 11:17:35 +0200 Subject: [PATCH 4/8] Changed: Display also destination in error --HG-- branch : develop --- code/ryzom/tools/client/ryzom_installer/src/filescopier.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/filescopier.cpp b/code/ryzom/tools/client/ryzom_installer/src/filescopier.cpp index 978d094c1..470790d4a 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/filescopier.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/filescopier.cpp @@ -166,7 +166,7 @@ bool CFilesCopier::copyFiles(const FilesToCopy &files) if (!QFile::copy(file.src, file.dst)) { - if (m_listener) m_listener->operationFail(QApplication::tr("Unable to copy file %1").arg(file.src)); + if (m_listener) m_listener->operationFail(QApplication::tr("Unable to copy file %1 to %2").arg(file.src).arg(file.dst)); return false; } From d1e078aea5f427c10fd15548b45d3e722f7c2100 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 17 Oct 2016 11:19:11 +0200 Subject: [PATCH 5/8] Fixed: getInstallerCurrentDirPath() returns bundle parent directory under OS X --HG-- branch : develop --- .../client/ryzom_installer/src/configfile.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp index 2ff5abd05..86c99278c 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp @@ -752,7 +752,19 @@ QString CConfigFile::getInstallerCurrentFilePath() const QString CConfigFile::getInstallerCurrentDirPath() const { // installer is always run from TEMP under Windows - return QApplication::applicationDirPath(); + QString appDir = QApplication::applicationDirPath(); + +#ifdef Q_OS_MAC + QDir dir(appDir); + dir.cdUp(); // .. = Contents + dir.cdUp(); // .. = .app + dir.cdUp(); // .. = + + // return absolute path + appDir = dir.absolutePath(); +#endif + + return appDir; } QString CConfigFile::getInstallerInstalledFilePath() const From ab1fb50ab551b1b545195384c1894dcb4a127429 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 17 Oct 2016 11:19:50 +0200 Subject: [PATCH 6/8] Changed: Relaunch installed Ryzom Installer if exists --HG-- branch : develop --- code/ryzom/tools/client/ryzom_installer/src/configfile.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp index 86c99278c..bbd399b97 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp @@ -979,8 +979,8 @@ OperationStep CConfigFile::getInstallNextStep() const // current installer older, launch the more recent installer case -1: return LaunchInstalledInstaller; - // continue only if 0 - default: break; + // continue only if 0 and launched Installer is the installed one + default: if (getInstallerCurrentDirPath() != getInstallerInstalledFilePath() && QFile::exists(getInstallerInstalledFilePath())) return LaunchInstalledInstaller; } // no default profile From 45c326a733cf4b5bf4f5da47100b2791c3863ba8 Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 17 Oct 2016 11:20:20 +0200 Subject: [PATCH 7/8] Changed: Keep other servers when upgrading ryzom_installer.ini --HG-- branch : develop --- .../client/ryzom_installer/src/configfile.cpp | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp index bbd399b97..b09fa4e44 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/configfile.cpp @@ -106,22 +106,25 @@ bool CConfigFile::load(const QString &filename) m_productHelpUrl = settings.value("url_help").toString(); m_productComments = settings.value("comments").toString(); settings.endGroup(); + } - settings.beginGroup("servers"); - int serversCount = settings.value("size").toInt(); - m_defaultServerIndex = settings.value("default").toInt(); + settings.beginGroup("servers"); + int serversCount = settings.value("size").toInt(); + m_defaultServerIndex = settings.value("default").toInt(); + settings.endGroup(); + + // only resize if added servers in local ryzom_installer.ini + int oldServersCount = m_servers.size(); + + if (serversCount > oldServersCount) m_servers.resize(serversCount); + + for (int i = oldServersCount; i < serversCount; ++i) + { + CServer &server = m_servers[i]; + + settings.beginGroup(QString("server_%1").arg(i)); + server.loadFromSettings(settings); settings.endGroup(); - - m_servers.resize(serversCount); - - for (int i = 0; i < serversCount; ++i) - { - CServer &server = m_servers[i]; - - settings.beginGroup(QString("server_%1").arg(i)); - server.loadFromSettings(settings); - settings.endGroup(); - } } // custom choices, always keep them From 3476eeb5e9cf4a37b834dc5fe58866989dc72bcd Mon Sep 17 00:00:00 2001 From: kervala Date: Mon, 17 Oct 2016 11:23:49 +0200 Subject: [PATCH 8/8] Changed: Don't copy twice the same file under other platforms than Windows --HG-- branch : develop --- .../ryzom_installer/src/operationdialog.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp index 3b65152d3..702b445fe 100644 --- a/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp +++ b/code/ryzom/tools/client/ryzom_installer/src/operationdialog.cpp @@ -734,13 +734,23 @@ void COperationDialog::copyInstaller() if (!newInstallerFullPath.isEmpty()) { + QString srcDir = config->getSrcServerDirectory(); + + if (srcDir.isEmpty()) srcDir = config->getInstallerCurrentDirPath(); + // always copy new installers CFilesCopier copier(this); copier.setIncludeFilter(config->getInstallerRequiredFiles()); +#ifdef Q_OS_WIN32 copier.addFile(oldInstallerFullPath); - copier.setSourceDirectory(config->getSrcServerDirectory().isEmpty() ? QApplication::applicationDirPath():config->getSrcServerDirectory()); +#endif + copier.setSourceDirectory(srcDir); copier.setDestinationDirectory(config->getInstallationDirectory()); - copier.exec(); + + if (!copier.exec()) return; + +#ifdef Q_OS_WIN32 + // only happens under Windows in Debug or when migrating // copied file oldInstallerFullPath = config->getInstallationDirectory() + "/" + QFileInfo(oldInstallerFullPath).fileName(); @@ -754,6 +764,7 @@ void COperationDialog::copyInstaller() // rename new installer with final name QFile::rename(oldInstallerFullPath, newInstallerFullPath); } +#endif // create menu directory if defined QString path = config->getMenuDirectory();