[PC-BSD Commits] r21838 - pcbsd/current/src-sh/pc-updatemanager

svn at pcbsd.org svn at pcbsd.org
Wed Mar 13 03:54:27 PDT 2013


Author: kris
Date: 2013-03-13 10:54:27 +0000 (Wed, 13 Mar 2013)
New Revision: 21838

Modified:
   pcbsd/current/src-sh/pc-updatemanager/pc-updatemanager
Log:

Change a bit how to do package downloads via pc-updatemanager

Now use our own function to do the downloading, so we can retry and
hit other mirrors if the current one goes down. 



Modified: pcbsd/current/src-sh/pc-updatemanager/pc-updatemanager
===================================================================
--- pcbsd/current/src-sh/pc-updatemanager/pc-updatemanager	2013-03-13 08:50:54 UTC (rev 21837)
+++ pcbsd/current/src-sh/pc-updatemanager/pc-updatemanager	2013-03-13 10:54:27 UTC (rev 21838)
@@ -465,6 +465,62 @@
   return 0
 }
 
+download_cache_packages()
+{
+  if [ ! -e "/usr/local/etc/pkg.conf" ] ; then
+    exit_err "No /usr/local/etc/pkg.conf!"
+  fi
+
+  get_mirror 
+  local myMirror="$VAL"
+
+  # Tickle pkg update first
+  pkg-static update
+
+  pkg-static upgrade -L -n ${1} > /tmp/.pkgUpList.$$
+
+  while read line
+  do
+     lTag=`echo $line | awk '{print $1}'` 
+     case $lTag in
+    Upgrading) pkgList="`echo $line | awk '{print $2}' | sed 's|:||g'`-`echo $line | awk '{print $5}'`.txz $pkgList" ;;
+ Reinstalling) pkgList="`echo $line | awk '{print $2}'`.txz $pkgList" ;;
+   Installing) pkgList="`echo $line | awk '{print $2}' | sed 's|:||g'`-`echo $line | awk '{print $3}'`.txz $pkgList" ;;
+                    *) continue ;;
+     esac
+
+  done < /tmp/.pkgUpList.$$
+  rm /tmp/.pkgUpList.$$
+
+  # Get the PKG_CACHEDIR
+  PKG_CACHEDIR="/var/cache/pkg"
+  cat /usr/local/etc/pkg.conf | grep -q "^PKG_CACHEDIR:"
+  if [ $? -eq 0 ] ; then
+    PKG_CACHEDIR="`grep '^PKG_CACHEDIR:' /usr/local/etc/pkg.conf | awk '{print $2}'`"
+  fi
+  if [ -z "$PKG_CACHEDIR" ] ; then
+     exit_err "Failed getting PKG_CACHEDIR"
+  fi
+
+  cat /usr/local/etc/pkg.conf | grep -q "^packagesite:"
+  if [ $? -eq 0 ] ; then
+    pkgUrl="`grep '^packagesite:' /usr/local/etc/pkg.conf | awk '{print $2}' | cut -d '/' -f 4-`"
+  fi
+
+  if [ ! -d "$PKG_CACHEDIR/All" ] ; then
+     mkdir -p ${PKG_CACHEDIR}/All
+  fi
+
+  for i in $pkgList
+  do
+    get_file "${myMirror}/${pkgUrl}/All/${i}" "${PKG_CACHEDIR}/All/${i}"
+    if [ $? -ne 0 ] ; then
+      exit_err "Failed downloading: ${myMirror}/${pkgUrl}/All/${i}"
+    fi
+  done
+}
+
+
 update_pkgs()
 {
   if [ -n "$1" -a "$1" != "-f" ] ; then
@@ -481,16 +537,13 @@
 
     # Wait for QT to open the pipe file
     sleep 5
-
-    # Tickle pkg update first
-    pkg-static update
   fi
 
-  # Check if we need to update "pkg" pkg first
-  pkg-static upgrade -y ${1} pkg 
+  # Lets pre-download all the packages
+  download_cache_packages "$1"
 
   # Start the package update!
-  pkg-static upgrade -y ${1}
+  pkg-static upgrade -L -y ${1}
   result=$?
 
   # Lets now re-extract our overlay data to grab any adjusted port files



More information about the Commits mailing list