Changeset 32cf5ff


Ignore:
Timestamp:
05/01/14 08:28:45 (6 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, releng/10.0.2, releng/10.0.3
Children:
2f562fd
Parents:
9884f67
Message:

Merge all the PKG conflict detection stuff into the libPCBSD DLProcess output parsing. This will now automatically work for any utility that runs pkg/pbi command through a DLProcess.

Location:
src-qt4/libpcbsd/utils
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src-qt4/libpcbsd/utils/pcbsd-DLProcess.cpp

    r01d574a r32cf5ff  
    99  //Flag as no output parsing at the moment 
    1010  DLTYPE = -1; 
     11  parentW = 0; //no parent widget for now 
    1112  pipeFile.clear(); 
    1213} 
     
    1617} 
    1718 
     19void DLProcess::setParentWidget(QWidget *par){ 
     20  parentW = par;         
     21} 
     22 
    1823void DLProcess::setWardenDir(QString wardendir){ 
     24  wDir = wardendir; 
    1925  pipeFile = wardendir+"/tmp/pkg-fifo"; 
    2026  if(QFile::exists(pipeFile)){ 
     
    173179        calculateStats(dl, tot, "", file); 
    174180     } 
     181     else if ( line.indexOf("PKGCONFLICTS: ") == 0 ) { 
     182        QString tmp = line;  
     183        tmp.replace("PKGCONFLICTS: ", ""); 
     184        ConflictList = tmp; 
     185     } 
     186     else if ( line.indexOf("PKGREPLY: ") == 0 ) { 
     187        QString ans; 
     188        QString tmp = line;  
     189        tmp.replace("PKGREPLY: ", ""); 
     190        QMessageBox msgBox(parentW); 
     191        msgBox.setText(tr("The following packages are causing conflicts with the selected changes and can be automatically removed. Continue?") + "\n" + ConflictList); 
     192        msgBox.setStandardButtons(QMessageBox::Yes|QMessageBox::No); 
     193        msgBox.setDetailedText(getConflictDetailText()); 
     194        msgBox.setDefaultButton(QMessageBox::No); 
     195        if ( msgBox.exec() == QMessageBox::Yes) { 
     196          // We will try to fix conflicts 
     197          ans="yes"; 
     198        } else { 
     199          // We will fail :( 
     200          QMessageBox::warning(parentW, tr("Package Conflicts"), 
     201          tr("You may need to manually fix the conflicts before trying again."), 
     202          QMessageBox::Ok, 
     203          QMessageBox::Ok); 
     204          ans="no"; 
     205        } 
     206 
     207        QFile pkgTrig( tmp ); 
     208        if ( pkgTrig.open( QIODevice::WriteOnly ) ) { 
     209           QTextStream streamTrig( &pkgTrig ); 
     210           streamTrig << ans; 
     211           pkgTrig.close(); 
     212           ConflictList.clear(); //already sent an answer - clear the internal list 
     213        } 
     214     } 
    175215} 
    176216 
     
    187227   //qDebug() << "Size calculation:" << sizeK << output; 
    188228   return output; 
     229} 
     230 
     231QString DLProcess::getConflictDetailText() { 
     232 
     233  QStringList ConList = ConflictList.split(" "); 
     234  QStringList tmpDeps; 
     235  QString retText; 
     236 
     237  for (int i = 0; i < ConList.size(); ++i) { 
     238    QProcess p; 
     239    tmpDeps.clear(); 
     240 
     241    if ( wDir.isEmpty() ) 
     242      p.start("pkg", QStringList() << "rquery" << "%rn-%rv" << ConList.at(i)); 
     243    else 
     244      p.start("chroot", QStringList() << wDir << "pkg" "rquery" << "%rn-%rv" << ConList.at(i) ); 
     245 
     246    if(p.waitForFinished()) { 
     247      while (p.canReadLine()) { 
     248        tmpDeps << p.readLine().simplified(); 
     249      } 
     250    } 
     251    retText+= ConList.at(i) + " " + tr("required by:") + "\n" + tmpDeps.join(" "); 
     252  } 
     253 
     254  return retText; 
    189255} 
    190256 
  • src-qt4/libpcbsd/utils/pcbsd-DLProcess.h

    r01d574a r32cf5ff  
    99#include <QFile> 
    1010#include <QFileInfo> 
     11#include <QMessageBox> 
    1112 
    1213class DLProcess : public QProcess{ 
     
    1617        ~DLProcess(); 
    1718 
     19        void setParentWidget(QWidget *par); 
    1820        void setWardenDir(QString wardendir); //If the PKG type is running in a jail (before setting type) 
    1921        void setDLType(QString type); // [PBI, PKG, CDN] - (***ONLY RUN ONCE PER INSTANCE***) 
     
    2426        QProcess *watcher; 
    2527        QString pipeFile; 
     28        QString ConflictList, wDir; 
     29        QWidget *parentW; //parent widget 
    2630 
    2731        void calculateStats(QString current, QString total, QString speed, QString filename); 
     
    3034 
    3135        QString kbToString(double); 
     36        QString getConflictDetailText(); 
    3237 
    3338private slots: 
Note: See TracChangeset for help on using the changeset viewer.