mirror of
https://github.com/QuasarApp/CQtDeployer.git
synced 2025-04-27 10:14:32 +00:00
ref #558 "added support of the calc hash sum"
This commit is contained in:
parent
5acd532b6f
commit
303922ea5b
@ -226,6 +226,7 @@ void DeployCore::help() {
|
||||
" All templates extract into targetDirectory."
|
||||
" For change target directory use the targetDir option."
|
||||
" Example: cqtdeployer -bin myExecutable getDefaultTemplate qif deb."},
|
||||
{"noHashSum", "This option disable computation of the packages hash sum"}
|
||||
|
||||
|
||||
}
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <QProcess>
|
||||
#include <QThread>
|
||||
#include <cassert>
|
||||
#include <QCryptographicHash>
|
||||
|
||||
#define TMP_PACKAGE_DIR "tmp_data"
|
||||
|
||||
@ -40,6 +41,39 @@ void Packing::setDistribution(const QList<iDistribution*> &pakages) {
|
||||
_pakages = pakages;
|
||||
}
|
||||
|
||||
void Packing::calcDistributiveHash(const iDistribution* distro) {
|
||||
|
||||
if (QuasarAppUtils::Params::isEndable("noHashSum")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!distro) {
|
||||
internalError();
|
||||
return;
|
||||
}
|
||||
|
||||
auto files = distro->outPutFiles();
|
||||
|
||||
for (const auto &file: files) {
|
||||
|
||||
QFileInfo info(file);
|
||||
|
||||
QuasarAppUtils::Params::log("Computing hash of " + info.absoluteFilePath(),
|
||||
QuasarAppUtils::Info);
|
||||
|
||||
QFile out(info.absoluteFilePath() + ".md5");
|
||||
if (!out.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
|
||||
QuasarAppUtils::Params::log("Failed to open " + info.absoluteFilePath(),
|
||||
QuasarAppUtils::Error);
|
||||
continue;
|
||||
}
|
||||
|
||||
out.write(calcHash(info.absoluteFilePath()));
|
||||
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
|
||||
bool Packing::create() {
|
||||
|
||||
if (!collectPackages()) {
|
||||
@ -120,6 +154,8 @@ bool Packing::create() {
|
||||
return false;
|
||||
}
|
||||
|
||||
calcDistributiveHash(package);
|
||||
|
||||
package->removeTemplate();
|
||||
delete package;
|
||||
}
|
||||
@ -245,6 +281,18 @@ bool Packing::restorePackagesLocations() {
|
||||
return true;
|
||||
}
|
||||
|
||||
QByteArray Packing::calcHash(const QString &file) {
|
||||
QFile f(file);
|
||||
if (!f.open(QIODevice::ReadOnly)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
QByteArray hash = QCryptographicHash::hash(f.readAll(), QCryptographicHash::Md5).toHex();
|
||||
f.close();
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
void Packing::handleOutputUpdate() {
|
||||
|
||||
QByteArray stdoutLog = _proc->readAllStandardOutput();
|
||||
|
@ -53,6 +53,19 @@ private:
|
||||
|
||||
bool restorePackagesLocations();
|
||||
|
||||
/**
|
||||
* @brief calcDistributiveHash This method calc md hashes for all pacakges of the @a distro distributive
|
||||
* @param distro This is pointer to the distributive object.
|
||||
*/
|
||||
void calcDistributiveHash(const iDistribution* distro);
|
||||
|
||||
/**
|
||||
* @brief calcHash This method calc md5 hash of the file.
|
||||
* @param file This is a file path
|
||||
* @return string value of the file hash. Using the hex.
|
||||
*/
|
||||
QByteArray calcHash(const QString& file);
|
||||
|
||||
QList<iDistribution*> _pakages;
|
||||
QProcess *_proc = nullptr;
|
||||
QHash<QString, QString> _packagesLocations;
|
||||
|
@ -186,6 +186,8 @@ private slots:
|
||||
|
||||
void testBinPrefix();
|
||||
|
||||
void testMd5();
|
||||
|
||||
void customTest();
|
||||
};
|
||||
|
||||
@ -1499,6 +1501,30 @@ void deploytest::testBinPrefix() {
|
||||
|
||||
}
|
||||
|
||||
void deploytest::testMd5() {
|
||||
TestUtils utils;
|
||||
|
||||
#ifdef Q_OS_UNIX
|
||||
QString bin = TestBinDir + "TestOnlyC";
|
||||
auto outFile = "./" + DISTRO_DIR + "/InstallerTestOnlyC.run";
|
||||
|
||||
#else
|
||||
QString bin = TestBinDir + "TestOnlyC.exe";
|
||||
auto outFile = "./" + DISTRO_DIR + "/InstallerTestOnlyC.exe";
|
||||
|
||||
#endif
|
||||
|
||||
auto comapareTreeqif = utils.createTree(
|
||||
{
|
||||
outFile,
|
||||
});
|
||||
|
||||
runTestParams({"-bin", bin,
|
||||
"force-clear",
|
||||
"qif",
|
||||
"qifFromSystem"}, &comapareTreeqif);
|
||||
}
|
||||
|
||||
void deploytest::customTest() {
|
||||
// runTestParams({"-confFile", "path",
|
||||
// "qifFromSystem"});
|
||||
|
@ -67,6 +67,8 @@ cqtdeployer -option1 value1 -option2 list, of, values flag1 flag2 flag3
|
||||
| noQt | Ignors the error of initialize of a qmake. Use only if your application does not use the qt framework. |
|
||||
| allowEmptyPackages | Allows configure the empty packages. |
|
||||
| getDefaultTemplate | Extracts defaults deb or qif templates. For more information see the extracting default templates [page](ExtractDefaultsTemplates.md) |
|
||||
| noHashSum | Disable computation of the packages hash sum |
|
||||
|
||||
|
||||
### Deploy options
|
||||
|
||||
|
@ -69,6 +69,7 @@ cqtdeployer -option1 value1 -option2 list,of,values flag1 flag2 flag3
|
||||
| noQt | Игнорирует ошибку инициализации qmake. Используйте только в том случае, если ваше приложение не использует платформу qt. |
|
||||
| allowEmptyPackages | Разрешите настраивать пустые пакеты. |
|
||||
| getDefaultTemplate | Извлекает deb или qif шаблоны по умолчанию. Для получения дополнительной информации см. [Страницу](ExtractDefaultsTemplates.md) извлечения шаблонов по умолчанию. |
|
||||
| noHashSum | Отключить вычисление хеш-суммы пакетов |
|
||||
|
||||
### Параметры развертывания:
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user