[PC-BSD Commits] r1459 - pcbsd/trunk/SystemUpdater

svn at pcbsd.org svn at pcbsd.org
Tue Feb 26 18:03:16 PST 2008


Author: kris
Date: 2008-02-26 18:03:16 -0800 (Tue, 26 Feb 2008)
New Revision: 1459

Modified:
   pcbsd/trunk/SystemUpdater/UpdaterTray.cpp
Log:

Enhancement to SystemUpdater tool, now we make sure to check a PBIs MD5 
before removing / adding a new version. This should help prevent problems
where a file is corrupted during download, and the software tries to install
it anyway. 



Modified: pcbsd/trunk/SystemUpdater/UpdaterTray.cpp
===================================================================
--- pcbsd/trunk/SystemUpdater/UpdaterTray.cpp	2008-02-27 01:38:18 UTC (rev 1458)
+++ pcbsd/trunk/SystemUpdater/UpdaterTray.cpp	2008-02-27 02:03:16 UTC (rev 1459)
@@ -102,6 +102,7 @@
 QString PBIProgURL1[900];
 QString PBIProgURL2[900];
 QString PBIProgURL3[900];
+QString PBIProgMD5[900];
 int     PBIProgUpdate[900];
 int     PBIProgFailed[900];
 
@@ -1746,6 +1747,10 @@
         {
             PBIProgURL3[currentWorkingPBI] = line.replace("FileURL3: ", "");
         }
+        if ( line.find("MD5:") == 0)
+        {
+            PBIProgMD5[currentWorkingPBI] = line.replace("MD5: ", "");
+        }
 
     }
 
@@ -2059,9 +2064,17 @@
    if ( firstInstall == 0)
    {
 
-       // Update the status on the previous download to finished
-       status = tr("Upgrade complete!");
-       UpdaterStatusDialog->updateStatusListBoxItem(status, id.setNum(currentWorkingPBI) );
+       if ( upgradePBIProc->exitStatus() != 0)
+       {
+         QMessageBox::critical( 0, tr("Online Update"), tr("The updated version of " + PBIProgName[currentWorkingPBI] + " " + tr("failed the integrity check! Please try updating this PBI again later.") ) );
+         // Update the status on the previous download to finished
+         status = tr("Failed!");
+         UpdaterStatusDialog->updateStatusListBoxItem(status, id.setNum(currentWorkingPBI) );
+       } else {
+         // Update the status on the previous download to finished
+         status = tr("Upgrade complete!");
+         UpdaterStatusDialog->updateStatusListBoxItem(status, id.setNum(currentWorkingPBI) );
+       }
 
         for ( QStringList::Iterator it = workingPBIUpdates.begin(); it != workingPBIUpdates.end(); ++it ) {
 
@@ -2139,6 +2152,14 @@
         QTextStream stream4( &file4 );
         stream4 << "#!/bin/sh\n";
         stream4 << "DISPLAY="" ; export DISPLAY\n";
+        stream4 << "\n";
+        stream4 << "MD5=\"`cat /PCBSD/tmp/" + tmp.setNum(currentWorkingPBI) + ".pbi | md5`\"\n";
+        stream4 << "if [ \"${MD5}\" != \"" + PBIProgMD5[currentWorkingPBI] + "\" ]\n";
+        stream4 << "then\n";
+        stream4 << "  rm /PCBSD/tmp/" + tmp.setNum(currentWorkingPBI) + ".pbi\n";
+        stream4 << "  exit 255\n";
+        stream4 << "fi\n";
+        stream4 << "\n";
         stream4 << "if [ -h '/Programs/" + ProgDirName + "' ]\n" ;
         stream4 << "then\n";
         stream4 << "PBIDIR=\"`ls -al /Programs/" + ProgDirName + " | cut -d '>' -f 2-6 | cut -d ' ' -f 2 | sed 's," + ProgDirName + ",,'`\"\n";



More information about the Commits mailing list