Changeset 04308e6


Ignore:
Timestamp:
01/08/14 16:21:19 (7 months ago)
Author:
Kris Moore <kris@…>
Branches:
master, releng/10.0, releng/10.0.1, releng/10.0.2
Children:
f353da8
Parents:
544e6570
Message:

Finish up the pc-updatemanager, now it'll parse out which additional
packages have been installed via PKGNG, save this list, and then re-install
those packages during the major upgrade / branch change.

File:
1 edited

Legend:

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

    r6052403 r04308e6  
    409409{ 
    410410  cp /tmp/pcbsd.conf.preUpdate.$$ /usr/local/etc/pkg/repos/pcbsd.conf 
    411   if [ "$PKGROLLBACK" = "YES" ] ; then 
    412  
    413   fi 
    414411} 
    415412 
     
    422419  # Set some status variables 
    423420  PKGSTATUS=0 
     421  USERPKGSTATUS=0 
    424422  PBISTATUS=0 
    425423  FREEBSDSTATUS=0 
     
    559557  done < /root/pcbsd-meta-before-update 
    560558 
     559  # Now lets try re-installing any user-installed packages 
     560  clear 
     561  echo "Re-Installing user-installed packages" 
     562  while read userpkg 
     563  do 
     564    # Make sure package isn't already installed 
     565    pkg-static info -e ${userpkg} 
     566    if [ $? -eq 0 ] ; then continue ; fi 
     567 
     568    # Nope, lets try to load it now 
     569    pkg-static install -y ${userpkg} 
     570    if [ $? -ne 0 ] ; then 
     571       USERPKGSTATUS=1 
     572       echo "${userpkg}" >> /root/.failed-user-pkgs 
     573    fi 
     574  done < /root/pcbsd-userpkgs-before-update 
     575 
     576  # Now lets re-load any PBI files 
    561577  clear 
    562578  echo "Re-Installing PBIs" 
     
    574590  done < /root/pcbsd-pbi-before-update 
    575591 
    576  
    577592  # Last but not least, lets make sure to re-stamp GRUB in case any loader.conf.pcbsd modules changed 
    578593  grub-mkconfig -o /boot/grub/grub.cfg | tee /root/.failed-grub 
     
    609624  echo "" >> /root/pcbsd-update-summary 
    610625 
     626  if [ $USERPKGSTATUS -eq 0 ] ; then 
     627    echo "USERPKG: All packages updated successfully!" >> /root/pcbsd-update-summary 
     628  else 
     629    echo "USERPKG: The following user-packages failed to install:" >> /root/pcbsd-update-summary 
     630    cat /root/.failed-user-pkgs >> /root/pcbsd-update-summary 
     631  fi 
     632 
     633  echo "" >> /root/pcbsd-update-summary 
     634 
    611635  if [ $METASTATUS -eq 0 ] ; then 
    612636    echo "META: All meta-packages updated successfully!" >> /root/pcbsd-update-summary 
     
    634658  fi 
    635659 
     660  echo "" >> /root/pcbsd-update-summary 
    636661  echo "Old system information: " >> /root/pcbsd-update-summary 
    637662  echo "/root/pcbsd-pkg-before-update" >> /root/pcbsd-update-summary 
     
    645670  # Clear any old summary files 
    646671  rm /root/.failed-pkgs 2>/dev/null 
     672  rm /root/.failed-user-pkgs 2>/dev/null 
    647673  rm /root/.failed-meta 2>/dev/null 
    648674  rm /root/.failed-pbi 2>/dev/null 
     
    658684} 
    659685 
     686# Simple recursive loop to go through and get a list of all package deps for a top level package 
     687get_dep_origins() 
     688{ 
     689  grep -q "^$1\$" "${2}.checked" 2>/dev/null 
     690  if [ $? -eq 0 ] ; then return; fi 
     691  echo "$1" >> ${2}.checked 
     692 
     693  local i 
     694  for i in `pkg query '%do' ${1}` 
     695  do 
     696     echo "$i" >> ${2} 
     697     get_dep_origins "$i" "$2" 
     698  done 
     699} 
     700 
    660701start_major_fbsd_update() { 
    661702  local rel=`echo $1 | sed 's|fbsd-||g'` 
    662   PKGROLLBACK="NO" 
    663703 
    664704  # Save the repo file 
     
    693733  pc-metapkgmanager list-installed > /root/pcbsd-meta-before-update 
    694734 
    695   # Lets install pkgng update 
    696   PKGROLLBACK="YES" 
     735  # Figure out a list of user-installed packages to try and re-install on the updated system 
     736  echo "Building a list of user-installed packages... Please wait..." 
     737  local mPkgFile="/tmp/.mPkgDList.$$" 
     738  local mOriginFile="/tmp/.mPkgOList.$$" 
     739  rm $mPkgFile 2>/dev/null 
     740  echo "ports-mgmt/pkg" >> ${mPkgFile} 
     741  if [ -e "/usr/local/bin/pc-softwaremanager" ] ; then 
     742     echo "pcbsd-base" >> ${mPkgFile} 
     743  else 
     744     echo "trueos-base" >> ${mPkgFile} 
     745  fi 
     746  while read mpkg 
     747  do 
     748     pc-metapkgmanager pkgdeps $mpkg >/dev/null 2>/dev/null 
     749     if [ $? -ne 0 ] ; then continue ; fi 
     750     pc-metapkgmanager pkgdeps $mpkg >> $mPkgFile 
     751  done < /root/pcbsd-meta-before-update 
     752 
     753  # Now sort out the list of depends for our meta-pkgs 
     754  while read mpkg 
     755  do 
     756     #echo "Finding package dependencies of ${mpkg}.." 
     757     pkg query '%o' $mpkg >> ${mOriginFile} 
     758     get_dep_origins "$mpkg" "$mOriginFile" 
     759  done < ${mPkgFile} 
     760  rm ${mPkgFile} 
     761 
     762  echo "Building list of user-installed packages..." 
     763  # Sort the origins file 
     764  cat ${mOriginFile} | sort | uniq > ${mOriginFile}.new 
     765  mv ${mOriginFile}.new ${mOriginFile} 
     766 
     767  # Build a list of *all* package origins 
     768  pkg query -a '%o' | sort > ${mOriginFile}.system 
     769 
     770  # Save a list of packages that the user installed from elsewhere than our meta-packages 
     771  diff ${mOriginFile} ${mOriginFile}.system | grep '>' | awk '{print $2}' > /root/pcbsd-userpkgs-before-update 
     772  rm ${mOriginFile}.system 
     773  rm ${mOriginFile} 
    697774 
    698775  # Download update files from freebsd-update 
Note: See TracChangeset for help on using the changeset viewer.