Changeset 045b2de


Ignore:
Timestamp:
03/08/14 12:53:14 (6 months ago)
Author:
Kris Moore <kris@…>
Branches:
releng/10.0
Children:
5e3985e
Parents:
8acecf9
Message:

Backport the fixes for package updates to releng/10.0

Location:
src-sh
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src-sh/libsh/functions.sh

    rbe75ddc r045b2de  
    454454{ 
    455455 
    456   if [ -z "$EVENT_PIPE" ] ; then unset EVENT_PIPE ; fi 
    457  
    458456  # Lets test if we have any conflicts 
    459   pkg-static ${1} | tee /tmp/.pkgConflicts.$$ 
    460  
    461   cat /tmp/.pkgConflicts.$$ | grep -q "WARNING: locally installed" 
     457  pkg-static ${1} 2>&1| tee /tmp/.pkgConflicts.$$ 
     458 
     459  cat /tmp/.pkgConflicts.$$ | grep -q -e "WARNING: locally installed" -e "Conflict found" 
    462460  if [ $? -ne 0 ] ; then rm /tmp/.pkgConflicts.$$ ; return ; fi 
    463461 
     
    468466  # Nice ugly sed line, sure this can be neater 
    469467  cat /tmp/.pkgConflicts.$$ | grep 'WARNING: locally installed' \ 
    470         | sed 's|.*installed ||g' | sed 's| conflicts.*||g' | sort | uniq \ 
    471         > /tmp/.pkgConflicts.$$.2 
     468        | sed 's|.*installed ||g' | sed 's| conflicts.*||g' > /tmp/.pkgConflicts.$$.2 
     469 
     470  # Grab other style conflicts 
     471  cat /tmp/.pkgConflicts.$$ | grep "Conflict found on path" | cut -d ')' -f 2 | cut -d '(' -f 1 | awk '{print $2}' >> /tmp/.pkgConflicts.$$.2 
     472 
     473  # OMFG this is super-lame, not only do we have to grab different style conflicts 
     474  # but we may even have the *wrong* package name reported if it changed in the  
     475  # repo... I.E. py27-requests1-1.2.3 != py27-requests-1.2.3 
     476  # As a VERY crude work-around, grab the other origin names, see which one matches 
     477  cat /tmp/.pkgConflicts.$$ | grep "Conflict found on path" | cut -d '(' -f 2 | cut -d ')' -f 1 >> /tmp/.pkgConflicts.$$.2 
     478  cat /tmp/.pkgConflicts.$$ | grep "Conflict found on path" | cut -d '(' -f 3 | cut -d ")" -f 1 >> /tmp/.pkgConflicts.$$.2 
     479 
     480  # Get a sorted unique list 
     481  cat /tmp/.pkgConflicts.$$.2 | sort | uniq > /tmp/.pkgConflicts.$$.3 
    472482 
    473483  # Check how many conflicts we found 
    474   found=`wc -l /tmp/.pkgConflicts.$$.2 | awk '{print $1}'` 
     484  found=`wc -l /tmp/.pkgConflicts.$$.3 | awk '{print $1}'` 
    475485  if [ "$found" = "0" ] ; then 
    476486     rm /tmp/.pkgConflicts.$$ 
    477487     rm /tmp/.pkgConflicts.$$.2 
     488     rm /tmp/.pkgConflicts.$$.3 
    478489     return 0 
    479490  fi 
     491 
     492  # Done with EVENT_PIPE at this point 
     493  if [ -n "$EVENT_PIPE" ] ; then unset EVENT_PIPE; fi 
     494 
    480495 
    481496  while read line 
    482497  do 
    483     cList="$line $cList" 
    484   done < /tmp/.pkgConflicts.$$.2 
    485   rm /tmp/.pkgConflicts.$$.2  
     498    # Because PKGNG sucks, we have to now double-check again if these conflicts *really* 
     499    # are installed <facepalm> 
     500    pkg-static info -e $line 
     501    if [ $? -eq 0 ] ; then 
     502      cList="$line $cList" 
     503    fi 
     504  done < /tmp/.pkgConflicts.$$.3 
     505  rm /tmp/.pkgConflicts.$$.3 
     506  rm /tmp/.pkgConflicts.$$.2 
    486507  rm /tmp/.pkgConflicts.$$ 
    487508 
     
    518539     echo "Removing conflicting package: $bPkg" 
    519540 
    520      # If EVENT_PIPE is set, unset it, seems to cause some weird crash in pkgng 1.2.3 
    521      if [ -n "$EVENT_PIPE" ] ; then 
    522         oEP="$EVENT_PIPE" 
    523         unset EVENT_PIPE 
    524      fi 
    525  
    526541     # Delete the package now 
    527542     pkg delete -q -y -f ${bPkg} 
    528543 
    529      # Reset EVENT_PIPE if we need to 
    530      if [ -n "$oEP" ] ; then 
    531         EVENT_PIPE="$oEP"; export EVENT_PIPE 
    532         unset oEP 
    533      fi 
    534544  done 
    535545 
  • src-sh/pc-updatemanager/Makefile

    rc60c604 r045b2de  
    3030install_scripts: first FORCE 
    3131        @$(CHK_DIR_EXISTS) $(INSTALL_ROOT)$(PREFIX)/bin/ || $(MKDIR) $(INSTALL_ROOT)$(PREFIX)/bin/  
     32        @$(CHK_DIR_EXISTS) $(INSTALL_ROOT)$(PREFIX)/share/pcbsd/pc-updatemanager/ || $(MKDIR) $(INSTALL_ROOT)$(PREFIX)/share/pcbsd/pc-updatemanager/ 
    3233        -$(INSTALL_FILE) pc-updatemanager $(INSTALL_ROOT)$(PREFIX)/bin/ 
     34        -$(INSTALL_FILE) etcmerge $(INSTALL_ROOT)$(PREFIX)/share/pcbsd/pc-updatemanager/ 
    3335 
    3436 
     
    4345 
    4446install_conf: first FORCE 
    45         @$(CHK_DIR_EXISTS) $(INSTALL_ROOT)$(PREFIX)/share/pcbsd/pc-updatemanager/ || $(MKDIR) $(INSTALL_ROOT)$(PREFIX)/share/pcbsd/pc-updatemanager/  
     47        @$(CHK_DIR_EXISTS) $(INSTALL_ROOT)$(PREFIX)/share/pcbsd/pc-updatemanager/ || $(MKDIR) $(INSTALL_ROOT)$(PREFIX)/share/pcbsd/pc-updatemanager/ 
    4648        -$(INSTALL_DIR) conf $(INSTALL_ROOT)$(PREFIX)/share/pcbsd/pc-updatemanager/ 
    4749 
  • src-sh/pc-updatemanager/pc-updatemanager

    re7484af r045b2de  
    6060IGNDIR="${DBDIR}/ignored" 
    6161 
     62ISOTMP="/usr/local/tmp/pcbsd-update.iso" 
    6263 
    6364###################################################################### 
    6465# Done with config values 
    6566###################################################################### 
     67 
     68# Files we always want to upgrade in /etc 
     69ETCCLOBBER="mail/sendmail.cf mail/freebsd.cf" 
    6670 
    6771show_usage() { 
     
    408412rollback_update() 
    409413{ 
    410   cp /tmp/pcbsd.conf.preUpdate.$$ /usr/local/etc/pkg/repos/pcbsd.conf 
    411414} 
    412415 
     
    439442  fi 
    440443 
     444  # Lets Mount the image image now 
     445  clear 
     446  MD=`mdconfig -a -t vnode -f ${ISOTMP}` ; export MD 
     447  if [ ! -d "/mnt/iso-update" ] ; then mkdir -p "/mnt/iso-update"; fi 
     448  mount -t cd9660 /dev/$MD /mnt/iso-update 
     449  if [ $? -ne 0 ] ; then 
     450     # This should never happen, but just in case the user removed the ISO 
     451     # file or something causes mdconfig / mount to fail, lets roll back 
     452     rm /var/.freebsd-update-finish 
     453     rm -rf /boot/kernel 
     454     mv /boot/kernel.preUpgrade /boot/kernel 
     455 
     456     echo "ERROR: Could not mount ${ISOTMP}... Did the file get removed?" 
     457     echo "The update will now be canceled. Please try again later." 
     458     echo "Press ENTER to continue" 
     459     read tmp 
     460     reboot 
     461     exit 1 
     462  fi 
     463 
    441464  # Remove all PBIs 
    442465  clear 
     
    449472    echo "Removing: ${pbi}" 
    450473    if [ "$user" != "root" ] ; then 
    451       su $user -c "pbi_icon del-desktop $pbi" 
    452       su $user -c "pbi_icon del-menu $pbi" 
    453       su $user -c "pbi_icon del-mime $pbi" 
    454       su $user -c "pbi_icon del-pathlnk $pbi" 
    455       su $user -c "pbi_delete $pbi" 
     474      su $user -c "pbi_icon del-desktop $pbi" >/dev/null 2>/dev/null 
     475      su $user -c "pbi_icon del-menu $pbi" >/dev/null 2>/dev/null 
     476      su $user -c "pbi_icon del-mime $pbi" >/dev/null 2>/dev/null 
     477      su $user -c "pbi_icon del-pathlnk $pbi" >/dev/null 2>/dev/null 
     478      su $user -c "pbi_delete $pbi" >/dev/null 2>/dev/null 
    456479      result=$? 
    457480    else 
    458       pbi_icon del-desktop $pbi 
    459       pbi_icon del-menu $pbi 
    460       pbi_icon del-mime $pbi 
    461       pbi_icon del-pathlnk $pbi 
     481      pbi_icon del-desktop $pbi >/dev/null 2>/dev/null 
     482      pbi_icon del-menu $pbi >/dev/null 2>/dev/null 
     483      pbi_icon del-mime $pbi >/dev/null 2>/dev/null 
     484      pbi_icon del-pathlnk $pbi >/dev/null 2>/dev/null 
    462485      pbi_delete $pbi >/dev/null 2>/dev/null 
    463486      result=$? 
     
    472495  # Start the package cleanup process 
    473496  clear 
    474   echo "Removing packages...This may take a while...\c" 
     497  echo "Removing packages...This may take a while..." 
    475498  pkg delete -afy 
    476499  if [ $? -ne 0 ] ; then 
     
    480503  echo "Done!" 
    481504 
    482   # Start the freebsd-update process 
     505 
     506  # Setup temp logfile 
     507  if [ -e "/root/.failed-freebsd" ] ; then rm /root/.failed-freebsd; fi 
    483508  clear 
    484   echo "Installing FreeBSD updates... Please wait..." 
    485   freebsd-update --non-interactive install | tee /root/.failed-freebsd 
    486   if [ $? -ne 0 ] ; then 
    487      echo "Warning: Failed running freebsd-update install!" 
    488      echo "Press ENTER to continue" 
     509 
     510  # We need to be sure and removal the immutable flags 
     511  echo "Preparing filesystem..." 
     512  chflags -R noschg / 
     513 
     514  distFiles="base doc games lib32" 
     515  for i in $distFiles 
     516  do 
     517    echo -e "Updating world: $i...\c" 
     518    tar -xvp -f /mnt/iso-update/dist/${i}.txz --exclude ./proc --exclude ./etc/ -C / >> /tmp/.extract.$$ 2>> /tmp/.extract.$$ 
     519    if [ $? -ne 0 ] ; then 
     520       FREEBSDSTATUS=1 
     521       echo -e "Warning!" 
     522       cat /tmp/.extract.$$ >> /root/.failed-freebsd 
     523       sleep 5 
     524    else 
     525       echo -e "Done" 
     526    fi 
     527  done 
     528  rm /tmp/.extract.$$ 
     529 
     530  # Now time to do all the etcmerge stuff 
     531  TMPETC="/root/etc-update" 
     532  if [ -d "$TMPETC" ] ; then rm -rf $TMPETC ; fi 
     533  mkdir -p $TMPETC 
     534 
     535  tar -xvp -f /mnt/iso-update/dist/base.txz -C ${TMPETC} ./etc >/dev/null 2>/dev/null 
     536  mv ${TMPETC}/etc ${TMPETC}/etc-new 
     537 
     538  # Can nuke these two, will be re-generated during etcmerge 
     539  rm ${TMPETC}/etc-new/spwd.db 
     540  rm ${TMPETC}/etc-new/pwd.db 
     541 
     542  echo "Merging /etc..." 
     543  /sbin/etcmerge -d ${TMPETC} init  >> /root/.failed-freebsd 2>> /root/.failed-freebsd 
     544  cd $TMPETC 
     545 
     546  # Lets copy the files we always want to clobber 
     547  for i in ${ETCCLOBBER} 
     548  do 
     549     # If this file existed on system, save copy of old version 
     550     if [ -e "/etc/$i" ] ; then 
     551        cp /etc/${i} etc-merged/${i}.preUpgrade 
     552     fi 
     553     # Overwrite the new version 
     554     if [ -e "etc-merged/${i}" ] ; then 
     555        cp etc-new/${i} etc-merged/${i} 
     556     fi 
     557  done 
     558 
     559  # Lets resolve the conflicts found, use the *new* strings by default 
     560  # Copy the old file to /etc/<file>.preUpgrade 
     561  for i in $(cat *.conflicts 2> /dev/null); do 
     562     if [ ! -e "etc-merged/${i}" ] ; then continue ; fi 
     563     if egrep -q '^(<<<<<<< |=======$|>>>>>>> )' etc-merged/$i; then 
     564        cp /etc/${i} etc-merged/${i}.preUpgrade 
     565 
     566        # Lets parse out the old, bring in new changes 
     567        rem=0 
     568        while read line 
     569        do 
     570          echo "$line" | egrep -q '^<<<<<<< ' 
     571          if [ $? -eq 0 ] ; then rem=1 ; continue ; fi 
     572 
     573          echo "$line" | egrep -q '^=======$' 
     574          if [ $? -eq 0 ] ; then rem=0 ; continue ; fi 
     575 
     576          echo "$line" | egrep -q '^>>>>>>> ' 
     577          if [ $? -eq 0 ] ; then rem=0 ; continue ; fi 
     578 
     579          if [ $rem -eq 0 ] ; then echo "$line" >> etc-merged/${i}.new ; fi 
     580        done < etc-merged/${i} 
     581 
     582        # Copy the fixed file 
     583        cp -p etc-merged/${i}.new etc-merged/${i} 
     584        rm etc-merged/${i}.new 
     585     fi 
     586  done 
     587 
     588  # Now install the merged /etc/ stuff 
     589  cd $TMPETC 
     590  /sbin/etcmerge -d ${TMPETC} install >> /root/.failed-freebsd 2>>/root/.failed-freebsd 
     591  if [ $? -ne 0 ] ; then 
    489592     FREEBSDSTATUS=1 
    490      read tmp 
    491   fi 
     593     echo "Warning: Failed etcmerge install..." 
     594     sleep 5 
     595  fi 
     596 
     597  # Save the etc-new directory as the old one now 
     598  rm -rf /var/db/etc 
     599  cp -r etc-new /var/db/etc 
     600 
     601  # Cleanup 
     602  rm -rf ${TMPETC} 
     603  rm /sbin/etcmerge 
     604 
    492605  clear 
    493606 
     
    515628     mkdir "/usr/local/etc/pkg/fingerprints/pcbsd/revoked" 
    516629  fi 
    517   cd / 
    518   tar xvpf /usr/local/tmp/pkg.txz /usr/local/sbin/pkg-static >/dev/null 2>/dev/null 
    519   /usr/local/sbin/pkg-static install -y ports-mgmt/pkg 
     630  cd /mnt/iso-update/dist/packages/All 
     631  pkgFile=`ls pkg-[1-9]*` 
     632  tar xvpf $pkgFile -C / /usr/local/sbin/pkg-static >/dev/null 2>/dev/null 
     633  /usr/local/sbin/pkg-static add -f $pkgFile 
    520634  if [ $? -ne 0 ] ; then 
    521635     echo "Warning: Failed to re-install PKGNG..." 
     
    524638  fi 
    525639 
    526   # Lets update the pkgng repo 
     640 
     641  # Lets create our fake pcbsd.conf file 
     642  echo "pcbsd: { 
     643  url: \"file:///mnt/iso-update/dist/packages\", 
     644  enabled: true 
     645}" >  /usr/local/etc/pkg/repos/pcbsd.conf 
     646 
     647  # Now update pkgng 
    527648  pkg-static update -f 
     649  if [ $? -ne 0 ] ; then 
     650     echo "Failed updating pkgng repo..." 
     651     sleep 5 
     652  fi 
    528653 
    529654  # Now lets begin re-installing packages 
     
    559684 
    560685  clear 
    561  
    562   clear 
    563686  echo "Re-Installing meta-packages" 
    564687  while read newmeta 
    565688  do 
    566     pc-metapkgmanager add $newmeta 
    567     if [ $? -ne 0 ] ; then 
    568        METASTATUS=1 
    569        echo "$newmeta" >> /root/.failed-meta 
    570        echo "Warning: Failed to re-install meta-package: $newmeta" 
    571        echo "Press ENTER to continue" 
    572        read tmp 
    573     fi 
     689    pkgDeps="`pc-metapkgmanager pkgdeps $newmeta`" 
     690    for i in $pkgDeps 
     691    do 
     692      pkg-static info -e ${i} 
     693      if [ $? -eq 0 ] ; then continue ; fi 
     694 
     695      pkg-static install -y ${i} 
     696      if [ $? -ne 0 ] ; then 
     697         METASTATUS=1 
     698         echo "$newmeta" >> /root/.failed-meta 
     699         echo "Warning: Failed to re-install meta-package: $newmeta (${i})" 
     700         echo "Press ENTER to continue" 
     701         read tmp 
     702      fi 
     703    done 
    574704  done < /root/pcbsd-meta-before-update 
    575705 
     
    590720    fi 
    591721  done < /root/pcbsd-userpkgs-before-update 
     722 
     723  cd / 
     724 
     725  # Now lets do the overlay extraction (This cleans up the fake pcbsd.conf) 
     726  pc-extractoverlay ports 
    592727 
    593728  # Now lets re-load any PBI files 
     
    617752       # Re-add menu / desktop stuff 
    618753       if [ "$user" != "root" ] ; then 
    619          su $user -c "pbi_icon add-pathlnk $shortpbi" 
    620          su $user -c "pbi_icon add-desktop $shortpbi" 
    621          su $user -c "pbi_icon add-menu $shortpbi" 
    622          su $user -c "pbi_icon add-mime $shortpbi" 
     754         su $user -c "pbi_icon add-pathlnk $shortpbi" >/dev/null 2>/dev/null 
     755         su $user -c "pbi_icon add-desktop $shortpbi" >/dev/null 2>/dev/null 
     756         su $user -c "pbi_icon add-menu $shortpbi" >/dev/null 2>/dev/null 
     757         su $user -c "pbi_icon add-mime $shortpbi" >/dev/null 2>/dev/null 
    623758       else 
    624          pbi_icon add-pathlnk $shortpbi 
    625          pbi_icon add-desktop $shortpbi 
    626          pbi_icon add-menu $shortpbi 
    627          pbi_icon add-mime $shortpbi 
     759         pbi_icon add-pathlnk $shortpbi >/dev/null 2>/dev/null 
     760         pbi_icon add-desktop $shortpbi >/dev/null 2>/dev/null 
     761         pbi_icon add-menu $shortpbi >/dev/null 2>/dev/null 
     762         pbi_icon add-mime $shortpbi >/dev/null 2>/dev/null 
    628763       fi 
    629764    fi 
     
    653788  fi 
    654789 
    655   echo "" >> /root/pcbsd-update-summary 
    656  
    657790  if [ $PKGSTATUS -eq 0 ] ; then 
    658     echo "PKG: All packages updated successfully!" >> /root/pcbsd-update-summary 
     791    echo "    PKG: All packages updated successfully!" >> /root/pcbsd-update-summary 
    659792  else 
    660     echo "PKG: The following packages failed to install:" >> /root/pcbsd-update-summary 
     793    echo "    PKG: The following packages failed to install:" >> /root/pcbsd-update-summary 
    661794    cat /root/.failed-pkgs >> /root/pcbsd-update-summary 
    662795  fi 
    663  
    664   echo "" >> /root/pcbsd-update-summary 
    665796 
    666797  if [ $USERPKGSTATUS -eq 0 ] ; then 
     
    671802  fi 
    672803 
    673   echo "" >> /root/pcbsd-update-summary 
    674  
    675804  if [ $METASTATUS -eq 0 ] ; then 
    676     echo "META: All meta-packages updated successfully!" >> /root/pcbsd-update-summary 
     805    echo "   META: All meta-packages updated successfully!" >> /root/pcbsd-update-summary 
    677806  else 
    678     echo "META: The following meta-packages failed to install:" >> /root/pcbsd-update-summary 
     807    echo "   META: The following meta-packages failed to install:" >> /root/pcbsd-update-summary 
    679808    cat /root/.failed-meta >> /root/pcbsd-update-summary 
    680809  fi 
    681810 
    682   echo "" >> /root/pcbsd-update-summary 
    683  
    684811  if [ $PBISTATUS -eq 0 ] ; then 
    685     echo "PBI: All PBIs updated successfully!" >> /root/pcbsd-update-summary 
     812    echo "    PBI: All PBIs updated successfully!" >> /root/pcbsd-update-summary 
    686813  else 
    687     echo "PBI: The following PBIs failed to install:" >> /root/pcbsd-update-summary 
     814    echo "    PBI: The following PBIs failed to install:" >> /root/pcbsd-update-summary 
    688815    cat /root/.failed-pbi >> /root/pcbsd-update-summary 
    689816  fi 
    690817 
    691   echo "" >> /root/pcbsd-update-summary 
    692  
    693818  if [ $GRUBSTATUS -eq 0 ] ; then 
    694     echo "GRUB: The GRUB boot-loader menus re-built successfully!" >> /root/pcbsd-update-summary 
     819    echo "   GRUB: The GRUB boot-loader menus re-built successfully!" >> /root/pcbsd-update-summary 
    695820  else 
    696     echo "GRUB: The GRUB boot-loader menus failed to rebuild:" >> /root/pcbsd-update-summary 
     821    echo "   GRUB: The GRUB boot-loader menus failed to rebuild:" >> /root/pcbsd-update-summary 
    697822    cat /root/.failed-grub >> /root/pcbsd-update-summary 
    698823  fi 
     
    718843  more /root/pcbsd-update-summary 
    719844 
     845  # Cleanup time 
     846  cd / 
     847  umount /mnt/iso-update 2>/dev/null 
     848  mdconfig -d -u $MD 2>/dev/null 
     849  rm ${ISOTMP} 2>/dev/null 
     850 
    720851  echo "Press ENTER to reboot" 
    721852  read tmp 
     
    742873  local rel=`echo $1 | sed 's|fbsd-||g'` 
    743874 
    744   # Save the repo file 
    745   cp /usr/local/etc/pkg/repos/pcbsd.conf /tmp/pcbsd.conf.preUpdate.$$ 
    746  
    747   # Set the new pcbsd.conf file to the new repo 
    748   local arch=`uname -m` 
    749   echo "pcbsd: { 
    750         url: "http://pkg.cdn.pcbsd.org/$rel/$arch", 
    751         signature_type: "fingerprints", 
    752         fingerprints: "/usr/local/etc/pkg/fingerprints/pcbsd", 
    753         enabled: true 
    754        }" > /usr/local/etc/pkg/repos/pcbsd.conf 
    755  
    756   # Lets backup old pkgng 
    757   oPkg=`pkg info pkg | head -n 1 | awk '{print $1}'` 
    758   pkg create -o /usr/local/tmp/ ${oPkg} 
    759   if [ -e "/usr/local/tmp/oldPkg.txz" ] ; then rm /usr/local/tmp/oldPkg.txz; fi 
    760   mv /usr/local/tmp/${oPkg}.txz /usr/local/tmp/oldPkg.txz 
    761  
    762   # Lets download the new pkgng for this release 
    763   if [ -e "/usr/local/tmp/pkg.txz" ] ; then rm /usr/local/tmp/pkg.txz; fi 
    764   get_file_from_mirrors "/packages/$rel/$arch/Latest/pkg.txz" "/usr/local/tmp/pkg.txz" "pkg" 
    765   if [ $? -ne 0 ] ; then 
    766      rollback_update 
    767      exit_err "Failed downloading pkgng update..." 
     875  # Do the disk-space check 
     876  rZpool="`mount | grep 'on / ' | awk '{print $1}' | cut -d '/' -f 1`" 
     877  poolFree="`zpool list -H -o free $rZpool`" 
     878 
     879  # is space in GB? 
     880  echo "$poolFree" | grep -q "G" 
     881  if [ $? -eq 0 ] ; then 
     882     poolFree="`echo $poolFree | sed 's|G||g'`" 
     883     if [ $poolFree -lt 10 ] ; then 
     884        exit_err "Need at least 20GB of free space to continue" 
     885     fi 
     886  fi 
     887 
     888  # Is space in MB? 
     889  echo "$poolFree" | grep -q "M" 
     890  if [ $? -eq 0 ] ; then 
     891     poolFree="`echo $poolFree | sed 's|M||g'`" 
     892     if [ $poolFree -lt 10000 ] ; then 
     893        exit_err "Need at least 20GB of free space to continue" 
     894     fi 
     895  fi 
     896 
     897  # Grab the ISO file from the mirrors 
     898  get_file_from_mirrors "/$rel/$ARCH/latest.iso" "$ISOTMP" "iso" 
     899  get_file_from_mirrors "/$rel/$ARCH/latest.iso.md5" "${ISOTMP}.md5" "iso" 
     900 
     901  # Verify the ISO file is good for an update 
     902  verify_iso_data 
     903 
     904  # Lets auto-create a new boot-environment before updating 
     905  if [ -z "$NOBEADM" ] ; then 
     906    beadm create ${SYSVER}-beforeUpdate 
     907    if [ $? -ne 0 ] ; then 
     908       echo "WARNING: Unable to create a new boot-enviroment!" 
     909       sleep 10 
     910    fi 
    768911  fi 
    769912 
     
    826969  rm ${mOriginFile} 
    827970 
    828   # Download update files from freebsd-update 
    829   freebsd-update --non-interactive -r "$rel" upgrade 
    830   if [ $? -ne 0 ] ; then 
     971  # Now install the updated kernel 
     972  if [ -d "/boot/kernel.preUpgrade" ] ; then 
     973     rm -rf /boot/kernel.preUpgrade 
     974  fi 
     975  mv /boot/kernel /boot/kernel.preUpgrade 
     976 
     977  echo "Updating kernel..." 
     978  tar xf /mnt/iso-update/dist/kernel.txz -C / 2>/dev/null >/dev/null 
     979  if [ $? -ne 0 ] ; then 
     980       rm -rf /boot/kernel 
     981       mv /boot/kernel.preUpgrade /boot/kernel 
     982       umount /mnt/iso-update 
     983       mdconfig -d -u $MD 
     984       rollback_update 
     985       exit_err "Kernel update failed! (Old kernel restored)" 
     986  fi 
     987 
     988  # Unmount / cleanup ISO 
     989  umount /mnt/iso-update 
     990  mdconfig -d -u $MD 
     991 
     992  # Touch our marker that we will need to reboot before doing other updates 
     993  touch /var/.freebsd-update-finish 
     994  touch /tmp/.fbsdup-reboot 
     995 
     996  echo "Major update staged!" 
     997  echo "Please reboot the system for the updater to continue." 
     998  exit 0 
     999} 
     1000 
     1001## Do a fetch of a pristine /etc directory for the three way etcmerge 
     1002fetch_clean_etc() 
     1003{ 
     1004  echo "Fetching pristine /etc for merging..." 
     1005  baseTmp="/usr/local/tmp/base.txz.$$" 
     1006  get_file_from_mirrors "/$SYSVER/$ARCH/dist/base.txz" "$baseTmp" "iso" 
     1007  if [ $? -ne 0 ] ; then return 1 ; fi 
     1008 
     1009  rm -rf "/var/db/etc/" 
     1010  echo "Extracting pristine /etc for merging..." 
     1011  tar xvpf ${baseTmp} -C /var/db ./etc >/dev/null 2>/dev/null 
     1012  local err=$? 
     1013  rm ${baseTmp} 
     1014  return $err 
     1015} 
     1016 
     1017## Verify that ISO is suitable for upgrading with 
     1018verify_iso_data() 
     1019{ 
     1020  if [ ! -e "${ISOTMP}" ] ; then 
    8311021     rollback_update 
    832      exit_err "Failed running \"freebsd-update -r $rel upgrade\"..." 
    833   fi 
    834  
    835   # Touch our marker that we will need to reboot before doing other updates 
    836   touch /tmp/.fbsdup-reboot 
    837  
    838   # Now install freebsd-update files 
    839   freebsd-update --non-interactive install 
    840   if [ $? -ne 0 ] ; then 
     1022     exit_err "ISO fails checksum..." 
     1023  fi 
     1024 
     1025  # Check that the MD5 matches 
     1026  echo "Checking ISO checksum..." 
     1027  if [ "`md5 -q $ISOTMP`" != "`cat ${ISOTMP}.md5`" ] ; then 
    8411028     rollback_update 
    842      exit_err "Failed running \"freebsd-update install\"..." 
    843   fi 
    844  
    845   # Remove backup repo file 
    846   rm /tmp/pcbsd.conf.preUpdate.$$ 
    847  
    848   echo "Major update finished!"  
    849   echo "Please reboot the system for changes to take effect."  
    850   exit 0 
     1029     exit_err "ISO fails checksum..." 
     1030  fi 
     1031 
     1032  # Now we need to "mount" the ISO, check its contents 
     1033  MD=`mdconfig -a -t vnode -f ${ISOTMP}` ; export MD 
     1034  if [ ! -d "/mnt/iso-update" ] ; then mkdir -p "/mnt/iso-update"; fi 
     1035  mount -t cd9660 /dev/$MD /mnt/iso-update 
     1036  if [ $? -ne 0 ] ; then 
     1037     mdconfig -d -u $MD 
     1038     rollback_update 
     1039     exit_err "ISO failed mount..." 
     1040  fi 
     1041 
     1042  # Now we are mounted, verify the dist files exist and can be read 
     1043  distFiles="base doc games kernel lib32" 
     1044  for i in $distFiles 
     1045  do 
     1046     if [ ! -e "/mnt/iso-update/dist/${i}.txz" ] ; then 
     1047       umount /mnt/iso-update 
     1048       mdconfig -d -u $MD 
     1049       rollback_update 
     1050       exit_err "ISO missing distfile: /dist/${i}.txz" 
     1051     fi 
     1052 
     1053     echo "Verifying distfile: ${i}.txz" 
     1054     tar tf "/mnt/iso-update/dist/${i}.txz" >/dev/null 2>/dev/null 
     1055     if [ $? -ne 0 ] ; then 
     1056       umount /mnt/iso-update 
     1057       mdconfig -d -u $MD 
     1058       rollback_update 
     1059       exit_err "ISO corrupt distfile: /dist/${i}.txz" 
     1060     fi 
     1061  done 
     1062 
     1063  # Lets fetch a pristine /etc for merging, don't trust an old one in /var/db 
     1064  fetch_clean_etc 
     1065  if [ $? -ne 0 ] ; then 
     1066     umount /mnt/iso-update 
     1067     mdconfig -d -u $MD 
     1068     rollback_update 
     1069     exit_err "Missing etcmerge directory: /var/db/etc" 
     1070  fi 
     1071 
     1072  # Make sure we have /sbin/etcmerge copied over 
     1073  cp ${PROGDIR}/etcmerge /sbin/etcmerge 
     1074  if [ $? -ne 0 ] ; then 
     1075       umount /mnt/iso-update 
     1076       mdconfig -d -u $MD 
     1077       rollback_update 
     1078       exit_err "Failed setting up etcmerge..." 
     1079  fi 
     1080  chmod 755 /sbin/etcmerge 
    8511081} 
    8521082 
     
    9191149  fi 
    9201150 
     1151  # Don't use EVENT_PIPE for the update -f command 
     1152  if [ -n "$EVENT_PIPE" ] ; then 
     1153     oEP="$EVENT_PIPE"  
     1154     unset EVENT_PIPE 
     1155  fi 
     1156 
    9211157  # Update the DB first 
    9221158  pkg-static update -f 
    9231159 
     1160  # Enable EVENT_PIPE again 
     1161  if [ -n "$oEP" ] ; then 
     1162     EVENT_PIPE="$oEP" 
     1163     unset oEP 
     1164     export EVENT_PIPE 
     1165  fi 
     1166 
    9241167  # Look for conflicts 
    9251168  check_pkg_conflicts "upgrade -FUy $1" 
     
    9271170     exit 1 
    9281171  fi 
     1172 
     1173  # Done with EVENT_PIPE 
     1174  unset EVENT_PIPE 
    9291175 
    9301176  # Start the package update! 
     
    9481194  exit $result 
    9491195} 
    950  
    951 # Check if we have an update folder for the version we are on 
    952 if [ ! -d "${AVAILDIR}/${SYSVER}" ] ; then mkdir -p ${AVAILDIR}/${SYSVER} ; fi 
    9531196 
    9541197if [ "`id -u`" = "0" ] ; then 
Note: See TracChangeset for help on using the changeset viewer.