Ignore:
Timestamp:
Apr 24, 2013 1:05:17 PM (12 months ago)
Author:
Kris Moore <kris@…>
Branches:
master, 9.1-release, 9.2-release, releng/10.0, releng/10.0.1
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)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.