Changeset 8a15428


Ignore:
Timestamp:
01/13/14 10:21:15 (8 months ago)
Author:
Kris Moore <kris@…>
Branches:
9.2-release
Children:
d1a3d12
Parents:
9ada87b
Message:

Backport the fixes to 9.2 for major updating PBIs and keeping the user
whom installed them.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src-sh/pc-updatemanager/pc-updatemanager

    r115b081 r8a15428  
    442442  clear 
    443443  echo "Removing PBIs..." 
    444   while read pbi 
    445   do 
     444  while read line 
     445  do 
     446    pbi=`echo $line | cut -d ' ' -f 1` 
    446447    echo "Removing: ${pbi}" 
    447448    pbi_delete $pbi >/dev/null 2>/dev/null 
     
    577578  clear 
    578579  echo "Re-Installing PBIs" 
    579   while read newpbi 
    580   do 
     580  while read line 
     581  do 
     582    newpbi=`echo $line | cut -d ' ' -f 1` 
     583    user=`echo $line | cut -d ' ' -f 2` 
    581584    shortpbi="`echo $newpbi | rev | cut -d '-' -f 3- | rev`" 
    582     pbi_add -r $shortpbi 
    583     if [ $? -ne 0 ] ; then 
     585 
     586    # Re-install the PBI as user or root depending on how it was installed 
     587    if [ "$user" != "root" ] ; then 
     588      su $user -c "pbi_add -r $shortpbi" 
     589      result=$? 
     590    else 
     591      pbi_add -r $shortpbi 
     592      result=$? 
     593    fi 
     594    if [ $result -ne 0 ] ; then 
    584595       PBISTATUS=1 
    585596       echo "$shortpbi" >> /root/.failed-pbi 
     
    643654 
    644655  if [ $PBISTATUS -eq 0 ] ; then 
    645     echo "PBI: All meta-packages updated successfully!" >> /root/pcbsd-update-summary 
     656    echo "PBI: All PBIs updated successfully!" >> /root/pcbsd-update-summary 
    646657  else 
    647     echo "PBI: The following meta-packages failed to install:" >> /root/pcbsd-update-summary 
     658    echo "PBI: The following PBIs failed to install:" >> /root/pcbsd-update-summary 
    648659    cat /root/.failed-pbi >> /root/pcbsd-update-summary 
    649660  fi 
     
    730741  # Now lets build some lists of what is present on this system now 
    731742  pkg info > /root/pcbsd-pkg-before-update 
    732   pbi_info > /root/pcbsd-pbi-before-update 
     743  pbi_info > /root/pcbsd-pbi-before-update.tmp 
    733744  pc-metapkgmanager list-installed > /root/pcbsd-meta-before-update 
     745 
     746  # Figure out which user had installed which PBIs and save this list 
     747  while read line 
     748  do 
     749     insBy=`pbi_info -v $line | grep "InstalledBy:" | cut -d ' ' -f 2` 
     750     if [ -z "$insBy" ] ; then 
     751        echo "Unable to get UserName for installed PBI: $line" 
     752        continue 
     753     fi 
     754     echo "$line $insBy" >> /root/pcbsd-pbi-before-update 
     755  done < /root/pcbsd-pbi-before-update.tmp 
     756  touch /root/pcbsd-pbi-before-update 
     757  rm /root/pcbsd-pbi-before-update.tmp 
    734758 
    735759  # Figure out a list of user-installed packages to try and re-install on the updated system 
Note: See TracChangeset for help on using the changeset viewer.