Changeset 115b081


Ignore:
Timestamp:
01/08/14 16:23:58 (12 months ago)
Author:
Kris Moore <kris@…>
Branches:
9.2-release
Children:
287fef9
Parents:
3be1aa2
Message:

Backport the fixes for updating to a new major version / branch.

This will allow us to begin rolling out updates from 9.2 -> 10.x

Location:
src-sh
Files:
2 edited

Legend:

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

    r1ba44be r115b081  
    5151    
    5252Options: 
    53   add pkg1,pkg2          -- Add the specified list of meta-packages 
    54   del pkg1,pkg2          -- Delete the specified list of meta-packages 
     53  add mpkg1,mpkg2        -- Add the specified list of meta-packages 
     54  del mpkg1,mpkg2        -- Delete the specified list of meta-packages 
    5555  list                   -- List the available meta-packages 
    56   status <pkg>           -- List the status of the specified meta-packages 
     56  list-installed         -- Only list the installed meta-packages 
     57  pkgdeps <mpkg>         -- List package dependancies for the specified meta-package 
     58  status <mpkg>          -- List the status of the specified meta-packages 
    5759  --pkgset <pkgset>      -- Change default pkgset we are using 
    5860 
     
    169171        fi 
    170172 
     173} 
     174 
     175# Function to list installed metapkgs 
     176list_installed_metapkgs() { 
     177        if [ ! -d "${MPDIR}" ] ; then exit_err "No available meta-pkg dir" ; fi 
     178 
     179        # Start listing each meta-pkg 
     180        for i in `find ${MPDIR}/* -type d` 
     181        do 
     182                # Is this package ignored on this arch? 
     183                if [ -e "${i}/ignore-arch" ] ; then 
     184                        if [ `cat ${i}/ignore-arch` = "$ARCH" ] ; then continue; fi 
     185                fi 
     186                MPNAME=`basename $i` 
     187                if [ ! -e "${MPDIR}/${MPNAME}/ports-list" ] ; then continue ; fi 
     188 
     189                stat_metapkg "$MPNAME" >/dev/null 2>/dev/null 
     190                if [ $? -eq 0 ] ; then 
     191                   if [ -z "$installed" ] ; then 
     192                     installed="$MPNAME" 
     193                   else 
     194                     installed="$installed $MPNAME" 
     195                   fi 
     196                fi 
     197        done 
     198        echo "$installed" 
     199} 
     200 
     201# List the package deps for the specified meta-pkg 
     202list_pkgdeps() { 
     203        if [ -z "$1" ] ; then exit_err "No meta-pkg specified!" ; fi 
     204        if [ ! -e "${MPDIR}/${1}/ports-list" ] ; then exit_err "No such meta-pkg: $1" ; fi 
     205        cat ${MPDIR}/$1/ports-list | cut -d ':' -f 1 
     206        exit 0 
    171207} 
    172208 
     
    368404while [ $# -gt 0 ]; do 
    369405  case "$1" in 
    370       list) list_metapkgs ; exit 0 ;; 
     406       pkgdeps) list_pkgdeps "$2" ; exit 0 ;; 
     407          list) list_metapkgs ; exit 0 ;; 
     408list-installed) list_installed_metapkgs ; exit 0 ;; 
    371409       add) parse_metapkgs "$2" "add" "$3" ; exit 0 ;; 
    372410       del) parse_metapkgs "$2" "del" ; exit 0 ;; 
  • src-sh/pc-updatemanager/pc-updatemanager

    r876ed39 r115b081  
    409409{ 
    410410  cp /tmp/pcbsd.conf.preUpdate.$$ /usr/local/etc/pkg/repos/pcbsd.conf 
    411   if [ "$PKGROLLBACK" = "YES" ] ; then 
    412  
    413   fi 
    414411} 
    415412 
     
    420417  export PATH 
    421418 
     419  # Set some status variables 
     420  PKGSTATUS=0 
     421  USERPKGSTATUS=0 
     422  PBISTATUS=0 
     423  FREEBSDSTATUS=0 
     424  GRUBSTATUS=0 
     425  METASTATUS=0 
     426 
     427  # Clear any old summary files 
     428  rm /root/.failed-pkgs 2>/dev/null 
     429  rm /root/.failed-meta 2>/dev/null 
     430  rm /root/.failed-pbi 2>/dev/null 
     431  rm /root/.failed-freebsd 2>/dev/null 
     432  rm /root/.failed-grub 2>/dev/null 
     433 
     434  # Is this a desktop or server? 
     435  if [ -e "/usr/local/bin/pc-softwaremanager" ] ; then 
     436     SYSTYPE="desktop" 
     437  else 
     438     SYSTYPE="server" 
     439  fi 
     440 
     441  # Remove all PBIs 
     442  clear 
     443  echo "Removing PBIs..." 
     444  while read pbi 
     445  do 
     446    echo "Removing: ${pbi}" 
     447    pbi_delete $pbi >/dev/null 2>/dev/null 
     448    if [ $? -ne 0 ] ; then 
     449       echo "Warning: Failed to remove: $pbi" 
     450       sleep 5 
     451    fi 
     452  done < /root/pcbsd-pbi-before-update 
     453  echo "Done!" 
     454 
     455  # Start the package cleanup process 
     456  clear 
     457  echo "Removing packages...This may take a while...\c" 
     458  pkg delete -afy 
     459  if [ $? -ne 0 ] ; then 
     460     echo "Warning: Failed to remove all packages" 
     461     sleep 5 
     462  fi 
     463  echo "Done!" 
     464 
     465  # Start the freebsd-update process 
     466  clear 
    422467  echo "Installing FreeBSD updates... Please wait..." 
    423   freebsd-update --non-interactive install 
     468  freebsd-update --non-interactive install | tee /root/.failed-freebsd 
    424469  if [ $? -ne 0 ] ; then 
    425470     echo "Warning: Failed running freebsd-update install!" 
    426471     echo "Press ENTER to continue" 
     472     FREEBSDSTATUS=1 
    427473     read tmp 
    428474  fi 
     475  clear 
    429476 
    430477  # Remove this, causes all kinds of havok during the update 
     
    433480  fi 
    434481 
    435   # Now its time to force a pkg-update of all packages to their new FreeBSD compiled versions 
    436   pc-updatemanager pkgupdate -f 
    437   if [ $? -ne 0 ] ; then 
    438      echo "Warning: Failed running 'pc-updatemanager pkgupdate -f'" 
     482  clear 
     483  echo "Starting networking..." 
     484  echo "" 
     485  # Enable networking 
     486  /etc/rc.d/devfs restart 
     487  /etc/rc.d/netif restart 
     488  /etc/rc.d/devd start 
     489  /etc/rc.d/wpa_supplicant start 
     490  /etc/rc.d/dhclient start 
     491  sleep 8 
     492  clear 
     493 
     494  # This is super-lame, we can't just remove all packages *except* pkgng, so we have to re-bootstrap 
     495  # Lets extract the new pkgng we fetched earlier 
     496  echo "Boot-Strapping PKGNG..." 
     497  if [ ! -d "/usr/local/etc/pkg/fingerprints/pcbsd/revoked" ] ; then 
     498     mkdir "/usr/local/etc/pkg/fingerprints/pcbsd/revoked" 
     499  fi 
     500  cd / 
     501  tar xvpf /usr/local/tmp/pkg.txz /usr/local/sbin/pkg-static >/dev/null 2>/dev/null 
     502  /usr/local/sbin/pkg-static install -y ports-mgmt/pkg 
     503  if [ $? -ne 0 ] ; then 
     504     echo "Warning: Failed to re-install PKGNG..." 
    439505     echo "Press ENTER to continue" 
    440506     read tmp 
    441507  fi 
    442508 
     509  # Lets update the pkgng repo 
     510  pkg-static update -f 
     511 
     512  # Now lets begin re-installing packages 
     513  if [ "$SYSTYPE" = "desktop" ] ; then 
     514    echo "Installing desktop packages..." 
     515    pkg-static install -y pcbsd-base 
     516    if [ $? -ne 0 ] ; then 
     517       PKGSTATUS=1 
     518       echo "pcbsd-base" >> /root/.failed-pkgs 
     519       echo "Warning: Failed to install pcbsd-base!" 
     520       echo "You will need to manually install this package to re-enable the PC-BSD desktop" 
     521       echo "Press ENTER to continue" 
     522       read tmp 
     523    fi 
     524    pc-extractoverlay desktop 
     525  else 
     526    echo "Installing server packages..." 
     527    pkg-static install -y trueos-base 
     528    if [ $? -ne 0 ] ; then 
     529       PKGSTATUS=1 
     530       echo "trueos-base" >> /root/.failed-pkgs 
     531       echo "Warning: Failed to install trueos-base!" 
     532       echo "You will need to manually install this package for the TrueOS utils." 
     533       echo "Press ENTER to continue" 
     534       read tmp 
     535    fi 
     536    pc-extractoverlay server 
     537  fi 
     538 
     539  # Start pbid, so that by the time meta-packages are done, we have a full index 
     540  rm /var/db/pbi/index/* 
     541  /usr/local/etc/rc.d/pbid start >/dev/null 2>/dev/null 
     542 
     543  clear 
     544 
     545  clear 
     546  echo "Re-Installing meta-packages" 
     547  while read newmeta 
     548  do 
     549    pc-metapkgmanager add $newmeta 
     550    if [ $? -ne 0 ] ; then 
     551       METASTATUS=1 
     552       echo "$newmeta" >> /root/.failed-meta 
     553       echo "Warning: Failed to re-install meta-package: $newmeta" 
     554       echo "Press ENTER to continue" 
     555       read tmp 
     556    fi 
     557  done < /root/pcbsd-meta-before-update 
     558 
     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 
     577  clear 
     578  echo "Re-Installing PBIs" 
     579  while read newpbi 
     580  do 
     581    shortpbi="`echo $newpbi | rev | cut -d '-' -f 3- | rev`" 
     582    pbi_add -r $shortpbi 
     583    if [ $? -ne 0 ] ; then 
     584       PBISTATUS=1 
     585       echo "$shortpbi" >> /root/.failed-pbi 
     586       echo "Warning: Failed to re-install PBI: $shortpbi" 
     587       echo "Press ENTER to continue" 
     588       read tmp 
     589    fi 
     590  done < /root/pcbsd-pbi-before-update 
     591 
    443592  # Last but not least, lets make sure to re-stamp GRUB in case any loader.conf.pcbsd modules changed 
    444   grub-mkconfig -o /boot/grub/grub.cfg 
    445   if [ $? -ne 0 ] ; then 
    446      echo "Warning: Failed running 'pc-updatemanager pkgupdate -f'" 
     593  grub-mkconfig -o /boot/grub/grub.cfg | tee /root/.failed-grub 
     594  if [ $? -ne 0 ] ; then 
     595     GRUBSTATUS=1 
     596     echo "Warning: Failed running 'grub-mkconfig -o /boot/grub/grub.cfg'" 
    447597     echo "Press ENTER to continue" 
    448598     read tmp 
    449599  fi 
    450600 
    451   echo "Updating overlay files..." 
    452   if [ -e "/usr/local/bin/pc-softwaremanager" ] ; then 
    453     pc-extractoverlay desktop 
     601 
     602  # Now lets show a summary 
     603  clear 
     604 
     605  echo "PC-BSD `uname -r` Upgrade Summary - (`date`)" > /root/pcbsd-update-summary 
     606  echo "-----------------------------------------------------" >> /root/pcbsd-update-summary 
     607 
     608  if [ $FREEBSDSTATUS -eq 0 ] ; then 
     609    echo "FreeBSD: The base-system updated successfully!" >> /root/pcbsd-update-summary 
    454610  else 
    455     pc-extractoverlay server 
    456   fi 
     611    echo "FreeBSD: The base-system failed to install:" >> /root/pcbsd-update-summary 
     612    cat /root/.failed-freebsd >> /root/pcbsd-update-summary 
     613  fi 
     614 
     615  echo "" >> /root/pcbsd-update-summary 
     616 
     617  if [ $PKGSTATUS -eq 0 ] ; then 
     618    echo "PKG: All packages updated successfully!" >> /root/pcbsd-update-summary 
     619  else 
     620    echo "PKG: The following packages failed to install:" >> /root/pcbsd-update-summary 
     621    cat /root/.failed-pkgs >> /root/pcbsd-update-summary 
     622  fi 
     623 
     624  echo "" >> /root/pcbsd-update-summary 
     625 
     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 
     635  if [ $METASTATUS -eq 0 ] ; then 
     636    echo "META: All meta-packages updated successfully!" >> /root/pcbsd-update-summary 
     637  else 
     638    echo "META: The following meta-packages failed to install:" >> /root/pcbsd-update-summary 
     639    cat /root/.failed-meta >> /root/pcbsd-update-summary 
     640  fi 
     641 
     642  echo "" >> /root/pcbsd-update-summary 
     643 
     644  if [ $PBISTATUS -eq 0 ] ; then 
     645    echo "PBI: All meta-packages updated successfully!" >> /root/pcbsd-update-summary 
     646  else 
     647    echo "PBI: The following meta-packages failed to install:" >> /root/pcbsd-update-summary 
     648    cat /root/.failed-pbi >> /root/pcbsd-update-summary 
     649  fi 
     650 
     651  echo "" >> /root/pcbsd-update-summary 
     652 
     653  if [ $GRUBSTATUS -eq 0 ] ; then 
     654    echo "GRUB: The GRUB boot-loader menus re-built successfully!" >> /root/pcbsd-update-summary 
     655  else 
     656    echo "GRUB: The GRUB boot-loader menus failed to rebuild:" >> /root/pcbsd-update-summary 
     657    cat /root/.failed-grub >> /root/pcbsd-update-summary 
     658  fi 
     659 
     660  echo "" >> /root/pcbsd-update-summary 
     661  echo "Old system information: " >> /root/pcbsd-update-summary 
     662  echo "/root/pcbsd-pkg-before-update" >> /root/pcbsd-update-summary 
     663  echo "/root/pcbsd-pbi-before-update" >> /root/pcbsd-update-summary 
     664  echo "/root/pcbsd-meta-before-update" >> /root/pcbsd-update-summary 
     665 
     666  echo "" >> /root/pcbsd-update-summary 
     667 
     668  echo "This summary location: /root/pcbsd-update-summary" >> /root/pcbsd-update-summary 
     669 
     670  # Clear any old summary files 
     671  rm /root/.failed-pkgs 2>/dev/null 
     672  rm /root/.failed-user-pkgs 2>/dev/null 
     673  rm /root/.failed-meta 2>/dev/null 
     674  rm /root/.failed-pbi 2>/dev/null 
     675  rm /root/.failed-grub 2>/dev/null 
     676  rm /root/.failed-freebsd 2>/dev/null 
     677 
     678  more /root/pcbsd-update-summary 
     679 
     680  echo "Press ENTER to reboot" 
     681  read tmp 
    457682 
    458683  exit 0 
     684} 
     685 
     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 
    459699} 
    460700 
    461701start_major_fbsd_update() { 
    462702  local rel=`echo $1 | sed 's|fbsd-||g'` 
    463   PKGROLLBACK="NO" 
    464703 
    465704  # Save the repo file 
     
    476715 
    477716  # Lets backup old pkgng 
    478   oPkg=`pkg info pkg | awk '{print $1}'` 
     717  oPkg=`pkg info pkg | head -n 1 | awk '{print $1}'` 
    479718  pkg create -o /usr/local/tmp/ ${oPkg} 
    480719  if [ -e "/usr/local/tmp/oldPkg.txz" ] ; then rm /usr/local/tmp/oldPkg.txz; fi 
     
    489728  fi 
    490729 
    491   # Lets install pkgng update 
    492   PKGROLLBACK="YES" 
     730  # Now lets build some lists of what is present on this system now 
     731  pkg info > /root/pcbsd-pkg-before-update 
     732  pbi_info > /root/pcbsd-pbi-before-update 
     733  pc-metapkgmanager list-installed > /root/pcbsd-meta-before-update 
     734 
     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} 
    493774 
    494775  # Download update files from freebsd-update 
Note: See TracChangeset for help on using the changeset viewer.