summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Wenger <domonoky@googlemail.com>2007-08-26 16:44:23 +0000
committerDominik Wenger <domonoky@googlemail.com>2007-08-26 16:44:23 +0000
commit0aeea5d9a715f5076cab4e9eaaa2a41665203186 (patch)
treeaf357e3af27f90a995554b392e397cfb7dd66823
parent848abc803760298b2f97d1ffb135418f16a8166a (diff)
downloadrockbox-0aeea5d9a715f5076cab4e9eaaa2a41665203186.tar.gz
rockbox-0aeea5d9a715f5076cab4e9eaaa2a41665203186.zip
rbutilQt: Add downloading of a bootloaders-info file, with md5sums from the bootloaders, to make a version check. Also added the bootloader to the installlog.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14462 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--rbutil/rbutilqt/installbootloader.cpp125
-rw-r--r--rbutil/rbutilqt/installbootloader.h25
-rw-r--r--rbutil/rbutilqt/installzip.cpp1
-rw-r--r--rbutil/rbutilqt/rbutil.ini2
-rw-r--r--rbutil/rbutilqt/rbutilqt.cpp57
5 files changed, 190 insertions, 20 deletions
diff --git a/rbutil/rbutilqt/installbootloader.cpp b/rbutil/rbutilqt/installbootloader.cpp
index c124c71150..11798c1232 100644
--- a/rbutil/rbutilqt/installbootloader.cpp
+++ b/rbutil/rbutilqt/installbootloader.cpp
@@ -22,7 +22,7 @@
22 22
23BootloaderInstaller::BootloaderInstaller(QObject* parent): QObject(parent) 23BootloaderInstaller::BootloaderInstaller(QObject* parent): QObject(parent)
24{ 24{
25 25
26} 26}
27 27
28void BootloaderInstaller::install(ProgressloggerInterface* dp) 28void BootloaderInstaller::install(ProgressloggerInterface* dp)
@@ -179,6 +179,108 @@ void BootloaderInstaller::installEnded(bool error)
179 m_dp->abort(); 179 m_dp->abort();
180} 180}
181 181
182bool BootloaderInstaller::downloadInfo()
183{
184 // try to get the current build information
185 infodownloader = new HttpGet(this);
186
187 connect(infodownloader, SIGNAL(done(bool)), this, SLOT(infoDownloadDone(bool)));
188 connect(infodownloader, SIGNAL(requestFinished(int, bool)), this, SLOT(infoRequestFinished(int, bool)));
189
190 infodownloader->setProxy(m_proxy);
191
192 qDebug() << "downloading bootloader info";
193 infodownloader->setFile(&bootloaderInfo);
194 infodownloader->getFile(QUrl(m_bootloaderinfoUrl));
195
196 // block until its downloaded
197 qDebug() << "Waiting for Download finished";
198 infoDownloaded=false;
199 infoError = false;
200 while(!infoDownloaded )
201 QApplication::processEvents();
202 return !infoError;
203}
204
205void BootloaderInstaller::infoDownloadDone(bool error)
206{
207 if(error)
208 {
209 qDebug() << "network error:" << infodownloader->error();
210 return;
211 }
212 qDebug() << "network status:" << infodownloader->error();
213
214 infoDownloaded = true;
215}
216
217void BootloaderInstaller::infoRequestFinished(int id, bool error)
218{
219
220 if(error)
221 {
222 QString errorString;
223 errorString = tr("Network error: %1. Please check your network and proxy settings.")
224 .arg(infodownloader->errorString());
225 if(error) QMessageBox::about(NULL, "Network Error", errorString);
226 qDebug() << "downloadDone:" << id << error;
227
228 infoError = true;
229 infoDownloaded = true;
230 }
231 qDebug() << "infoRequestFinished:" << id << error;
232}
233
234
235void BootloaderInstaller::createInstallLog()
236{
237 m_dp->addItem(tr("Creating installation log"),LOGINFO);
238 QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0);
239
240 bootloaderInfo.open();
241 QSettings info(bootloaderInfo.fileName(), QSettings::IniFormat, this);
242 bootloaderInfo.close();
243 info.beginGroup(m_device);
244
245 installlog.beginGroup("Bootloader");
246 installlog.setValue("md5sum",info.value("md5sum").toString());
247 installlog.endGroup();
248 installlog.sync();
249}
250
251void BootloaderInstaller::removeInstallLog()
252{
253 m_dp->addItem(tr("Editing installation log"),LOGINFO);
254 QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0);
255 installlog.beginGroup("Bootloader");
256 installlog.remove("md5sum");
257 installlog.endGroup();
258 installlog.sync();
259}
260
261
262bool BootloaderInstaller::uptodate()
263{
264 QString installedMd5;
265 QString serverMd5;
266
267 QSettings installlog(m_mountpoint + "/.rockbox/rbutil.log", QSettings::IniFormat, 0);
268 installlog.beginGroup("Bootloader");
269 installedMd5 = installlog.value("md5sum").toString();
270 installlog.endGroup();
271
272 bootloaderInfo.open();
273 QSettings info(bootloaderInfo.fileName(), QSettings::IniFormat, this);
274 bootloaderInfo.close();
275 info.beginGroup(m_device);
276 serverMd5 = info.value("md5sum").toString();
277 info.endGroup();
278
279 if(installedMd5 != serverMd5)
280 return false;
281 else
282 return true;
283}
182 284
183/************************************************** 285/**************************************************
184*** gigabeat secific code 286*** gigabeat secific code
@@ -244,6 +346,8 @@ void BootloaderInstaller::gigabeatPrepare()
244 return; 346 return;
245 } 347 }
246 348
349 removeInstallLog();
350
247 emit done(false); //success 351 emit done(false); //success
248 } 352 }
249 353
@@ -301,6 +405,8 @@ void BootloaderInstaller::gigabeatFinish()
301 405
302 downloadFile.remove(); 406 downloadFile.remove();
303 407
408 createInstallLog();
409
304 m_dp->addItem(tr("Bootloader install finished successfully."),LOGOK); 410 m_dp->addItem(tr("Bootloader install finished successfully."),LOGOK);
305 m_dp->addItem(tr("To finish the Bootloader installation, follow the steps below."),LOGINFO); 411 m_dp->addItem(tr("To finish the Bootloader installation, follow the steps below."),LOGINFO);
306 m_dp->addItem(tr("1. Eject/Unmount your Device."),LOGINFO); 412 m_dp->addItem(tr("1. Eject/Unmount your Device."),LOGINFO);
@@ -357,6 +463,8 @@ void BootloaderInstaller::iaudioFinish()
357 463
358 downloadFile.remove(); 464 downloadFile.remove();
359 465
466 createInstallLog();
467
360 m_dp->addItem(tr("Bootloader install finished successfully."),LOGOK); 468 m_dp->addItem(tr("Bootloader install finished successfully."),LOGOK);
361 m_dp->addItem(tr("To finish the Bootloader installation, follow the steps below."),LOGINFO); 469 m_dp->addItem(tr("To finish the Bootloader installation, follow the steps below."),LOGINFO);
362 m_dp->addItem(tr("1. Eject/Unmount your Device."),LOGINFO); 470 m_dp->addItem(tr("1. Eject/Unmount your Device."),LOGINFO);
@@ -448,6 +556,8 @@ void BootloaderInstaller::h10Prepare()
448 return; 556 return;
449 } 557 }
450 558
559 removeInstallLog();
560
451 emit done(false); //success 561 emit done(false); //success
452 562
453 } 563 }
@@ -503,7 +613,9 @@ void BootloaderInstaller::h10Finish()
503 } 613 }
504 614
505 downloadFile.remove(); 615 downloadFile.remove();
506 616
617 createInstallLog();
618
507 m_dp->addItem(tr("Bootloader install finished successfully."),LOGOK); 619 m_dp->addItem(tr("Bootloader install finished successfully."),LOGOK);
508 m_dp->abort(); 620 m_dp->abort();
509 621
@@ -639,6 +751,7 @@ void BootloaderInstaller::ipodPrepare()
639 if (delete_bootloader(&ipod)==0) 751 if (delete_bootloader(&ipod)==0)
640 { 752 {
641 m_dp->addItem(tr("Successfully removed Bootloader"),LOGOK); 753 m_dp->addItem(tr("Successfully removed Bootloader"),LOGOK);
754 removeInstallLog();
642 emit done(false); 755 emit done(false);
643 ipod_close(&ipod); 756 ipod_close(&ipod);
644 return; 757 return;
@@ -729,6 +842,7 @@ void BootloaderInstaller::ipodFinish()
729 if (add_bootloader(&ipod, m_tempfilename.toLatin1().data(), FILETYPE_DOT_IPOD)==0) 842 if (add_bootloader(&ipod, m_tempfilename.toLatin1().data(), FILETYPE_DOT_IPOD)==0)
730 { 843 {
731 m_dp->addItem(tr("Successfully added Bootloader"),LOGOK); 844 m_dp->addItem(tr("Successfully added Bootloader"),LOGOK);
845 createInstallLog();
732 emit done(false); 846 emit done(false);
733 ipod_close(&ipod); 847 ipod_close(&ipod);
734 return; 848 return;
@@ -839,6 +953,7 @@ void BootloaderInstaller::sansaPrepare()
839 if (sansa_delete_bootloader(&sansa)==0) 953 if (sansa_delete_bootloader(&sansa)==0)
840 { 954 {
841 m_dp->addItem(tr("Successfully removed Bootloader"),LOGOK); 955 m_dp->addItem(tr("Successfully removed Bootloader"),LOGOK);
956 removeInstallLog();
842 emit done(false); 957 emit done(false);
843 sansa_close(&sansa); 958 sansa_close(&sansa);
844 return; 959 return;
@@ -903,6 +1018,7 @@ void BootloaderInstaller::sansaFinish()
903 if (sansa_add_bootloader(&sansa, m_tempfilename.toLatin1().data(), FILETYPE_MI4)==0) 1018 if (sansa_add_bootloader(&sansa, m_tempfilename.toLatin1().data(), FILETYPE_MI4)==0)
904 { 1019 {
905 m_dp->addItem(tr("Successfully added Bootloader"),LOGOK); 1020 m_dp->addItem(tr("Successfully added Bootloader"),LOGOK);
1021 createInstallLog();
906 emit done(false); 1022 emit done(false);
907 sansa_close(&sansa); 1023 sansa_close(&sansa);
908 return; 1024 return;
@@ -1070,7 +1186,10 @@ void BootloaderInstaller::iriverFinish()
1070 dest = m_mountpoint + "/ihp_120.hex"; 1186 dest = m_mountpoint + "/ihp_120.hex";
1071 else if(series == 300) 1187 else if(series == 300)
1072 dest = m_mountpoint + "/H300.hex"; 1188 dest = m_mountpoint + "/H300.hex";
1189
1073 // copy file 1190 // copy file
1191 QFile destfile(dest);
1192 if(destfile.exists()) destfile.remove();
1074 if(!newHex.copy(dest)) 1193 if(!newHex.copy(dest))
1075 { 1194 {
1076 m_dp->addItem(tr("Could not copy: %1 to %2") 1195 m_dp->addItem(tr("Could not copy: %1 to %2")
@@ -1082,6 +1201,8 @@ void BootloaderInstaller::iriverFinish()
1082 downloadFile.remove(); 1201 downloadFile.remove();
1083 newHex.remove(); 1202 newHex.remove();
1084 1203
1204 createInstallLog();
1205
1085 m_dp->addItem(tr("Bootloader install finished successfully."),LOGOK); 1206 m_dp->addItem(tr("Bootloader install finished successfully."),LOGOK);
1086 m_dp->addItem(tr("To finish the Bootloader installation, follow the steps below."),LOGINFO); 1207 m_dp->addItem(tr("To finish the Bootloader installation, follow the steps below."),LOGINFO);
1087 m_dp->addItem(tr("1. Eject/Unmount your Device."),LOGINFO); 1208 m_dp->addItem(tr("1. Eject/Unmount your Device."),LOGINFO);
diff --git a/rbutil/rbutilqt/installbootloader.h b/rbutil/rbutilqt/installbootloader.h
index 1d5bc465c2..496389e9dc 100644
--- a/rbutil/rbutilqt/installbootloader.h
+++ b/rbutil/rbutilqt/installbootloader.h
@@ -48,23 +48,31 @@ public:
48 48
49 void setMountPoint(QString mountpoint) {m_mountpoint = mountpoint;} 49 void setMountPoint(QString mountpoint) {m_mountpoint = mountpoint;}
50 void setProxy(QUrl proxy) {m_proxy= proxy;} 50 void setProxy(QUrl proxy) {m_proxy= proxy;}
51 void setDevice(QString device) {m_device= device;} // the current plattform 51 void setDevice(QString device) {m_device= device;} //!< the current plattform
52 void setBootloaderMethod(QString method) {m_bootloadermethod= method;} 52 void setBootloaderMethod(QString method) {m_bootloadermethod= method;}
53 void setBootloaderName(QString name){m_bootloadername= name;} 53 void setBootloaderName(QString name){m_bootloadername= name;}
54 void setBootloaderBaseUrl(QString baseUrl){m_bootloaderUrlBase = baseUrl;} 54 void setBootloaderBaseUrl(QString baseUrl){m_bootloaderUrlBase = baseUrl;}
55 void setOrigFirmwarePath(QString path) {m_origfirmware = path;} //for iriver original firmware 55 void setOrigFirmwarePath(QString path) {m_origfirmware = path;} //!< for iriver original firmware
56 56 void setBootloaderInfoUrl(QString url) {m_bootloaderinfoUrl =url; } //!< the url for the info file
57 bool downloadInfo(); //!< should be called before install/uninstall, blocks until downloaded.
58 bool uptodate(); //!< returns wether the bootloader is uptodate
59
57signals: 60signals:
58 void done(bool error); //installation finished. 61 void done(bool error); //installation finished.
59 62
60 // internal signals. Dont use this from out side. 63signals: // internal signals. Dont use this from out side.
61 void prepare(); 64 void prepare();
62 void finish(); 65 void finish();
63 66
64private slots: 67private slots:
68 void createInstallLog(); // adds the bootloader entry to the log
69 void removeInstallLog(); // removes the bootloader entry from the log
70
65 void updateDataReadProgress(int, int); 71 void updateDataReadProgress(int, int);
66 void downloadDone(bool); 72 void downloadDone(bool);
67 void downloadRequestFinished(int, bool); 73 void downloadRequestFinished(int, bool);
74 void infoDownloadDone(bool);
75 void infoRequestFinished(int, bool);
68 void installEnded(bool); 76 void installEnded(bool);
69 77
70 // gigabeat specific routines 78 // gigabeat specific routines
@@ -92,9 +100,16 @@ private slots:
92 void iriverFinish(); 100 void iriverFinish();
93 101
94private: 102private:
103
104 HttpGet *infodownloader;
105 QTemporaryFile bootloaderInfo;
106 volatile bool infoDownloaded;
107 volatile bool infoError;
108
95 QString m_mountpoint, m_device,m_bootloadermethod,m_bootloadername; 109 QString m_mountpoint, m_device,m_bootloadermethod,m_bootloadername;
96 QString m_bootloaderUrlBase,m_tempfilename,m_origfirmware; 110 QString m_bootloaderUrlBase,m_tempfilename,m_origfirmware;
97 QUrl m_proxy; 111 QUrl m_proxy;
112 QString m_bootloaderinfoUrl;
98 bool m_install; 113 bool m_install;
99 114
100 int series,table_entry; // for fwpatcher 115 int series,table_entry; // for fwpatcher
diff --git a/rbutil/rbutilqt/installzip.cpp b/rbutil/rbutilqt/installzip.cpp
index c5e91d8e36..2c7eac6451 100644
--- a/rbutil/rbutilqt/installzip.cpp
+++ b/rbutil/rbutilqt/installzip.cpp
@@ -192,6 +192,7 @@ void ZipInstaller::downloadDone(bool error)
192 installlog.setValue(zipContents.at(i), m_logver); 192 installlog.setValue(zipContents.at(i), m_logver);
193 } 193 }
194 installlog.endGroup(); 194 installlog.endGroup();
195 installlog.sync();
195 196
196 emit cont(); 197 emit cont();
197} 198}
diff --git a/rbutil/rbutilqt/rbutil.ini b/rbutil/rbutilqt/rbutil.ini
index d617f0fb98..09d9e24647 100644
--- a/rbutil/rbutilqt/rbutil.ini
+++ b/rbutil/rbutilqt/rbutil.ini
@@ -3,6 +3,8 @@ download_url=http://www.rockbox.org/download/
3daily_url=http://download.rockbox.org/daily/ 3daily_url=http://download.rockbox.org/daily/
4bleeding_url=http://build.rockbox.org/dist/build- 4bleeding_url=http://build.rockbox.org/dist/build-
5server_conf_url=http://www.rockbox.org/daily/build-info 5server_conf_url=http://www.rockbox.org/daily/build-info
6#bootloader_info_url=http://download.rockbox.org/bootloader/bootloaders-info
7bootloader_info_url=http://b23.org/~domonoky/bootloaders-info
6bleeding_info=http://build.rockbox.org/cvsmod/build-info 8bleeding_info=http://build.rockbox.org/cvsmod/build-info
7font_url=http://www.rockbox.org/daily/fonts/rockbox-fonts.zip 9font_url=http://www.rockbox.org/daily/fonts/rockbox-fonts.zip
8last_release=2.5 10last_release=2.5
diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp
index 3d700b7e81..a374737bd8 100644
--- a/rbutil/rbutilqt/rbutilqt.cpp
+++ b/rbutil/rbutilqt/rbutilqt.cpp
@@ -337,6 +337,40 @@ void RbUtilQt::installBl()
337 logger->show(); 337 logger->show();
338 338
339 QString platform = userSettings->value("defaults/platform").toString(); 339 QString platform = userSettings->value("defaults/platform").toString();
340
341 // create installer
342 blinstaller = new BootloaderInstaller(this);
343
344 blinstaller->setMountPoint(userSettings->value("defaults/mountpoint").toString());
345
346 blinstaller->setProxy(proxy());
347 blinstaller->setDevice(platform);
348 blinstaller->setBootloaderMethod(devices->value(platform + "/bootloadermethod").toString());
349 blinstaller->setBootloaderName(devices->value(platform + "/bootloadername").toString());
350 blinstaller->setBootloaderBaseUrl(devices->value("bootloader_url").toString());
351 blinstaller->setBootloaderInfoUrl(devices->value("bootloader_info_url").toString());
352 if(!blinstaller->downloadInfo())
353 {
354 logger->addItem(tr("Could not get the bootloader info file!"),LOGERROR);
355 logger->abort();
356 return;
357 }
358
359 if(blinstaller->uptodate())
360 {
361 int ret = QMessageBox::question(this, tr("Bootloader Installation"),
362 tr("It seem your Bootloader is already uptodate.\n"
363 "Do really want to install it?"),
364 QMessageBox::Ok | QMessageBox::Cancel,
365 QMessageBox::Cancel);
366 if(ret == QMessageBox::Cancel)
367 {
368 logger->addItem(tr("Bootloader installation Canceled!"),LOGERROR);
369 logger->abort();
370 return;
371 }
372
373 }
340 374
341 // if fwpatcher , ask for extra file 375 // if fwpatcher , ask for extra file
342 QString offirmware; 376 QString offirmware;
@@ -367,22 +401,11 @@ void RbUtilQt::installBl()
367 return; 401 return;
368 } 402 }
369 } 403 }
370
371 // create installer
372 blinstaller = new BootloaderInstaller(this);
373
374 blinstaller->setMountPoint(userSettings->value("defaults/mountpoint").toString());
375
376 blinstaller->setProxy(proxy());
377 blinstaller->setDevice(platform);
378 blinstaller->setBootloaderMethod(devices->value(platform + "/bootloadermethod").toString());
379 blinstaller->setBootloaderName(devices->value(platform + "/bootloadername").toString());
380 blinstaller->setBootloaderBaseUrl(devices->value("bootloader_url").toString());
381 blinstaller->setOrigFirmwarePath(offirmware); 404 blinstaller->setOrigFirmwarePath(offirmware);
382 405
383 blinstaller->install(logger);
384 406
385 // connect(blinstaller, SIGNAL(done(bool)), this, SLOT(done(bool))); 407 blinstaller->install(logger);
408
386} 409}
387 410
388 411
@@ -507,6 +530,14 @@ void RbUtilQt::uninstallBootloader(void)
507 blinstaller.setBootloaderMethod(devices->value(plattform + "/bootloadermethod").toString()); 530 blinstaller.setBootloaderMethod(devices->value(plattform + "/bootloadermethod").toString());
508 blinstaller.setBootloaderName(devices->value(plattform + "/bootloadername").toString()); 531 blinstaller.setBootloaderName(devices->value(plattform + "/bootloadername").toString());
509 blinstaller.setBootloaderBaseUrl(devices->value("bootloader_url").toString()); 532 blinstaller.setBootloaderBaseUrl(devices->value("bootloader_url").toString());
533 blinstaller.setBootloaderInfoUrl(devices->value("bootloader_info_url").toString());
534 if(!blinstaller.downloadInfo())
535 {
536 logger->addItem(tr("Could not get the bootloader info file!"),LOGERROR);
537 logger->abort();
538 return;
539 }
540
510 blinstaller.uninstall(logger); 541 blinstaller.uninstall(logger);
511 542
512} 543}