Ignore:
Timestamp:
04/29/13 06:11:03 (18 months ago)
Author:
Kris Moore <kris@…>
Branches:
master, 9.1-release, 9.2-release, releng/10.0, releng/10.0.1, releng/10.0.2, releng/10.0.3
Children:
ce5bcd0
Parents:
83fd730
Message:

Update the pc-updatemanager, remove the pkgng stuff, since its all
in pc-pkgmanager now

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src-qt4/pc-updategui/mainWin.cpp

    r1620346 r67e6e29  
    3737  connect(buttonRescan, SIGNAL(clicked()), this, SLOT(slotRescanUpdates())); 
    3838  connect(pushInstallUpdates, SIGNAL(clicked()), this, SLOT(slotInstallClicked())); 
    39   connect(pushUpdatePkgs, SIGNAL(clicked()), this, SLOT(slotUpdatePkgsClicked())); 
    4039  connect(pushClose, SIGNAL(clicked()), this, SLOT(slotCloseClicked())); 
    41   connect(buttonRescanPkgs, SIGNAL(clicked()), this, SLOT(slotRescanPkgsClicked())); 
    4240  connect(checkAll, SIGNAL(clicked()), this, SLOT(slotSelectAllClicked())); 
    4341  connect(listViewUpdates, SIGNAL(itemClicked(QListWidgetItem *)),this,SLOT(slotListClicked())); 
     
    4947 
    5048  QTimer::singleShot(100, this, SLOT(slotRescanUpdates() ) ); 
    51   QTimer::singleShot(200, this, SLOT(slotRescanPkgsClicked() ) ); 
    5249} 
    5350 
     
    116113  // Set our UI elements 
    117114  progressUpdate->setHidden(false); 
    118   tabUpdates->setEnabled(false); 
    119115 
    120116  curUpdate = -1; 
     
    162158    if ( listViewUpdates->item(z)->checkState() == Qt::Checked && curUpdate < z )  
    163159    { 
    164       dPackages = false; 
    165       uPackages = false; 
    166160      curUpdate = z; 
    167161      curUpdateIndex++; 
     
    342336{ 
    343337  if ( ! doingUpdate ) 
    344     tabUpdates->setEnabled(true); 
     338    groupUpdates->setEnabled(true); 
    345339  listViewUpdates->clear(); 
    346340 
     
    354348  // Any system updates? 
    355349  if ( listUpdates.isEmpty() ) { 
    356     if ( ! pushUpdatePkgs->isEnabled() ) { 
    357       textLabel->setText(tr("Your system is fully updated!")); 
    358       tabUpdates->setTabText(0, tr("System Updates")); 
    359     } else { 
    360       textLabel->setText(tr("Package updates available!")); 
    361     } 
     350    textLabel->setText(tr("Your system is fully updated!")); 
    362351    groupUpdates->setTitle(""); 
     352    groupUpdates->setEnabled(true); 
    363353    return; 
    364354  } 
     
    366356  textLabel->setText(tr("System updates available!")); 
    367357  groupUpdates->setTitle(tr("Available Updates")); 
    368   tabUpdates->setCurrentIndex(0); 
    369   tabUpdates->setTabText(0, tr("System Updates (%1)").arg(listUpdates.count())); 
    370358 
    371359  // Start parsing the updates and list whats available 
     
    417405} 
    418406 
    419 void mainWin::slotRescanPkgsClicked() 
    420 { 
    421   // Check for pkg updates 
    422   checkMPKGUpdates(); 
    423 } 
    424  
    425407void mainWin::slotReadUpdateData() 
    426408{ 
     
    437419 
    438420  QString line, tmp, name, type, version, date, tag, url, size, sa, rr; 
    439   QStringList up, listPkgs; 
     421  QStringList up; 
    440422 
    441423  QProcess p; 
     
    521503 
    522504} 
    523  
    524 void mainWin::checkMPKGUpdates() { 
    525   if ( doingUpdate ) 
    526      return; 
    527  
    528   QString line, tmp, name, pkgname, pkgover, pkgnver; 
    529   QStringList up, listPkgs; 
    530   bool haveUpdates = false; 
    531   int totPkgs=0; 
    532   buttonRescanPkgs->setEnabled(false); 
    533   pushUpdatePkgs->setEnabled(false); 
    534   listViewUpdatesPkgs->clear(); 
    535   groupUpdatesPkgs->setTitle(tr("Checking for updates")); 
    536  
    537   QProcess p; 
    538   if ( wDir.isEmpty() ) 
    539      p.start(QString("pc-updatemanager"), QStringList() << "pkgcheck"); 
    540   else 
    541      p.start(QString("chroot"), QStringList() << wDir << "pc-updatemanager" << "pkgcheck"); 
    542   while(p.state() == QProcess::Starting || p.state() == QProcess::Running) 
    543      QCoreApplication::processEvents(); 
    544  
    545   while (p.canReadLine()) { 
    546     line = p.readLine().simplified(); 
    547     qDebug() << line; 
    548     if ( line.indexOf("Upgrading") != 0) { 
    549        continue; 
    550     } 
    551     tmp = line; 
    552     pkgname = tmp.section(" ", 1, 1); 
    553     pkgname.replace(":", ""); 
    554     pkgover = tmp.section(" ", 2, 2); 
    555     pkgnver = tmp.section(" ", 4, 4); 
    556     QTreeWidgetItem *myItem = new QTreeWidgetItem(QStringList() << pkgname << pkgover << pkgnver); 
    557     listViewUpdatesPkgs->addTopLevelItem(myItem); 
    558     haveUpdates = true; 
    559     totPkgs++; 
    560   } 
    561  
    562   buttonRescanPkgs->setEnabled(true); 
    563   pushUpdatePkgs->setEnabled(haveUpdates); 
    564   if ( totPkgs > 0 ) { 
    565     if ( listUpdates.isEmpty() ) 
    566       tabUpdates->setCurrentIndex(1); 
    567     tabUpdates->setTabText(1, tr("Package Updates (%1)").arg(totPkgs)); 
    568     groupUpdatesPkgs->setTitle(tr("Available updates")); 
    569   } else { 
    570     tabUpdates->setTabText(1, tr("Package Updates")); 
    571     groupUpdatesPkgs->setTitle(tr("No available updates")); 
    572   } 
    573   
    574   slotDisplayUpdates(); 
    575 } 
    576  
    577505 
    578506void mainWin::checkFBSDUpdates() { 
     
    599527    if ( line.indexOf("The following files will be updated ") == 0) { 
    600528       fUp = true; 
    601        listPkgs.clear(); 
    602529       continue; 
    603530    } 
     
    631558} 
    632559 
    633 void mainWin::slotUpdatePkgsClicked() { 
    634   // Set our UI elements 
    635   progressUpdate->setHidden(false); 
    636   tabUpdates->setEnabled(false); 
    637  
    638   dPackages = false; 
    639   uPackages = false; 
    640   doingUpdate=true; 
    641   curUpdate = 0; 
    642  
    643   // Setup the upgrade process 
    644   uProc = new QProcess(); 
    645   QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); 
    646   env.insert("PCFETCHGUI", "YES"); 
    647   uProc->setProcessEnvironment(env); 
    648   uProc->setProcessChannelMode(QProcess::MergedChannels); 
    649  
    650   // Connect the slots 
    651   connect( uProc, SIGNAL(readyReadStandardOutput()), this, SLOT(slotReadPkgUpdateOutput()) ); 
    652   connect( uProc, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(slotUpdatePkgDone()) ); 
    653  
    654   if ( wDir.isEmpty() ) 
    655     uProc->start("pc-updatemanager", QStringList() << "pkgupdate"); 
    656   else 
    657     uProc->start("chroot", QStringList() << wDir << "pc-updatemanager" << "pkgupdate"); 
    658  
    659   textLabel->setText(tr("Starting package updates...")); 
    660  
    661   progressUpdate->setRange(0, listViewUpdatesPkgs->topLevelItemCount() ); 
    662   progressUpdate->setValue(0); 
    663 } 
    664  
    665 void mainWin::slotReadPkgUpdateOutput() { 
    666    QString line, tmp, cur, tot, fname; 
    667  
    668    while (uProc->canReadLine()) { 
    669      line = uProc->readLine().simplified(); 
    670      qDebug() << "Normal Line:" << line; 
    671      tmp = line; 
    672      tmp.truncate(50); 
    673      if ( line.indexOf("to be downloaded") != -1 ) { 
    674        textLabel->setText(tr("Downloading packages...")); 
    675        curUpdate = 0; 
    676        progressUpdate->setValue(0); 
    677        continue; 
    678      } 
    679      if ( line.indexOf("Checking integrity") == 0 ) { 
    680        textLabel->setText(line); 
    681        uPackages = true; 
    682        dPackages = false; 
    683        curUpdate = 0; 
    684        progressUpdate->setValue(0); 
    685      } 
    686      if ( line.indexOf("FETCH: ") == 0 ) {  
    687         progressUpdate->setValue(progressUpdate->value() + 1);  
    688         tmp = line;  
    689         tmp = tmp.remove(0, tmp.lastIndexOf("/") + 1);  
    690         textLabel->setText(tr("Downloading: %1").arg(tmp));  
    691         continue; 
    692      }  
    693       
    694      if ( line.indexOf("SIZE: ") == 0 ) { 
    695           bool ok, ok2; 
    696           line.replace("SIZE: ", ""); 
    697           line.replace("DOWNLOADED: ", ""); 
    698           line.replace("SPEED: ", ""); 
    699           line.section(" ", 0, 0).toInt(&ok); 
    700           line.section(" ", 1, 1).toInt(&ok2); 
    701     
    702           if ( ok && ok2 ) { 
    703             QString unit; 
    704             int tot = line.section(" ", 0, 0).toInt(&ok); 
    705             int cur = line.section(" ", 1, 1).toInt(&ok2); 
    706             QString percent = QString::number( (float)(cur * 100)/tot ); 
    707             QString speed = line.section(" ", 2, 3); 
    708  
    709             // Get the MB downloaded / total 
    710             if ( tot > 2048 ) { 
    711               unit="MB"; 
    712               tot = tot / 1024; 
    713               cur = cur / 1024; 
    714             } else { 
    715               unit="KB"; 
    716             } 
    717  
    718             QString ProgressString=QString("%1" + unit + " of %2" + unit + " at %3").arg(cur).arg(tot).arg(speed); 
    719             progressUpdate->setRange(0, tot); 
    720             progressUpdate->setValue(cur); 
    721          } 
    722      } 
    723  
    724      if ( uPackages ) { 
    725        if ( line.indexOf("Upgrading") == 0 ) { 
    726          textLabel->setText(line); 
    727          curUpdate++; 
    728          progressUpdate->setValue(curUpdate); 
    729        } 
    730        continue; 
    731      } 
    732  
    733    } // end of while 
    734 } 
    735  
    736 // Function to read output of pipefile 
    737 void mainWin::slotReadEventPipe(int fd) { 
    738   QString tmp, fname, cur, tot; 
    739   bool ok, ok2; 
    740   char buff[4028]; 
    741   int totread = read(fd, buff, 4020); 
    742   buff[totread]='\0'; 
    743   QString line = buff; 
    744   line = line.simplified(); 
    745   //qDebug() << "Found line:" << line; 
    746    
    747   if ( line.indexOf("INFO_FETCH") != -1  && dPackages ) { 
    748      tmp = line; 
    749      fname = tmp.section(":", 4, 4); 
    750      fname.remove(0, fname.lastIndexOf('/') + 1); 
    751      fname  = fname.section('"', 0, 0); 
    752      cur = tmp.section(":", 5, 5); 
    753      cur = cur.remove(','); 
    754      cur = cur.section(" ", 1, 1); 
    755      cur = cur.simplified(); 
    756      tot = tmp.section(":", 6, 6); 
    757      tot = tot.simplified(); 
    758      tot = tot.remove(','); 
    759      tot = tot.section("}", 0, 0); 
    760  
    761      textLabel->setText(tr("Downloading %1").arg(fname)); 
    762      tot.toInt(&ok); 
    763      cur.toInt(&ok2); 
    764      if ( ok && ok2 ) 
    765      {  
    766        progressUpdate->setRange(0, tot.toInt(&ok2)); 
    767        progressUpdate->setValue(cur.toInt(&ok2)); 
    768      } 
    769       
    770      //qDebug() << "File:" << fname << "cur" << cur << "tot" << tot; 
    771   } 
    772 } 
    773  
    774 void mainWin::slotUpdatePkgDone() { 
    775   progressUpdate->setHidden(true); 
    776   QFile sysTrig( SYSTRIGGER ); 
    777   if ( sysTrig.open( QIODevice::WriteOnly ) ) { 
    778     QTextStream streamTrig( &sysTrig ); 
    779      streamTrig << "INSTALLFINISHED: "; 
    780   } 
    781  
    782   if ( uProc->exitCode() != 0 ) 
    783     QMessageBox::warning(this, tr("Failed package update"), tr("The package update failed! If this persists, you may need to manually run: pc-updatemanager pkgupdate")); 
    784  
    785   doingUpdate=false; 
    786   checkMPKGUpdates(); 
    787 } 
Note: See TracChangeset for help on using the changeset viewer.