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

svn at pcbsd.org svn at pcbsd.org
Thu Nov 4 15:20:21 PDT 2010


Author: kris
Date: 2010-11-04 15:20:21 -0700 (Thu, 04 Nov 2010)
New Revision: 7981

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

Speed up the merging to hash-dir, and also try to speed up pbi_patch
when removing hashdir files



Modified: pcbsd/current/src-sh/pbi-manager/pbi-manager
===================================================================
--- pcbsd/current/src-sh/pbi-manager/pbi-manager	2010-11-04 22:20:06 UTC (rev 7980)
+++ pcbsd/current/src-sh/pbi-manager/pbi-manager	2010-11-04 22:20:21 UTC (rev 7981)
@@ -1090,7 +1090,6 @@
 
 	# Update the hashdir
 	pbi_add_update_hashdir "${PBI_PATCHWRKDIR}"
-	pbi_clean_hashdir
 
 	# Run the install script
 	if [ -e "${PBI_PATCHWRKDIR}/.sbin/.pbi-install.sh" ] ; then
@@ -1168,6 +1167,10 @@
 			mv "${PBI_PATCHWRKDIR}/${_tFile}" "${PBI_PATCHWRKDIR}/${_tFile}.patch.$$"
 			cp "${PBI_PATCHWRKDIR}/${_tFile}.patch.$$" "${PBI_PATCHWRKDIR}/${_tFile}"
 			rm "${PBI_PATCHWRKDIR}/${_tFile}.patch.$$"
+
+			# See if if removing this file leaves any orphan 
+			# hardlinks
+			check_remove_hashfile_fuzzy "${PBI_HASHDIR}/${_tFile}"
         	fi
 		
 		# Now do the patching
@@ -1618,17 +1621,24 @@
 	if [ ! -d "${PBI_HASHDIR}/${dir}" ] ; then
 		mkdir -p ${PBI_HASHDIR}/${dir}
 	fi
+
+	# Check the file sizes, if they differ we can skip diff
+	#if [ "`ls -al ${PBI_HASHDIR}/${tfile} | awk '{ print $5}'`" != "`ls -al ${file} | awk '{ print $5}'`" ] ; then
+	#	if [ "$PBI_VERBOSE" = "YES" ] ; then echo "X" ; fi
+	#	return
+	#fi
+
 	# Confirm that the files are the same
-	diff -q "${file}" "${PBI_HASHDIR}/${tfile}" >/dev/null 2>/dev/null
-	if [ "$?" = "0" ] ; then
-		if [ "$PBI_VERBOSE" = "YES" ] ; then echo "." ; fi
-		ln -f "${PBI_HASHDIR}/${tfile}" "${file}"
-		if [ "$?" != "0" ] ; then exit_err "Critical failure, exiting..."; fi
-	else
-		if [ "$PBI_VERBOSE" = "YES" ] ; then echo "X" ; fi
-		# OK, have two files with same hashes, but still differ
-		# Lets keep the pbi included in the new installed file
-	fi
+	#diff -q "${file}" "${PBI_HASHDIR}/${tfile}" >/dev/null 2>/dev/null
+	#if [ "$?" != "0" ] ; then
+	#	if [ "$PBI_VERBOSE" = "YES" ] ; then echo "X" ; fi
+	#	return
+	#fi
+
+	# Got here, so we have a match!
+	if [ "$PBI_VERBOSE" = "YES" ] ; then echo "." ; fi
+	ln -f "${PBI_HASHDIR}/${tfile}" "${file}"
+	if [ "$?" != "0" ] ; then exit_err "Critical failure, exiting..."; fi
 	
 }
 
@@ -1642,10 +1652,8 @@
 		mkdir -p ${PBI_HASHDIR}/${dir}
 	fi
 
-	mv "${file}" "${PBI_HASHDIR}/${tfile}"
+	ln -f "${file}" "${PBI_HASHDIR}/${tfile}"
 	if [ "$?" != "0" ] ; then exit_err "Critical failure, exiting..."; fi
-	ln -f "${PBI_HASHDIR}/${tfile}" "${file}"
-	if [ "$?" != "0" ] ; then exit_err "Critical failure, exiting..."; fi
 	if [ "$PBI_VERBOSE" = "YES" ] ; then echo "L" ; fi
 }
 
@@ -2619,6 +2627,15 @@
 	pbi_clean_emptyhdirs
 }
 
+# Check a fuzzy file(s) to see if it needs to be removed
+check_remove_hashfile_fuzzy()
+{
+	# Check if these files can be removed 
+	for _fch in `ls ${1}*`
+	do
+		check_remove_hashfile "${_fch}"
+	done
+}
 
 # Check if this hash-file is ready to be removed from the hash-dir
 check_remove_hashfile() {



More information about the Commits mailing list