[PC-BSD Commits] r7592 - pcbsd/current/src-qt4/pbi-manager

svn at pcbsd.org svn at pcbsd.org
Fri Sep 17 12:27:03 PDT 2010


Author: kris
Date: 2010-09-17 12:27:03 -0700 (Fri, 17 Sep 2010)
New Revision: 7592

Modified:
   pcbsd/current/src-qt4/pbi-manager/pbi-manager
Log:

Allow updating via patch files now, still needs testing :)



Modified: pcbsd/current/src-qt4/pbi-manager/pbi-manager
===================================================================
--- pcbsd/current/src-qt4/pbi-manager/pbi-manager	2010-09-17 18:17:23 UTC (rev 7591)
+++ pcbsd/current/src-qt4/pbi-manager/pbi-manager	2010-09-17 19:27:03 UTC (rev 7592)
@@ -2907,6 +2907,7 @@
 	if [ -e "${PBI_APPDIR}/${PBI_INDEXUPFILE}" -a -e "${PBI_APPDIR}/${PBI_INDEXUPTIME}" ] ; then
 		#echo "Fetching diffs to $PBI_INDEXUPFILE"
 		_svnrev=`cat ${PBI_APPDIR}/${PBI_INDEXUPTIME}`
+		#echo "$_svnrev"
 		# Try to get a diff of the file
 		curl --insecure -o ${PBI_TMPDIR}/.upcheck$$ ${PBI_CURLPROXY} \
 			-F "SYSVER=${_ufbsdver}" \
@@ -2942,6 +2943,11 @@
 			fi
 		fi 
 	fi
+	
+	# If our index is still empty, try to grab a fresh copy just to be sure
+	if [ -z "`cat ${PBI_INDEXUPFILE}`" ] ; then
+		_fullUp="0"
+	fi
 
 	# We need to do a full download of the index
 	if [ "$_fullUp" = "0" ] ; then
@@ -2982,6 +2988,7 @@
 
 	PBI_UPNVER=""
 	PBI_UPFILE=""
+	PBI_UPPATCHES=""
 	PBI_UPCSUM=""
 	PBI_UPMDATE=""
 
@@ -2990,6 +2997,7 @@
 
 	PBI_UPNVER="`echo $_upLine | cut -d ':' -f 3`"
 	PBI_UPFILE="`echo $_upLine | cut -d ':' -f 6`"
+	PBI_UPPATCHES="`echo $_upLine | cut -d ':' -f 8`"
 	PBI_UPCSUM="`echo $_upLine | cut -d ':' -f 4`"
 	PBI_UPMDATE="`echo $_upLine | cut -d ':' -f 5`"
 
@@ -3039,6 +3047,9 @@
 
 	# We've gotten this far, now download the updated PBI
 	pbi_update_dl
+	if [ "$?" != "0" ] ; then
+		exit_err "Failed downloading PBI"
+	fi
 
 	# Now overwrite the PBI_FILENAME and let us proceed to regular install
 	PBI_FILENAME="$PBI_UPDLFILE"
@@ -3062,8 +3073,38 @@
 		fi
 	fi
 	
-	# We've gotten this far, now download the updated PBI
+	
+	# Check if there is a possible patch file for this update
+	echo "${PBI_UPPATCHES}" | grep "$PBI_PROGVERSION" >/dev/null 2>/dev/null
+	if [ "$?" = "0" ] ; then
+		# new filename to download
+		_pbilow="`echo ${PBI_PROGNAME} | tr '[:upper:]' '[:lower:]' | sed 's| ||g'`"
+		_pFile="${_pbilow}-${PBI_PROGVERSION}_to_${PBI_UPNVER}-${PBI_APPARCH}.pbp"
+
+		# Try downloading the patch file
+		pbi_update_dl "$_pFile"
+		if [ "$?" = "0" ] ; then
+			# We had a good patch download, try applying it now
+			echo "Updating via patch file..."
+			pbi_patch --licagree "$PBI_UPDLFILE" >/dev/null 2>/dev/null
+			if [ "$?" != "0" ] ; then
+				# Patching failed, we'll grab a fresh copy next
+				echo "Failed to install PBI: ${PBI_UPDLFILE}"
+			else
+				echo "Patch successful!"
+				rm "${PBI_UPDLFILE}"
+				exit_trap
+			fi
+			
+		fi
+	fi
+
+	# No patch file, grab the full app
 	pbi_update_dl
+	if [ "$?" != "0" ] ; then
+		exit_err "Failed downloading update!"
+	fi
+
 	echo " "
 	
 	# Delete the old version, prepare for new
@@ -3084,23 +3125,35 @@
 
 # Start downloading the update
 pbi_update_dl() {
+
+	_tPatch=$1
 	
 	# Set local download location
 	_dl_loc="${PBI_APPDIR}/.`basename $PBI_UPFILE`.$$"
 
+	# Have a patch file to download instead, make that the active file to try
+	if [ ! -z "$_tPatch" ] ; then
+		_bDir=`dirname $PBI_UPFILE`
+		_uFile="${_bDir}/${_tPatch}"
+	else
+		_uFile="${PBI_UPFILE}"
+	fi
+
 	if [ ! -z "$PBI_MIRROR" ] ; then
 		# Start download from default mirror
-		_furl="`echo $PBI_MIRROR | sed 's/\/*$//'`${PBI_UPFILE}"
+		_furl="`echo $PBI_MIRROR | sed 's/\/*$//'`${_uFile}"
 		echo "Downloading ${_furl}"
 		pbi_get_file "$_furl" "$_dl_loc"
 		if [ "$?" != "0" ]  ; then 
 			rm "${_dl_loc}" >/dev/null 2>/dev/null
-			exit_err "Download Failed: ${_furl}"
+			echo "Download Failed: ${_furl}"
+			return 1
 		fi
 		_upcsum=`sha256 -q "$_dl_loc"`
 		if [ "$_upcsum" != "$PBI_UPCSUM" ] ; then
 			rm "${_dl_loc}" >/dev/null 2>/dev/null
-			exit_err "Download Failed: ${_furl}"
+			echo "Download Failed: ${_furl}"
+			return 1
 		fi
 
 	else
@@ -3111,9 +3164,9 @@
 		do
 			# Do download from updater mirrors
 			case $_upattempt in
-				1) _furl="`echo $PBI_PBIMIRROR2 | sed 's/\/*$//'`${PBI_UPFILE}" ;;
-				2) _furl="`echo $PBI_PBIMIRROR3 | sed 's/\/*$//'`${PBI_UPFILE}" ;;
-				3) _furl="`echo $PBI_PBIMIRROR4 | sed 's/\/*$//'`${PBI_UPFILE}" ;;
+				1) _furl="`echo $PBI_PBIMIRROR2 | sed 's/\/*$//'`${_uFile}" ;;
+				2) _furl="`echo $PBI_PBIMIRROR3 | sed 's/\/*$//'`${_uFile}" ;;
+				3) _furl="`echo $PBI_PBIMIRROR4 | sed 's/\/*$//'`${_uFile}" ;;
 			esac
 			echo "Downloading ${_furl}"
 			pbi_get_file "$_furl" "$_dl_loc"
@@ -3130,13 +3183,16 @@
 			_upattempt="`expr $_upattempt + 1`"
 		done
 		if [ "$_gooddl" != "yes" ] ; then
-			exit_err "Download Failed: ${_furl}"
+			echo "Download Failed: ${_furl}"
+			return 1
 		fi
 	fi
 
 	# If we get this far, we have a good file!
 	PBI_UPDLFILE="$_dl_loc"
 	sync
+
+	return 0
 }
 
 # Function to download a file from remote using curl



More information about the Commits mailing list