Changeset 6052403


Ignore:
Timestamp:
01/07/14 17:47:39 (7 months ago)
Author:
Kris Moore <kris@…>
Branches:
master, releng/10.0, releng/10.0.1, releng/10.0.2
Children:
55d0b6f, 2a39cc54
Parents:
aa7ba66
Message:

Major update to the pc-updatemanager utility.

Change how we perform updates to new "major" releases of Free/PC-BSD

Now, instead of relying on the always failing pkgng upgrade system, use
the pc-updatemanager to build lists of the old system pbis/pkgs/metapkgs
, install the new world / kernel and then re-install the PBIs / metapkgs.

As a bonus, we will now keep these lists, and generate a summary file which
can be used post-install to diagnose any potential problems during the upgrade.

I still need to finish some additional parsing to grab any user-installed pkgng
apps.

File:
1 edited

Legend:

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

    r81e27dd r6052403  
    420420  export PATH 
    421421 
     422  # Set some status variables 
     423  PKGSTATUS=0 
     424  PBISTATUS=0 
     425  FREEBSDSTATUS=0 
     426  GRUBSTATUS=0 
     427  METASTATUS=0 
     428 
     429  # Clear any old summary files 
     430  rm /root/.failed-pkgs 2>/dev/null 
     431  rm /root/.failed-meta 2>/dev/null 
     432  rm /root/.failed-pbi 2>/dev/null 
     433  rm /root/.failed-freebsd 2>/dev/null 
     434  rm /root/.failed-grub 2>/dev/null 
     435 
     436  # Is this a desktop or server? 
     437  if [ -e "/usr/local/bin/pc-softwaremanager" ] ; then 
     438     SYSTYPE="desktop" 
     439  else 
     440     SYSTYPE="server" 
     441  fi 
     442 
     443  # Remove all PBIs 
     444  clear 
     445  echo "Removing PBIs..." 
     446  while read pbi 
     447  do 
     448    echo "Removing: ${pbi}" 
     449    pbi_delete $pbi >/dev/null 2>/dev/null 
     450    if [ $? -ne 0 ] ; then 
     451       echo "Warning: Failed to remove: $pbi" 
     452       sleep 5 
     453    fi 
     454  done < /root/pcbsd-pbi-before-update 
     455  echo "Done!" 
     456 
     457  # Start the package cleanup process 
     458  clear 
     459  echo "Removing packages...This may take a while...\c" 
     460  pkg delete -afy 
     461  if [ $? -ne 0 ] ; then 
     462     echo "Warning: Failed to remove all packages" 
     463     sleep 5 
     464  fi 
     465  echo "Done!" 
     466 
     467  # Start the freebsd-update process 
     468  clear 
    422469  echo "Installing FreeBSD updates... Please wait..." 
    423   freebsd-update --non-interactive install 
     470  freebsd-update --non-interactive install | tee /root/.failed-freebsd 
    424471  if [ $? -ne 0 ] ; then 
    425472     echo "Warning: Failed running freebsd-update install!" 
    426473     echo "Press ENTER to continue" 
     474     FREEBSDSTATUS=1 
    427475     read tmp 
    428476  fi 
     477  clear 
    429478 
    430479  # Remove this, causes all kinds of havok during the update 
     
    439488  /etc/rc.d/devfs restart 
    440489  /etc/rc.d/netif restart 
     490  /etc/rc.d/devd start 
     491  /etc/rc.d/wpa_supplicant start 
     492  /etc/rc.d/dhclient start 
    441493  sleep 8 
    442494  clear 
    443495 
    444   # Now its time to force a pkg-update of all packages to their new FreeBSD compiled versions 
    445   pc-updatemanager pkgupdate -f 
    446   if [ $? -ne 0 ] ; then 
    447      echo "Warning: Failed running 'pc-updatemanager pkgupdate -f'" 
     496  # This is super-lame, we can't just remove all packages *except* pkgng, so we have to re-bootstrap 
     497  # Lets extract the new pkgng we fetched earlier 
     498  echo "Boot-Strapping PKGNG..." 
     499  if [ ! -d "/usr/local/etc/pkg/fingerprints/pcbsd/revoked" ] ; then 
     500     mkdir "/usr/local/etc/pkg/fingerprints/pcbsd/revoked" 
     501  fi 
     502  cd / 
     503  tar xvpf /usr/local/tmp/pkg.txz /usr/local/sbin/pkg-static >/dev/null 2>/dev/null 
     504  /usr/local/sbin/pkg-static install -y ports-mgmt/pkg 
     505  if [ $? -ne 0 ] ; then 
     506     echo "Warning: Failed to re-install PKGNG..." 
    448507     echo "Press ENTER to continue" 
    449508     read tmp 
    450509  fi 
    451510 
     511  # Lets update the pkgng repo 
     512  pkg-static update -f 
     513 
     514  # Now lets begin re-installing packages 
     515  if [ "$SYSTYPE" = "desktop" ] ; then 
     516    echo "Installing desktop packages..." 
     517    pkg-static install -y pcbsd-base 
     518    if [ $? -ne 0 ] ; then 
     519       PKGSTATUS=1 
     520       echo "pcbsd-base" >> /root/.failed-pkgs 
     521       echo "Warning: Failed to install pcbsd-base!" 
     522       echo "You will need to manually install this package to re-enable the PC-BSD desktop" 
     523       echo "Press ENTER to continue" 
     524       read tmp 
     525    fi 
     526    pc-extractoverlay desktop 
     527  else 
     528    echo "Installing server packages..." 
     529    pkg-static install -y trueos-base 
     530    if [ $? -ne 0 ] ; then 
     531       PKGSTATUS=1 
     532       echo "trueos-base" >> /root/.failed-pkgs 
     533       echo "Warning: Failed to install trueos-base!" 
     534       echo "You will need to manually install this package for the TrueOS utils." 
     535       echo "Press ENTER to continue" 
     536       read tmp 
     537    fi 
     538    pc-extractoverlay server 
     539  fi 
     540 
     541  # Start pbid, so that by the time meta-packages are done, we have a full index 
     542  rm /var/db/pbi/index/* 
     543  /usr/local/etc/rc.d/pbid start >/dev/null 2>/dev/null 
     544 
     545  clear 
     546 
     547  clear 
     548  echo "Re-Installing meta-packages" 
     549  while read newmeta 
     550  do 
     551    pc-metapkgmanager add $newmeta 
     552    if [ $? -ne 0 ] ; then 
     553       METASTATUS=1 
     554       echo "$newmeta" >> /root/.failed-meta 
     555       echo "Warning: Failed to re-install meta-package: $newmeta" 
     556       echo "Press ENTER to continue" 
     557       read tmp 
     558    fi 
     559  done < /root/pcbsd-meta-before-update 
     560 
     561  clear 
     562  echo "Re-Installing PBIs" 
     563  while read newpbi 
     564  do 
     565    shortpbi="`echo $newpbi | rev | cut -d '-' -f 3- | rev`" 
     566    pbi_add -r $shortpbi 
     567    if [ $? -ne 0 ] ; then 
     568       PBISTATUS=1 
     569       echo "$shortpbi" >> /root/.failed-pbi 
     570       echo "Warning: Failed to re-install PBI: $shortpbi" 
     571       echo "Press ENTER to continue" 
     572       read tmp 
     573    fi 
     574  done < /root/pcbsd-pbi-before-update 
     575 
     576 
    452577  # Last but not least, lets make sure to re-stamp GRUB in case any loader.conf.pcbsd modules changed 
    453   grub-mkconfig -o /boot/grub/grub.cfg 
    454   if [ $? -ne 0 ] ; then 
     578  grub-mkconfig -o /boot/grub/grub.cfg | tee /root/.failed-grub 
     579  if [ $? -ne 0 ] ; then 
     580     GRUBSTATUS=1 
    455581     echo "Warning: Failed running 'grub-mkconfig -o /boot/grub/grub.cfg'" 
    456582     echo "Press ENTER to continue" 
     
    458584  fi 
    459585 
    460   echo "Updating overlay files..." 
    461   if [ -e "/usr/local/bin/pc-softwaremanager" ] ; then 
    462     pc-extractoverlay desktop 
     586 
     587  # Now lets show a summary 
     588  clear 
     589 
     590  echo "PC-BSD `uname -r` Upgrade Summary - (`date`)" > /root/pcbsd-update-summary 
     591  echo "-----------------------------------------------------" >> /root/pcbsd-update-summary 
     592 
     593  if [ $FREEBSDSTATUS -eq 0 ] ; then 
     594    echo "FreeBSD: The base-system updated successfully!" >> /root/pcbsd-update-summary 
    463595  else 
    464     pc-extractoverlay server 
    465   fi 
     596    echo "FreeBSD: The base-system failed to install:" >> /root/pcbsd-update-summary 
     597    cat /root/.failed-freebsd >> /root/pcbsd-update-summary 
     598  fi 
     599 
     600  echo "" >> /root/pcbsd-update-summary 
     601 
     602  if [ $PKGSTATUS -eq 0 ] ; then 
     603    echo "PKG: All packages updated successfully!" >> /root/pcbsd-update-summary 
     604  else 
     605    echo "PKG: The following packages failed to install:" >> /root/pcbsd-update-summary 
     606    cat /root/.failed-pkgs >> /root/pcbsd-update-summary 
     607  fi 
     608 
     609  echo "" >> /root/pcbsd-update-summary 
     610 
     611  if [ $METASTATUS -eq 0 ] ; then 
     612    echo "META: All meta-packages updated successfully!" >> /root/pcbsd-update-summary 
     613  else 
     614    echo "META: The following meta-packages failed to install:" >> /root/pcbsd-update-summary 
     615    cat /root/.failed-meta >> /root/pcbsd-update-summary 
     616  fi 
     617 
     618  echo "" >> /root/pcbsd-update-summary 
     619 
     620  if [ $PBISTATUS -eq 0 ] ; then 
     621    echo "PBI: All meta-packages updated successfully!" >> /root/pcbsd-update-summary 
     622  else 
     623    echo "PBI: The following meta-packages failed to install:" >> /root/pcbsd-update-summary 
     624    cat /root/.failed-pbi >> /root/pcbsd-update-summary 
     625  fi 
     626 
     627  echo "" >> /root/pcbsd-update-summary 
     628 
     629  if [ $GRUBSTATUS -eq 0 ] ; then 
     630    echo "GRUB: The GRUB boot-loader menus re-built successfully!" >> /root/pcbsd-update-summary 
     631  else 
     632    echo "GRUB: The GRUB boot-loader menus failed to rebuild:" >> /root/pcbsd-update-summary 
     633    cat /root/.failed-grub >> /root/pcbsd-update-summary 
     634  fi 
     635 
     636  echo "Old system information: " >> /root/pcbsd-update-summary 
     637  echo "/root/pcbsd-pkg-before-update" >> /root/pcbsd-update-summary 
     638  echo "/root/pcbsd-pbi-before-update" >> /root/pcbsd-update-summary 
     639  echo "/root/pcbsd-meta-before-update" >> /root/pcbsd-update-summary 
     640 
     641  echo "" >> /root/pcbsd-update-summary 
     642 
     643  echo "This summary location: /root/pcbsd-update-summary" >> /root/pcbsd-update-summary 
     644 
     645  # Clear any old summary files 
     646  rm /root/.failed-pkgs 2>/dev/null 
     647  rm /root/.failed-meta 2>/dev/null 
     648  rm /root/.failed-pbi 2>/dev/null 
     649  rm /root/.failed-grub 2>/dev/null 
     650  rm /root/.failed-freebsd 2>/dev/null 
     651 
     652  more /root/pcbsd-update-summary 
     653 
     654  echo "Press ENTER to reboot" 
     655  read tmp 
    466656 
    467657  exit 0 
     
    497687     exit_err "Failed downloading pkgng update..." 
    498688  fi 
     689 
     690  # Now lets build some lists of what is present on this system now 
     691  pkg info > /root/pcbsd-pkg-before-update 
     692  pbi_info > /root/pcbsd-pbi-before-update 
     693  pc-metapkgmanager list-installed > /root/pcbsd-meta-before-update 
    499694 
    500695  # Lets install pkgng update 
Note: See TracChangeset for help on using the changeset viewer.