mirror of
https://github.com/QuasarApp/QtDeployer.git
synced 2025-05-17 23:39:32 +00:00
first version of install framework
This commit is contained in:
parent
145b217f4a
commit
0300e33efa
@ -5,6 +5,8 @@ QString BaseClass::m_qtdir = QString();
|
|||||||
QString BaseClass::m_outputdir = QString();
|
QString BaseClass::m_outputdir = QString();
|
||||||
QString BaseClass::m_projectdir = QString();
|
QString BaseClass::m_projectdir = QString();
|
||||||
QString BaseClass::m_executablepath = QString();
|
QString BaseClass::m_executablepath = QString();
|
||||||
|
QString BaseClass::m_binarycreator = QString();
|
||||||
|
QString BaseClass::projectName = QString();
|
||||||
|
|
||||||
QStringList BaseClass::findFilesInsideDir(const QString &name, const QString &dirpath)
|
QStringList BaseClass::findFilesInsideDir(const QString &name, const QString &dirpath)
|
||||||
{
|
{
|
||||||
|
@ -17,8 +17,10 @@ class BaseClass : public QObject
|
|||||||
protected:
|
protected:
|
||||||
static QString m_qtdir;
|
static QString m_qtdir;
|
||||||
static QString m_outputdir;
|
static QString m_outputdir;
|
||||||
|
static QString m_binarycreator;
|
||||||
static QString m_projectdir;
|
static QString m_projectdir;
|
||||||
static QString m_executablepath;
|
static QString m_executablepath;
|
||||||
|
static QString projectName;
|
||||||
|
|
||||||
QStringList findFilesInsideDir(const QString &name, const QString &dirpath);
|
QStringList findFilesInsideDir(const QString &name, const QString &dirpath);
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@ private:
|
|||||||
QString qmake;
|
QString qmake;
|
||||||
QString tempBuildFolder;
|
QString tempBuildFolder;
|
||||||
QString tempLog;
|
QString tempLog;
|
||||||
QString projectName;
|
|
||||||
QProcess pQMake;
|
QProcess pQMake;
|
||||||
|
|
||||||
bool createFulder(QDir& dir, QString& path, const QString& name) const;
|
bool createFulder(QDir& dir, QString& path, const QString& name) const;
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
#include "outputmanager.h"
|
#include "outputmanager.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include <QDate>
|
||||||
|
|
||||||
void OutputManager::setPathsToCopy(const QStringList &pathsToCopy)
|
void OutputManager::setPathsToCopy(const QStringList &pathsToCopy)
|
||||||
{
|
{
|
||||||
@ -31,7 +33,12 @@ bool OutputManager::copyDir(const QString &source, const QString &destin)
|
|||||||
|
|
||||||
void OutputManager::copyCpp(const QStringList &libs)
|
void OutputManager::copyCpp(const QStringList &libs)
|
||||||
{
|
{
|
||||||
auto libdir = m_outputdir + "/lib/data/lib/";
|
QString temp = "/lib";
|
||||||
|
if(isInstallFW()){
|
||||||
|
temp = "/packages/lib/data/lib";
|
||||||
|
}
|
||||||
|
|
||||||
|
auto libdir = m_outputdir + temp;
|
||||||
|
|
||||||
for (const QString &S : libs)
|
for (const QString &S : libs)
|
||||||
{
|
{
|
||||||
@ -56,6 +63,8 @@ void OutputManager::copyAll(const QStringList &qtlibs, const QStringList &libs,
|
|||||||
dir.mkdir(QDir(m_outputdir).dirName());
|
dir.mkdir(QDir(m_outputdir).dirName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkInstallFrameWork();
|
||||||
|
|
||||||
createDirectories();
|
createDirectories();
|
||||||
|
|
||||||
if (libs.count() != 0) copyCpp(libs);
|
if (libs.count() != 0) copyCpp(libs);
|
||||||
@ -64,6 +73,7 @@ void OutputManager::copyAll(const QStringList &qtlibs, const QStringList &libs,
|
|||||||
copyPlugins(plugins);
|
copyPlugins(plugins);
|
||||||
copyExec();
|
copyExec();
|
||||||
createRunFile();
|
createRunFile();
|
||||||
|
createInstaller();
|
||||||
|
|
||||||
emit pathsToCopyChanged(m_pathsToCopy);
|
emit pathsToCopyChanged(m_pathsToCopy);
|
||||||
emit copySuccessChanged(m_copySuccess);
|
emit copySuccessChanged(m_copySuccess);
|
||||||
@ -71,7 +81,13 @@ void OutputManager::copyAll(const QStringList &qtlibs, const QStringList &libs,
|
|||||||
|
|
||||||
void OutputManager::copyQml(const QStringList &dirs)
|
void OutputManager::copyQml(const QStringList &dirs)
|
||||||
{
|
{
|
||||||
auto qmldir = m_outputdir + "/qml/data/qml/";
|
QString temp = "/qml";
|
||||||
|
if(isInstallFW()){
|
||||||
|
temp = "/packages/qml/data/qml";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
auto qmldir = m_outputdir + temp;
|
||||||
|
|
||||||
for (const QString &S : dirs)
|
for (const QString &S : dirs)
|
||||||
{
|
{
|
||||||
@ -81,10 +97,57 @@ void OutputManager::copyQml(const QStringList &dirs)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool OutputManager::isInstallFW() const {
|
||||||
|
return !m_binarycreator.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OutputManager::checkInstallFrameWork(){
|
||||||
|
QDir dir(m_qtdir);
|
||||||
|
if(!dir.cd("../../Tools/QtInstallerFramework")){
|
||||||
|
m_binarycreator = QString();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList list = dir.entryList();
|
||||||
|
|
||||||
|
int index_of_max = 0;
|
||||||
|
double maxVersion = 0;
|
||||||
|
for(int i = 0; i < list.size(); i++){
|
||||||
|
if(list.at(i).toDouble() > maxVersion){
|
||||||
|
index_of_max = i;
|
||||||
|
maxVersion = list.at(i).toDouble();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!maxVersion || !index_of_max){
|
||||||
|
m_binarycreator = QString();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!dir.cd(list[index_of_max])){
|
||||||
|
m_binarycreator = QString();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_binarycreator = dir.absolutePath() + "/bin/binarycreator";
|
||||||
|
|
||||||
|
|
||||||
|
if(!QFile::exists(m_binarycreator)){
|
||||||
|
m_binarycreator = QString();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void OutputManager::copyPlugins(const QStringList &plugins)
|
void OutputManager::copyPlugins(const QStringList &plugins)
|
||||||
{
|
{
|
||||||
|
QString temp = "/plugins/";
|
||||||
|
if(isInstallFW()){
|
||||||
|
temp = "/packages/plugins/data/plugins/";
|
||||||
|
}
|
||||||
|
|
||||||
QString qtpath = m_qtdir + "/plugins/";
|
QString qtpath = m_qtdir + "/plugins/";
|
||||||
QString path = m_outputdir + "/plugins/data/plugins";
|
QString path = m_outputdir + temp;
|
||||||
|
|
||||||
for (const QString &plugin : plugins)
|
for (const QString &plugin : plugins)
|
||||||
{
|
{
|
||||||
@ -95,7 +158,12 @@ void OutputManager::copyPlugins(const QStringList &plugins)
|
|||||||
|
|
||||||
void OutputManager::copyExec()
|
void OutputManager::copyExec()
|
||||||
{
|
{
|
||||||
auto path = m_outputdir + "/base/data/bin" + QFileInfo(m_executablepath).fileName();
|
QString temp = "/bin/";
|
||||||
|
if(isInstallFW()){
|
||||||
|
temp = "/packages/base/data/bin/";
|
||||||
|
}
|
||||||
|
|
||||||
|
auto path = m_outputdir + temp + QFileInfo(m_executablepath).fileName();
|
||||||
|
|
||||||
m_pathsToCopy << path;
|
m_pathsToCopy << path;
|
||||||
m_copySuccess << copyFile(m_executablepath, path);
|
m_copySuccess << copyFile(m_executablepath, path);
|
||||||
@ -103,6 +171,12 @@ void OutputManager::copyExec()
|
|||||||
|
|
||||||
void OutputManager::createRunFile()
|
void OutputManager::createRunFile()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
QString temp = "";
|
||||||
|
if(isInstallFW()){
|
||||||
|
temp = "/packages/base/data";
|
||||||
|
}
|
||||||
|
|
||||||
QString content =
|
QString content =
|
||||||
"#!/bin/sh\n"
|
"#!/bin/sh\n"
|
||||||
"export LD_LIBRARY_PATH=`pwd`/lib\n"
|
"export LD_LIBRARY_PATH=`pwd`/lib\n"
|
||||||
@ -114,7 +188,7 @@ void OutputManager::createRunFile()
|
|||||||
|
|
||||||
content = content.arg(QFileInfo(m_executablepath).completeBaseName());
|
content = content.arg(QFileInfo(m_executablepath).completeBaseName());
|
||||||
|
|
||||||
QString fname = m_outputdir + "/base/" + QDir::separator() +
|
QString fname = m_outputdir + temp + QDir::separator() +
|
||||||
QFileInfo(m_executablepath).completeBaseName() + ".sh";
|
QFileInfo(m_executablepath).completeBaseName() + ".sh";
|
||||||
|
|
||||||
QFile F(fname);
|
QFile F(fname);
|
||||||
@ -129,8 +203,113 @@ void OutputManager::createRunFile()
|
|||||||
QFileDevice::ReadUser);
|
QFileDevice::ReadUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool OutputManager::createModule(const QString &from, const QString &to, const QStringList ¶ms){
|
||||||
|
QFile tempFile;
|
||||||
|
tempFile.setFileName(from);
|
||||||
|
|
||||||
|
if(!tempFile.open(QIODevice::ReadOnly)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString text = tempFile.readAll();
|
||||||
|
tempFile.close();
|
||||||
|
|
||||||
|
for(QString i : params){
|
||||||
|
text = text.arg(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
tempFile.setFileName(to);
|
||||||
|
|
||||||
|
if(!tempFile.open(QIODevice::ReadWrite) &&
|
||||||
|
QDir().mkpath(QFileInfo(to).absolutePath()) &&
|
||||||
|
!tempFile.open(QIODevice::ReadWrite)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
tempFile.write(text.toLatin1());
|
||||||
|
tempFile.close();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OutputManager::createInstaller(){
|
||||||
|
|
||||||
|
createModule(":/install/InstallTemplate/config.xml",
|
||||||
|
m_outputdir + "/config/config.xml",
|
||||||
|
QStringList() << projectName <<
|
||||||
|
Utils::getVersion() <<
|
||||||
|
Utils::getPublicher() <<
|
||||||
|
"QtDeployer" <<
|
||||||
|
QDate::currentDate().toString("yyyy-MM-dd"));
|
||||||
|
|
||||||
|
createModule(":/install/InstallTemplate/controlScript.js",
|
||||||
|
m_outputdir + "/config/controlScript.js",
|
||||||
|
QStringList());
|
||||||
|
|
||||||
|
createModule(":/install/InstallTemplate/package.xml",
|
||||||
|
m_outputdir + "/packages/base/meta/package.xml",
|
||||||
|
QStringList() << "base" <<
|
||||||
|
"base data of " + projectName <<
|
||||||
|
Utils::getVersion() <<
|
||||||
|
QDate::currentDate().toString("yyyy-MM-dd"));
|
||||||
|
|
||||||
|
createModule(":/install/InstallTemplate/package.xml",
|
||||||
|
m_outputdir + "/packages/qml/meta/package.xml",
|
||||||
|
QStringList() << "qml" <<
|
||||||
|
"qml data of " + projectName <<
|
||||||
|
Utils::getVersion() <<
|
||||||
|
QDate::currentDate().toString("yyyy-MM-dd"));
|
||||||
|
|
||||||
|
createModule(":/install/InstallTemplate/package.xml",
|
||||||
|
m_outputdir + "/packages/lib/meta/package.xml",
|
||||||
|
QStringList() << "lib" <<
|
||||||
|
"lib data of " + projectName <<
|
||||||
|
Utils::getVersion() <<
|
||||||
|
QDate::currentDate().toString("yyyy-MM-dd"));
|
||||||
|
|
||||||
|
createModule(":/install/InstallTemplate/package.xml",
|
||||||
|
m_outputdir + "/packages/plugins/meta/package.xml",
|
||||||
|
QStringList() << "plugins" <<
|
||||||
|
"plugins data of " + projectName <<
|
||||||
|
Utils::getVersion() <<
|
||||||
|
QDate::currentDate().toString("yyyy-MM-dd"));
|
||||||
|
|
||||||
|
QProcess binaryCreator;
|
||||||
|
binaryCreator.setProgram(m_binarycreator);
|
||||||
|
/*
|
||||||
|
-c $$PWD/config/config.xml -p $$PWD/packages ${QMAKE_FILE_OUT}*/
|
||||||
|
binaryCreator.setArguments(QStringList() << "-c" <<
|
||||||
|
m_outputdir + "/config/config.xml" <<
|
||||||
|
"-p" <<
|
||||||
|
m_outputdir + "/packages" <<
|
||||||
|
m_outputdir + "/installer_" + projectName);
|
||||||
|
|
||||||
|
binaryCreator.start();
|
||||||
|
|
||||||
|
binaryCreator.waitForFinished(2 * 60 * 1000);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void OutputManager::createDirectories()
|
void OutputManager::createDirectories()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if(isInstallFW()){
|
||||||
|
m_pathsToCopy << m_outputdir + "/config";
|
||||||
|
m_copySuccess << QDir(m_outputdir).mkpath("config");
|
||||||
|
|
||||||
|
m_pathsToCopy << m_outputdir + "/packages/base/data/bin";
|
||||||
|
m_copySuccess << QDir(m_outputdir).mkpath("packages/base/data/bin");
|
||||||
|
|
||||||
|
m_pathsToCopy << m_outputdir + "/packages/qml/data/qml";
|
||||||
|
m_copySuccess << QDir(m_outputdir).mkpath("packages/qml/data/qml");
|
||||||
|
|
||||||
|
m_pathsToCopy << m_outputdir + "/packages/lib/data/lib/";
|
||||||
|
m_copySuccess << QDir(m_outputdir).mkpath("packages/lib/data/lib");
|
||||||
|
|
||||||
|
m_pathsToCopy << m_outputdir + "/packages/plugins/data/plugins";
|
||||||
|
m_copySuccess << QDir(m_outputdir).mkpath("packages/plugins/data/plugins");
|
||||||
|
|
||||||
|
} else {
|
||||||
m_pathsToCopy << m_outputdir + "/bin/";
|
m_pathsToCopy << m_outputdir + "/bin/";
|
||||||
m_copySuccess << QDir(m_outputdir).mkdir("bin");
|
m_copySuccess << QDir(m_outputdir).mkdir("bin");
|
||||||
|
|
||||||
@ -142,6 +321,7 @@ void OutputManager::createDirectories()
|
|||||||
|
|
||||||
m_pathsToCopy << m_outputdir + "/plugins/";
|
m_pathsToCopy << m_outputdir + "/plugins/";
|
||||||
m_copySuccess << QDir(m_outputdir).mkdir("plugins");
|
m_copySuccess << QDir(m_outputdir).mkdir("plugins");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OutputManager::copyFile(const QString &source, const QString &destin)
|
bool OutputManager::copyFile(const QString &source, const QString &destin)
|
||||||
|
@ -23,8 +23,14 @@ class OutputManager : public BaseClass
|
|||||||
void copyQml(const QStringList &dirs);
|
void copyQml(const QStringList &dirs);
|
||||||
void copyPlugins(const QStringList &plugins);
|
void copyPlugins(const QStringList &plugins);
|
||||||
|
|
||||||
|
bool isInstallFW() const;
|
||||||
|
|
||||||
|
void checkInstallFrameWork();
|
||||||
|
|
||||||
void createDirectories();
|
void createDirectories();
|
||||||
void createRunFile();
|
void createRunFile();
|
||||||
|
void createInstaller();
|
||||||
|
bool createModule(const QString& from, const QString& to, const QStringList& params);
|
||||||
void copyExec();
|
void copyExec();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -33,3 +33,13 @@ QString Utils::getVersion(){
|
|||||||
|
|
||||||
return file.errorString();
|
return file.errorString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @todo add get description method */
|
||||||
|
QString Utils::getDescription(){
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @todo add get Publicher method */
|
||||||
|
QString Utils::getPublicher(){
|
||||||
|
return "QtDeployer";
|
||||||
|
}
|
||||||
|
@ -8,7 +8,8 @@ private:
|
|||||||
Utils() = delete;
|
Utils() = delete;
|
||||||
public:
|
public:
|
||||||
static QString getVersion();
|
static QString getVersion();
|
||||||
|
static QString getDescription();
|
||||||
|
static QString getPublicher();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // UTILS_H
|
#endif // UTILS_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user