Changeset 26c7c82


Ignore:
Timestamp:
03/12/14 01:23:07 (9 months ago)
Author:
Kris Moore <kris@…>
Branches:
master, releng/10.0.2, releng/10.0.3, releng/10.1
Children:
537479b1, 37d4a8c
Parents:
950d9cf
Message:

Add new "Package cleanup" functionality to package manager. This
will run 'pkg autoremove' and do cleanup of packages no longer
needed.

This needs some testing still.

Location:
src-qt4/pc-pkgmanager
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src-qt4/pc-pkgmanager/dialogConfirm.cpp

    r7541802 r26c7c82  
    2828void dialogConfirm::slotCancel() 
    2929{ 
     30  emit cancel(); 
    3031  close(); 
    3132} 
  • src-qt4/pc-pkgmanager/dialogConfirm.h

    r7541802 r26c7c82  
    3333signals: 
    3434    void ok(); 
     35    void cancel(); 
    3536 
    3637} ; 
  • src-qt4/pc-pkgmanager/mainWin.cpp

    rd18dfae r26c7c82  
    3939  connect(action_Quit, SIGNAL( triggered(bool) ), this, SLOT( slotCloseClicked() ) ); 
    4040  connect(action_Configuration, SIGNAL( triggered(bool) ), this, SLOT( slotConfigClicked() ) ); 
     41  connect(action_Cleanup_Packages, SIGNAL( triggered(bool) ), this, SLOT( slotPackageCleanupClicked() ) ); 
    4142  connect(tool_search, SIGNAL( clicked() ), this, SLOT( slotSearchPackages() ) ); 
    4243  connect(line_search, SIGNAL( returnPressed()), this, SLOT( slotSearchPackages()) ); 
     
    8081  palette.setColor(QPalette::Text, Qt::white); 
    8182  textDisplayOut->setPalette(palette); 
     83} 
     84 
     85void mainWin::slotPackageCleanupClicked() 
     86{ 
     87  if(QMessageBox::Yes == QMessageBox::question(this,tr("Package Cleanup"),tr("Do you want to start package cleanup?"),QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) ){ 
     88    doPackageCleanup(); 
     89  } 
     90} 
     91 
     92void mainWin::doPackageCleanup() 
     93{ 
     94  dPackages = false; 
     95  uPackages = false; 
     96 
     97  // Set the type of pkg command 
     98  pkgProcessType="cleanupinit"; 
     99  pkgCleanupList.clear(); 
     100 
     101  // Init the pkg process 
     102  prepPkgProcess(); 
     103 
     104  // Create our runlist of package commands 
     105  QStringList pCmds; 
     106 
     107  if ( wDir.isEmpty() ) 
     108    pCmds << "pkg-static" << "autoremove" << "-n"; 
     109  else 
     110    pCmds << "chroot" << wDir << "pkg-static" << "autoremove" << "-n"; 
     111 
     112  // Setup our runList 
     113  pkgCmdList << pCmds; 
     114 
     115  // Start the updating now 
     116  startPkgProcess(); 
     117 
     118  textStatus->setText(tr("Starting package cleanup...")); 
     119 
    82120} 
    83121 
     
    392430 
    393431  // Connect the slots 
    394   connect( uProc, SIGNAL(readyReadStandardOutput()), this, SLOT(slotReadPkgOutput()) ); 
    395   connect( uProc, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(slotPkgDone()) ); 
     432  if ( pkgProcessType == "cleanupinit" ) { 
     433    connect( uProc, SIGNAL(readyReadStandardOutput()), this, SLOT(slotReadPkgCleanupOutput()) ); 
     434    connect( uProc, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(slotPkgCleanupDone()) ); 
     435  } else if ( pkgProcessType == "cleanup" ) { 
     436    connect( uProc, SIGNAL(readyReadStandardOutput()), this, SLOT(slotReadPkgCleanupOutput()) ); 
     437    connect( uProc, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(slotPkgDone()) ); 
     438  } else { 
     439    connect( uProc, SIGNAL(readyReadStandardOutput()), this, SLOT(slotReadPkgOutput()) ); 
     440    connect( uProc, SIGNAL(finished(int, QProcess::ExitStatus)), this, SLOT(slotPkgDone()) ); 
     441  } 
    396442 
    397443  uProc->start(cmd, flags); 
     
    401447  progressUpdate->setRange(0, 0 ); 
    402448  progressUpdate->setValue(0); 
     449 
     450} 
     451 
     452void mainWin::slotCleanupOK() 
     453{ 
     454  // Create our runlist of package commands 
     455  QStringList pCmds; 
     456 
     457  if ( wDir.isEmpty() ) 
     458     pCmds << "pkg-static" << "autoremove" << "-y"; 
     459  else 
     460     pCmds << "chroot" << wDir << "pkg-static" << "autoremove" << "-y"; 
     461 
     462  // Setup our runList 
     463  pkgCmdList << pCmds; 
     464 
     465  // Start the real cleanup now 
     466  pkgProcessType="cleanup"; 
     467 
     468  // Run the next command 
     469  slotPkgDone(); 
     470} 
     471 
     472void mainWin::slotPkgCleanupDone() 
     473{ 
     474   // Ask the user if they indeed want to remove these packages 
     475   askUserConfirm = new dialogConfirm(); 
     476   connect(askUserConfirm, SIGNAL(ok()),this, SLOT(slotCleanupOK()) ); 
     477   connect(askUserConfirm, SIGNAL(cancel()),this, SLOT(slotPkgDone()) ); 
     478   askUserConfirm->programInit(tr("Package Cleanup")); 
     479   askUserConfirm->setInfoText(tr("The following packages will be removed. Continue?") + "\n\n" + pkgCleanupList.join("\n")); 
     480   askUserConfirm->exec(); 
     481} 
     482 
     483void mainWin::slotReadPkgCleanupOutput() 
     484{ 
     485  QString line, tmp; 
     486 
     487  if ( pkgProcessType == "cleanupinit" ) 
     488  { 
     489     while (uProc->canReadLine()) { 
     490       line = uProc->readLine().simplified(); 
     491       qDebug() << line; 
     492 
     493       // Empty line? We can skip it 
     494       if ( line.isEmpty() ) 
     495          continue; 
     496 
     497       tmp = line; 
     498       tmp.truncate(50); 
     499 
     500       // Now show output on GUI 
     501       textDisplayOut->insertPlainText(line + "\n"); 
     502       textDisplayOut->moveCursor(QTextCursor::End); 
     503 
     504       if ( tmp.indexOf("Deinstallation has") != -1 ) 
     505          continue; 
     506 
     507       if ( tmp.indexOf("The deinstallation") != -1 ) 
     508          continue; 
     509 
     510       // Save a list of packages we will be pruning 
     511       pkgCleanupList << tmp.simplified(); 
     512     } 
     513  } else { 
     514     while (uProc->canReadLine()) { 
     515       line = uProc->readLine().simplified(); 
     516       qDebug() << line; 
     517 
     518       // Empty line? We can skip it 
     519       if ( line.isEmpty() ) 
     520          continue; 
     521 
     522       tmp = line; 
     523       tmp.truncate(50); 
     524 
     525       // Now show output on GUI 
     526       textDisplayOut->insertPlainText(line + "\n"); 
     527       textDisplayOut->moveCursor(QTextCursor::End); 
     528 
     529     } 
     530  } 
    403531 
    404532} 
  • src-qt4/pc-pkgmanager/mainWin.h

    r77024b5 r26c7c82  
    8585    void slotConfigFinished(); 
    8686 
     87    // User wants to do package cleanup 
     88    void slotPackageCleanupClicked(); 
     89    void slotReadPkgCleanupOutput(); 
     90    void slotPkgCleanupDone(); 
     91    void slotCleanupOK(); 
     92 
    8793private: 
    8894    // Generic pkg process handlers 
     
    112118    QSocketNotifier *eSock; 
    113119 
     120    // Start the package cleanup process 
     121    void doPackageCleanup(); 
     122    QStringList pkgCleanupList; 
    114123 
    115124    // Meta-Packages 
  • src-qt4/pc-pkgmanager/mainWin.ui

    ra34ee98 r26c7c82  
    88    <y>0</y> 
    99    <width>913</width> 
    10     <height>644</height> 
     10    <height>649</height> 
    1111   </rect> 
    1212  </property> 
     
    435435     <y>0</y> 
    436436     <width>913</width> 
    437      <height>21</height> 
     437     <height>25</height> 
    438438    </rect> 
    439439   </property> 
     
    442442     <string>&amp;File</string> 
    443443    </property> 
     444    <addaction name="action_Cleanup_Packages"/> 
     445    <addaction name="separator"/> 
    444446    <addaction name="action_Quit"/> 
    445447   </widget> 
     
    510512   </property> 
    511513  </action> 
     514  <action name="action_Cleanup_Packages"> 
     515   <property name="text"> 
     516    <string>&amp;Cleanup Packages</string> 
     517   </property> 
     518  </action> 
    512519 </widget> 
    513520 <resources> 
Note: See TracChangeset for help on using the changeset viewer.