Merge with develop

--HG--
branch : compatibility-develop
This commit is contained in:
kervala 2016-10-17 11:35:24 +02:00
commit c418eb0c03
8 changed files with 104 additions and 102 deletions

View file

@ -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]

View file

@ -106,15 +106,19 @@ 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.endGroup();
m_servers.resize(serversCount);
// only resize if added servers in local ryzom_installer.ini
int oldServersCount = m_servers.size();
for (int i = 0; i < serversCount; ++i)
if (serversCount > oldServersCount) m_servers.resize(serversCount);
for (int i = oldServersCount; i < serversCount; ++i)
{
CServer &server = m_servers[i];
@ -122,7 +126,6 @@ bool CConfigFile::load(const QString &filename)
server.loadFromSettings(settings);
settings.endGroup();
}
}
// custom choices, always keep them
settings.beginGroup("profiles");
@ -492,11 +495,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)
@ -757,7 +755,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(); // .. = <parent>
// return absolute path
appDir = dir.absolutePath();
#endif
return appDir;
}
QString CConfigFile::getInstallerInstalledFilePath() const
@ -818,7 +828,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 +837,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 +885,7 @@ OperationStep CConfigFile::getInstallNextStep() const
if (!isRyzomInstalledIn(currentDirectory))
{
// Ryzom is in the same directory as Ryzom Installer
currentDirectory = getApplicationDirectory();
currentDirectory = getInstallerCurrentDirPath();
if (!isRyzomInstalledIn(currentDirectory))
{
@ -972,8 +982,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

View file

@ -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();

View file

@ -63,90 +63,70 @@ 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);
foreach(const QFileInfo &entry, entries)
{
QString fullPath = entry.absoluteFilePath();
QString dstPath = m_destinationDirectory + "/" + dir.relativeFilePath(fullPath);
if (entry.isDir())
if (fileInfo.isDir())
{
// create directory
QDir().mkpath(dstPath);
QDir subDir(fullPath);
QDirIterator it(subDir, QDirIterator::Subdirectories);
// get list of all files in directory
QFileInfoList entries = subDir.entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot);
while (it.hasNext())
// proces seach file recursively
foreach(const QFileInfo &entry, entries)
{
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;
}
getFile(entry, srcDir, files);
}
}
else
{
// add the file to list with all useful information
FileToCopy file;
file.filename = entry.fileName();
file.src = entry.filePath();
file.filename = fileInfo.fileName();
file.src = fileInfo.filePath();
file.dst = dstPath;
file.size = entry.size();
file.date = entry.lastModified().toTime_t();
file.permissions = entry.permissions();
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)
{
getFile(entry, srcDir, files);
}
// copy additional files
foreach(const QString &fullpath, m_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);
}
}
@ -186,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;
}

View file

@ -54,7 +54,9 @@ protected:
typedef QList<FileToCopy> 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;

View file

@ -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;

View file

@ -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))
{

View file

@ -729,18 +729,28 @@ void COperationDialog::copyInstaller()
// rename old client to installer
QString oldInstallerFullPath = QApplication::applicationFilePath();
QString oldInstallerFullPath = config->getInstallerCurrentFilePath();
QString newInstallerFullPath = config->getInstallerInstalledFilePath();
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();