-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
248 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
#include "finstaller.h" | ||
|
||
FInstaller::FInstaller(QObject *parent) : QObject(parent) | ||
{ | ||
connect(process, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(slotFinished())); | ||
} | ||
|
||
void FInstaller::setDeployPath(QString path) { | ||
m_deploypath = path; | ||
} | ||
|
||
void FInstaller::setInstallerPath(QString path) { | ||
m_installerpath = path; | ||
} | ||
|
||
void FInstaller::setVendorName(QString name) { | ||
m_vendorName = name; | ||
} | ||
|
||
void FInstaller::createConfig() { | ||
QDir configDir(m_installerpath + "/config"); | ||
if(!configDir.exists()) { | ||
bool result = configDir.mkpath(m_installerpath + "/config"); | ||
if(!result) | ||
return; | ||
} | ||
QFile config(m_installerpath + "/config/" +"config.xml"); | ||
if(config.open(QIODevice::ReadWrite)) { | ||
const QString str = configText; | ||
config.write(str.toLocal8Bit()); | ||
config.close(); | ||
} | ||
} | ||
|
||
void FInstaller::createPackages() { | ||
QDir packagesDir(m_installerpath + "/packages/" + m_vendorName); | ||
if(!packagesDir.exists()) { | ||
bool result = packagesDir.mkpath(m_installerpath + "/packages/" + m_vendorName + "/data"); | ||
result = result & packagesDir.mkpath(m_installerpath + "/packages/" + m_vendorName + "/meta"); | ||
if(!result) | ||
return; | ||
} | ||
QFile packages(m_installerpath + "/packages/" + m_vendorName + "/meta/package.xml"); | ||
if(packages.open(QIODevice::ReadWrite)) { | ||
const QString str = packageText; | ||
packages.write(str.toLocal8Bit()); | ||
packages.close(); | ||
} | ||
} | ||
|
||
QFile *FInstaller::prepareBatFile() { | ||
QFile *file = new QFile("temp.bat"); | ||
if(file->open(QIODevice::ReadWrite)) { | ||
QString str = "set PATH="+ Worker::getInstance()->compl1Path() + "/bin;" +Worker::getInstance()->compl2Path() + "/bin;%PATH%\n"; | ||
file->write(str.toLocal8Bit()); | ||
return file; | ||
} | ||
return nullptr; | ||
} | ||
|
||
void FInstaller::createOffInstaller() { | ||
copyDir(m_deploypath, m_installerpath + "/packages/" + m_vendorName + "/data"); | ||
|
||
QStringList arguments; | ||
arguments.append("-c " + m_installerpath + "/config/config.xml"); | ||
arguments.append("-p " + m_installerpath + "/packages"); | ||
arguments.append("-f"); | ||
arguments.append(m_installerpath + "/Installer.exe"); | ||
|
||
|
||
QFile *file = prepareBatFile(); | ||
QString str = Worker::getInstance()->qtPath() + "/Tools/QtInstallerFramework/3.1/bin/binarycreator " + arguments.join(" "); | ||
file->write(str.toLocal8Bit()); | ||
file->close(); | ||
file->deleteLater(); | ||
process->start("temp.bat"); | ||
} | ||
|
||
void FInstaller::slotFinished() { | ||
QFile::remove("temp.bat"); | ||
emit finished(); | ||
} | ||
|
||
void FInstaller::copyDir(QString out, QString in) { | ||
QDir outDir(out); | ||
if(!outDir.exists()) | ||
return; | ||
|
||
QStringList dirList = outDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); | ||
for(int i = 0; i < dirList.length(); ++i) { | ||
QString in_path = in + QDir::separator() + dirList[i]; | ||
outDir.mkpath(in_path); | ||
copyDir(out+ QDir::separator() + dirList[i], in_path); | ||
} | ||
|
||
QStringList fileList = outDir.entryList(QDir::Files); | ||
for(int i = 0; i < fileList.length(); ++i) { | ||
QFile::copy(out + QDir::separator() + fileList.at(i), in + QDir::separator() + fileList.at(i)); | ||
} | ||
} | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#ifndef FINSTALLER_H | ||
#define FINSTALLER_H | ||
|
||
#include <QObject> | ||
#include <QFile> | ||
#include <QDir> | ||
#include <QProcess> | ||
#include <QStringList> | ||
#include <QDebug> | ||
#include "worker.h" | ||
|
||
class FInstaller : public QObject | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit FInstaller(QObject *parent = nullptr); | ||
|
||
Q_INVOKABLE void setDeployPath(QString); | ||
Q_INVOKABLE void setInstallerPath(QString); | ||
Q_INVOKABLE void setVendorName(QString); | ||
Q_INVOKABLE void createConfig(); | ||
Q_INVOKABLE void createPackages(); | ||
|
||
Q_INVOKABLE void createOffInstaller(); | ||
|
||
|
||
private: | ||
|
||
QString m_deploypath; | ||
QString m_installerpath; | ||
QString m_vendorName = "com.vendor.example"; | ||
|
||
QProcess *process = new QProcess(); | ||
|
||
|
||
void copyDir(QString out, QString in); | ||
QFile *prepareBatFile(); | ||
|
||
QString configText = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" | ||
"<Installer>\n" | ||
" <Name>Installer</Name>\n" | ||
" <Version>1.0.0</Version>\n" | ||
" <Title>1.0.0 Installer</Title>\n" | ||
" <Publisher>Installer</Publisher>\n" | ||
" <StartMenuDir>Installer</StartMenuDir>\n" | ||
" <TargetDir>@RootDir@Program Files (x86)\Installer</TargetDir>\n" | ||
" <AllowSpaceInPath>true</AllowSpaceInPath>\n" | ||
"</Installer>\n"; | ||
|
||
QString packageText = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" | ||
"<Package>\n" | ||
" <DisplayName>Installer</DisplayName>\n" | ||
" <Description>The main component</Description>\n" | ||
" <Version>1.0.0</Version>\n" | ||
" <ReleaseDate>2019-01-30</ReleaseDate>\n" | ||
" <Default>true</Default>\n" | ||
" <Name>" + m_vendorName + "</Name>\n" | ||
" <ForcedInstallation>true</ForcedInstallation>\n" | ||
" <RequiresAdminRights>true</RequiresAdminRights>\n" | ||
"</Package>\n"; | ||
|
||
|
||
|
||
|
||
|
||
signals: | ||
void finished(); | ||
|
||
public slots: | ||
void slotFinished(); | ||
}; | ||
|
||
#endif // FINSTALLER_H |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,76 @@ | ||
import QtQuick 2.12 | ||
import QtQuick.Controls 2.5 | ||
|
||
import Components 1.0 | ||
import AutoTools 1.0 | ||
|
||
Item { | ||
Label { | ||
x: 20; y: 20 | ||
font.pixelSize: 18 | ||
font.weight: Font.Bold | ||
text: "Qt Installer Framework" | ||
} | ||
FInstaller { | ||
id: _finstaller | ||
onFinished: { | ||
_busyDialog.close() | ||
} | ||
} | ||
BusiDialog { | ||
id: _busyDialog | ||
} | ||
|
||
Flickable { | ||
x: 20; y: 50 | ||
width: parent.width; height: parent.height-y | ||
contentHeight: _content.height+20 | ||
clip: true | ||
Column { | ||
id: _content | ||
spacing: 20 | ||
SelectFolderRow { | ||
text: "Папка с деплоем" | ||
onSetPath: { | ||
_finstaller.setDeployPath(path) | ||
} | ||
} | ||
SelectFolderRow { | ||
text: "Папка установки" | ||
onSetPath: { | ||
_finstaller.setInstallerPath(path) | ||
} | ||
} | ||
SelectFolderRow { | ||
text: qsTr("Вендор") | ||
isFolderButton: false | ||
path: "com.vendor.example" | ||
onSetPath: { | ||
_finstaller.setVendorName(path) | ||
} | ||
} | ||
Row { | ||
spacing: 20 | ||
Button { | ||
text: qsTr("Создать config") | ||
onClicked: { | ||
_finstaller.createConfig() | ||
} | ||
} | ||
Button { | ||
text: qsTr("Создать packages") | ||
onClicked: { | ||
_finstaller.createPackages() | ||
} | ||
} | ||
} | ||
Button { | ||
text: qsTr("Создать офлайн инсталятор") | ||
onClicked: { | ||
_busyDialog.open() | ||
_finstaller.createOffInstaller() | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters