Added binary utils required for the web-update utility.

This commit is contained in:
LoRd_MuldeR 2013-12-09 20:42:02 +01:00
parent ddfedba2dd
commit ac7cd2f155
8 changed files with 83 additions and 22 deletions

BIN
res/toolset/common/gpgv.exe Normal file

Binary file not shown.

BIN
res/toolset/common/gpgv.gpg Normal file

Binary file not shown.

BIN
res/toolset/common/wget.exe Normal file

Binary file not shown.

View File

@ -26,7 +26,7 @@
#define VER_X264_MAJOR 2 #define VER_X264_MAJOR 2
#define VER_X264_MINOR 2 #define VER_X264_MINOR 2
#define VER_X264_PATCH 7 #define VER_X264_PATCH 7
#define VER_X264_BUILD 673 #define VER_X264_BUILD 678
#define VER_X264_MINIMUM_REV 2363 #define VER_X264_MINIMUM_REV 2363
#define VER_X264_CURRENT_API 140 #define VER_X264_CURRENT_API 140

View File

@ -977,7 +977,7 @@ void MainWindow::checkUpdates(void)
return; return;
} }
UpdaterDialog *updater = new UpdaterDialog(this); UpdaterDialog *updater = new UpdaterDialog(this, QString("%1/toolset").arg(m_appDir));
updater->exec(); updater->exec();
X264_DELETE(updater); X264_DELETE(updater);
} }

View File

@ -50,10 +50,11 @@ while(0)
// Constructor & Destructor // Constructor & Destructor
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
UpdaterDialog::UpdaterDialog(QWidget *parent) UpdaterDialog::UpdaterDialog(QWidget *parent, const QString &binDir)
: :
QDialog(parent), QDialog(parent),
ui(new Ui::UpdaterDialog()), ui(new Ui::UpdaterDialog()),
m_binDir(binDir),
m_state(0), m_state(0),
m_firstShow(true) m_firstShow(true)
{ {
@ -77,24 +78,6 @@ UpdaterDialog::UpdaterDialog(QWidget *parent)
//Hide labels //Hide labels
ui->labelInfo->hide(); ui->labelInfo->hide();
ui->labelUrl->hide(); ui->labelUrl->hide();
/*
//TEST
QBlake2Checksum checksum;
checksum.update("The quick brown fox jumps over the lazy dog");
qWarning("Result: %s\n", checksum.finalize().constData());
//TEST
QBlake2Checksum checksum2;
QFile file("G:\\Aktorwerkstoffe.2013-11-22.rar");
if(file.open(QIODevice::ReadOnly))
{
checksum2.update(file);
qWarning("Result: %s\n", checksum2.finalize().constData());
}
*/
QMessageBox::information(this, "Disclaimer", "Welcome to the auto-updater mockup demo!");
} }
UpdaterDialog::~UpdaterDialog(void) UpdaterDialog::~UpdaterDialog(void)
@ -156,6 +139,15 @@ void UpdaterDialog::initUpdate(void)
//Show animation //Show animation
SHOW_ANIMATION(true); SHOW_ANIMATION(true);
//Check binary files
if(!checkBinaries())
{
ui->buttonCancel->setEnabled(true);
QMessageBox::critical(this, tr("File Error"), tr("At least one file required by web-update is missing or corrupted.<br>Please re-install this application and then try again!"));
close();
return;
}
//Begin updater test run //Begin updater test run
m_state = 0; m_state = 0;
QTimer::singleShot(333, this, SLOT(updateState())); QTimer::singleShot(333, this, SLOT(updateState()));
@ -191,3 +183,62 @@ void UpdaterDialog::updateState(void)
break; break;
} }
} }
///////////////////////////////////////////////////////////////////////////////
// Private Functions
///////////////////////////////////////////////////////////////////////////////
bool UpdaterDialog::checkBinaries(void)
{
qDebug("[File Verification]");
static struct
{
const char* name;
const char* hash;
}
FILE_INFO[] =
{
{ "wget.exe", "7b522345239bcb95b5b0f7f50a883ba5957894a1feb769763e38ed789a8a0f63fead0155f54b9ffd0f1cdc5dfd855d207a6e7a8e4fd192589a8838ce646c504e" },
{ "gpgv.exe", "e61d28e4c47b2422ceec7b8fc08f9c70f10a3056e3779a974026eb24fe09551eedc2e7f34fbe5ef8e844fab0dbe68b85c4ca69d63bf85d445f7cae152c17f589" },
{ "gpgv.gpg", "58e0f0e462bbd0b5aa4f638801c1097da7da4b3eb38c8c88ad1db23705c0f11e174b083fa55fe76bd3ba196341c967833a6f3427d6f63ad8565900745535d8fa" },
{ NULL, NULL }
};
bool okay = true;
for(size_t i = 0; FILE_INFO[i].name; i++)
{
okay = okay && checkFileHash(QString("%1/common/%2").arg(m_binDir, QString::fromLatin1(FILE_INFO[i].name)), FILE_INFO[i].hash);
}
if(okay)
{
qDebug("Completed.\n");
}
return okay;
}
bool UpdaterDialog::checkFileHash(const QString &filePath, const char *expectedHash)
{
qDebug("Checking file: %s", filePath.toUtf8().constData());
QBlake2Checksum checksum2;
QFile file(filePath);
if(file.open(QIODevice::ReadOnly))
{
checksum2.update(file);
const QByteArray fileHash = checksum2.finalize();
if((strlen(expectedHash) != fileHash.size()) || (memcmp(fileHash.constData(), expectedHash, fileHash.size()) != 0))
{
qWarning("\nFile appears to be corrupted:\n%s\n", filePath.toUtf8().constData());
qWarning("Expected Hash: %s\nDetected Hash: %s\n", expectedHash, fileHash.constData());
return false;
}
return true;
}
else
{
qWarning("Failed to open file:\n%s\n", filePath.toUtf8().constData());
return false;
}
}

View File

@ -35,7 +35,7 @@ class UpdaterDialog : public QDialog
Q_OBJECT Q_OBJECT
public: public:
UpdaterDialog(QWidget *parent); UpdaterDialog(QWidget *parent, const QString &binDir);
~UpdaterDialog(void); ~UpdaterDialog(void);
protected: protected:
@ -49,7 +49,11 @@ private slots:
private: private:
Ui::UpdaterDialog *const ui; Ui::UpdaterDialog *const ui;
bool checkBinaries(void);
bool checkFileHash(const QString &filePath, const char *expectedHash);
bool m_firstShow; bool m_firstShow;
const QString m_binDir;
QMovie *m_animator; QMovie *m_animator;
int m_state; int m_state;
}; };

View File

@ -72,11 +72,14 @@ rmdir /S /Q "$(TargetDir)\toolset"
rmdir /S /Q "$(TargetDir)\imageformats" rmdir /S /Q "$(TargetDir)\imageformats"
mkdir "$(TargetDir)\toolset\x86" mkdir "$(TargetDir)\toolset\x86"
mkdir "$(TargetDir)\toolset\x64" mkdir "$(TargetDir)\toolset\x64"
mkdir "$(TargetDir)\toolset\common"
mkdir "$(TargetDir)\imageformats" mkdir "$(TargetDir)\imageformats"
copy /Y "$(SolutionDir)res\toolset\x86\*.exe" "$(TargetDir)\toolset\x86\" copy /Y "$(SolutionDir)res\toolset\x86\*.exe" "$(TargetDir)\toolset\x86\"
copy /Y "$(SolutionDir)res\toolset\x86\*.dll" "$(TargetDir)\toolset\x86\" copy /Y "$(SolutionDir)res\toolset\x86\*.dll" "$(TargetDir)\toolset\x86\"
copy /Y "$(SolutionDir)res\toolset\x64\*.exe" "$(TargetDir)\toolset\x64\" copy /Y "$(SolutionDir)res\toolset\x64\*.exe" "$(TargetDir)\toolset\x64\"
copy /Y "$(SolutionDir)res\toolset\x64\*.dll" "$(TargetDir)\toolset\x64\" copy /Y "$(SolutionDir)res\toolset\x64\*.dll" "$(TargetDir)\toolset\x64\"
copy /Y "$(SolutionDir)res\toolset\common\*.exe" "$(TargetDir)\toolset\common\"
copy /Y "$(SolutionDir)res\toolset\common\*.gpg" "$(TargetDir)\toolset\common\"
copy /Y "$(QTDIR)\bin\QtCored4.dll" "$(TargetDir)" copy /Y "$(QTDIR)\bin\QtCored4.dll" "$(TargetDir)"
copy /Y "$(QTDIR)\bin\QtGuid4.dll" "$(TargetDir)" copy /Y "$(QTDIR)\bin\QtGuid4.dll" "$(TargetDir)"
copy /Y "$(QTDIR)\bin\QtSvgd4.dll" "$(TargetDir)" copy /Y "$(QTDIR)\bin\QtSvgd4.dll" "$(TargetDir)"
@ -151,9 +154,12 @@ rmdir /S /Q "$(TargetDir)\toolset"
rmdir /S /Q "$(TargetDir)\imageformats" rmdir /S /Q "$(TargetDir)\imageformats"
mkdir "$(TargetDir)\toolset\x86" mkdir "$(TargetDir)\toolset\x86"
mkdir "$(TargetDir)\toolset\x64" mkdir "$(TargetDir)\toolset\x64"
mkdir "$(TargetDir)\toolset\common"
mkdir "$(TargetDir)\imageformats" mkdir "$(TargetDir)\imageformats"
copy /Y "$(SolutionDir)res\toolset\x86\*.exe" "$(TargetDir)\toolset\x86\" copy /Y "$(SolutionDir)res\toolset\x86\*.exe" "$(TargetDir)\toolset\x86\"
copy /Y "$(SolutionDir)res\toolset\x64\*.exe" "$(TargetDir)\toolset\x64\" copy /Y "$(SolutionDir)res\toolset\x64\*.exe" "$(TargetDir)\toolset\x64\"
copy /Y "$(SolutionDir)res\toolset\common\*.exe" "$(TargetDir)\toolset\common\"
copy /Y "$(SolutionDir)res\toolset\common\*.gpg" "$(TargetDir)\toolset\common\"
copy /Y "$(QTDIR)\bin\QtCore4.dll" "$(TargetDir)" copy /Y "$(QTDIR)\bin\QtCore4.dll" "$(TargetDir)"
copy /Y "$(QTDIR)\bin\QtGui4.dll" "$(TargetDir)" copy /Y "$(QTDIR)\bin\QtGui4.dll" "$(TargetDir)"
copy /Y "$(QTDIR)\bin\QtSvg4.dll" "$(TargetDir)" copy /Y "$(QTDIR)\bin\QtSvg4.dll" "$(TargetDir)"