Changeset 4c06449


Ignore:
Timestamp:
04/24/13 13:05:17 (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:
98b904e
Parents:
f01aaaf
Message:

Add all the new pkg conflict logic to libsh

Will detect if something is going to fail during pkg process and
warn the user either graphically or via CLI

In GUI add detection of the GUI hooks from conflict detection

When we find conflicts, remove them for now. (More advanced logic
may be incoming as I play with it)

Files:
3 edited

Legend:

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

    rf9fc934 r4c06449  
    197197 
    198198     // Flags we can parse out and not show the user 
     199 
     200     // Check if we have crashed into a conflict and ask the user what to do 
     201     if ( line.indexOf("PKGCONFLICTS: ") == 0 ) { 
     202        tmp = line;  
     203        tmp.replace("PKGCONFLICTS: ", ""); 
     204        ConflictList = tmp; 
     205        continue; 
     206     } 
     207     if ( line.indexOf("PKGREPLY: ") == 0 ) { 
     208        QString ans; 
     209        tmp = line;  
     210        tmp.replace("PKGREPLY: ", ""); 
     211        if ( QMessageBox::Yes == QMessageBox::warning(this, tr("Package Conflicts"), 
     212          tr("The following packages are causing conflicts with the selected changes and can be automatically removed. Continue?") + "\n" + ConflictList, 
     213          QMessageBox::Yes|QMessageBox::No, 
     214          QMessageBox::Yes) ) { 
     215 
     216          // We will try to fix conflicts 
     217          ans="yes"; 
     218            
     219        } else { 
     220          // We will fail :( 
     221          QMessageBox::warning(this, tr("Package Conflicts"), 
     222          tr("You may need to manually fix the conflicts before trying again."), 
     223          QMessageBox::Ok, 
     224          QMessageBox::Ok); 
     225          ans="no"; 
     226        } 
     227 
     228        QFile pkgTrig( tmp ); 
     229        if ( pkgTrig.open( QIODevice::WriteOnly ) ) { 
     230           QTextStream streamTrig( &pkgTrig ); 
     231           streamTrig << ans; 
     232           pkgTrig.close(); 
     233        } 
     234     } 
     235 
    199236     if ( line.indexOf("FETCH: ") == 0 ) {  
    200237        progressUpdate->setValue(progressUpdate->value() + 1);  
     
    296333 
    297334  if ( pkgHasFailed ) { 
    298     if ( QMessageBox::Save == QMessageBox::warning(this, tr("Failed pkgng command!"), tr("The package commands failed. Do you wish to save the output to a log file?"), QMessageBox::Save | QMessageBox::Discard, QMessageBox::Save) ) { 
    299        QFile file( "/tmp/pkg-output.log" ); 
    300        if ( file.open( QIODevice::WriteOnly ) ) { 
    301          QTextStream stream( &file ); 
    302          stream << textDisplayOut->toPlainText(); 
    303          file.close(); 
    304        } 
     335    QFile file( "/tmp/pkg-output.log" ); 
     336    if ( file.open( QIODevice::WriteOnly ) ) { 
     337       QTextStream stream( &file ); 
     338       stream << textDisplayOut->toPlainText(); 
     339       file.close(); 
    305340    } 
     341    QMessageBox::warning(this, tr("Failed!"), tr("The package commands failed. A copy of the output was saved to /tmp/pkg-output.log")); 
    306342  } else 
    307343    QMessageBox::warning(this, tr("Finished!"), tr("Package changes complete!" )); 
  • src-qt4/pc-pkgmanager/mainWin.h

    rf9fc934 r4c06449  
    110110    QString chrootArg1; 
    111111    QString chrootArg2; 
     112    QString ConflictList; 
    112113    bool canceled; 
    113114    QMenu *popup; 
  • src-sh/libsh/functions.sh

    re013d8d2 r4c06449  
    482482  return 0 
    483483}; 
     484 
     485check_pkg_conflicts() 
     486{ 
     487  # Lets test if we have any conflicts 
     488  pkg-static ${1} 2>/tmp/.pkgConflicts.$$ >/tmp/.pkgConflicts.$$ 
     489  if [ $? -eq 0 ] ; then rm /tmp/.pkgConflicts.$$ ; return ; fi 
     490  
     491  # Found conflicts, suprise suprise, yet another reason I hate packages 
     492  # Lets start building a list of the old packages we can prompt to remove 
     493 
     494  # Nice ugly sed line, sure this can be neater 
     495  cat /tmp/.pkgConflicts.$$ | grep 'WARNING: locally installed' \ 
     496        | sed 's|.*installed ||g' | sed 's| conflicts.*||g' | sort | uniq \ 
     497        > /tmp/.pkgConflicts.$$.2 
     498  while read line 
     499  do 
     500    cList="$line $cList" 
     501  done < /tmp/.pkgConflicts.$$.2 
     502  rm /tmp/.pkgConflicts.$$.2  
     503  rm /tmp/.pkgConflicts.$$ 
     504 
     505  if [ "$GUI_FETCH_PARSING" != "YES" -a "$PBI_FETCH_PARSING" != "YES" -a -z "$PCFETCHGUI" ] ; then 
     506        echo "The following packages will conflict with your pkg command:" 
     507        echo "-------------------------------------" 
     508        echo "$cList" | more 
     509        echo "Do you wish to remove them automatically?" 
     510        echo -e "Default yes: (y/n)\c" 
     511        read tmp 
     512        if [ "$tmp" != "y" -a "$tmp" != "Y" ] ; then return 1 ; fi 
     513  else 
     514        echo "PKGCONFLICTS: $cList" 
     515        echo "PKGREPLY: /tmp/pkgans.$$" 
     516        while :  
     517        do 
     518          if [ -e "/tmp/pkgans.$$" ] ; then 
     519            ans=`cat /tmp/pkgans.$$` 
     520            if [ "$ans" = "yes" ] ; then  
     521               break 
     522            else 
     523               return 1 
     524            fi 
     525          fi  
     526          sleep 3 
     527        done 
     528  fi 
     529 
     530  # Lets auto-resolve these bad-boys 
     531  # Right now the logic is pretty simple, you conflict, you die 
     532  for bPkg in $cList 
     533  do 
     534     # Nuked! 
     535     echo "Removing conflicting package: $bPkg" 
     536     pkg delete -q -y -f ${bPkg} 
     537  done 
     538 
     539  # Lets test if we still have any conflicts 
     540  pkg-static ${1} 2>/dev/null >/dev/null 
     541  if [ $? -eq 0 ] ; then return 0; fi 
     542 
     543  # Crapola, we still have conflicts, lets warn and bail 
     544  echo "ERROR: pkg ${1} is still reporting conflicts... Resolve these manually and try again" 
     545  return 1 
     546} 
Note: See TracChangeset for help on using the changeset viewer.