[PC-BSD Commits] r9465 - pcbsd/current/src-sh/pbi-manager

svn at pcbsd.org svn at pcbsd.org
Thu Mar 3 08:42:36 PST 2011


Author: kris
Date: 2011-03-03 08:42:36 -0800 (Thu, 03 Mar 2011)
New Revision: 9465

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

Added function to cleanup patchdata from failed patch creation



Modified: pcbsd/current/src-sh/pbi-manager/pbi-manager
===================================================================
--- pcbsd/current/src-sh/pbi-manager/pbi-manager	2011-03-03 14:55:02 UTC (rev 9464)
+++ pcbsd/current/src-sh/pbi-manager/pbi-manager	2011-03-03 16:42:36 UTC (rev 9465)
@@ -1447,11 +1447,33 @@
 	echo -e "`basename ${0}`: ${1}"
 	rm_tmpdir
 	rm_buildfiles
+	rm_pbipatchfiles
 	chroot_make_cleanup
 	clean_remote_dl
 	exit 255
 }
 
+# Check if we need to cleanup patch files
+rm_pbipatchfiles
+{
+	if [ -z "${_pbiNewDir}${_pbiOldDir}${_pbiPatchDir}" ] ; then
+		return
+	else
+		echo "Cleaning up patch data..."
+	fi
+
+	if [ ! -z "${_pbiNewDir}" -a -d "${_pbiNewDir}" -a "${_pbiNewDir}" != "/" ] ; then
+	 	rm -rf "${_pbiNewDir}"	
+	fi
+	if [ ! -z "${_pbiOldDir}" -a -d "${_pbiOldDir}" -a "${_pbiOldDir}" != "/" ] ; then
+	 	rm -rf "${_pbiOldDir}"	
+	fi
+	if [ ! -z "${_pbiPatchDir}" -a -d "${_pbiPatchDir}" -a "${_pbiPatchDir}" != "/" ] ; then
+	 	rm -rf "${_pbiPatchDir}"	
+	fi
+
+}
+
 # Check if we need to delete a remotely dl'd file
 clean_remote_dl() {
 	# If this was a remote fetch, remove dl'd file
@@ -4926,9 +4948,6 @@
 	pbi_add -e --licagree -o "${_pbiOldDir}" "${_pbiOld}" >/dev/null 2>/dev/null
 
 	if [ ! -d "${_pbiNewDir}/${_pbiNewPrefix}" -o ! -d "${_pbiOldDir}/${_pbiOldPrefix}" ] ; then 
-		if [ -d "$_pbiNewDir" ] ; then rm -rf "$_pbiNewDir"; fi
-		if [ -d "$_pbiOldDir" ] ; then rm -rf "$_pbiOldDir"; fi
-		if [ -d "$_pbiPatchDir" ] ; then rm -rf "$_pbiPatchDir"; fi
 		exit_err "Failed Extracting PBIs for comparision!"
 	fi
 
@@ -4965,7 +4984,6 @@
 	if test_tar_lzma ; then _tcmp="J" ; else _tcmp="j" ; fi
 	echo "Creating compressed archive..."
 	tar cv${_tcmp}f "${_pbiPatchArchiveFile}" -C ${_pbiPatchDir} . 2>/dev/null 
-	rm -rf ${_pbiPatchDir} 
 
 	# Make the header file
 	if [ -e "$_pbiPatchHeaderDir" ] ; then rm -rf "$_pbiPatchHeaderDir"; fi
@@ -5018,8 +5036,7 @@
         rm ${_pbiPatchArchiveFile}
 	
 	# Cleanup the directories
-	if [ -e "$_pbiNewDir" ] ; then rm -rf "$_pbiNewDir"; fi
-	if [ -e "$_pbiOldDir" ] ; then rm -rf "$_pbiOldDir"; fi
+	rm_pbipatchfiles
 }
 
 # Function which compares two directories, and returns a list of chmod commands to get them in line



More information about the Commits mailing list