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

svn at pcbsd.org svn at pcbsd.org
Thu Sep 16 07:18:31 PDT 2010


Author: kris
Date: 2010-09-16 07:18:31 -0700 (Thu, 16 Sep 2010)
New Revision: 7575

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

Also make sure we save any changed permissions between the two versions for PBI patches



Modified: pcbsd/current/src-qt4/pbi-manager/pbi-manager
===================================================================
--- pcbsd/current/src-qt4/pbi-manager/pbi-manager	2010-09-16 14:11:50 UTC (rev 7574)
+++ pcbsd/current/src-qt4/pbi-manager/pbi-manager	2010-09-16 14:18:31 UTC (rev 7575)
@@ -2972,7 +2972,7 @@
 	gen_rem_list "$_pbiNewDir/$_pbiNewPrefix" "$_pbiOldDir/$_pbiOldPrefix"
 	_rFileList="$VAL"
 	if [ ! -z "$_rFileList" ] ; then
-		echo "Saving removed file list"
+		echo "Saving removed file list..."
 		mv "${_rFileList}" ${_pbiPatchDir}/PBI-rmList
 	fi
 
@@ -2986,6 +2986,14 @@
 		rm "$_nFileList"
 	fi
 
+	# Get a listing of permissions
+	gen_chmod_list "$_pbiNewDir/$_pbiNewPrefix" "$_pbiOldDir/$_pbiOldPrefix"
+	_cFileList="$VAL"
+	if [ ! -z "$_cFileList" ] ; then
+		echo "Saving permissions list..."
+		mv "${_cFileList}" ${_pbiPatchDir}/PBI-permList
+	fi
+
 	# Generate diffs of files which have changed between the two
 	gen_bsdiffs_dirs "$_pbiNewDir/$_pbiNewPrefix" "$_pbiOldDir/$_pbiOldPrefix" "$_pbiPatchDir"
 
@@ -3047,6 +3055,52 @@
 	if [ -e "$_pbiOldDir" ] ; then rm -rf "$_pbiOldDir"; fi
 }
 
+# Function which compares two directories, and returns a list of chmod commands to get them in line
+gen_chmod_list() {
+
+	_chList="/tmp/.pbi.chList.$$"
+	if [ -e "$_chList" ] ; then rm "$_chList" ; fi
+
+	find ${1} | sed "s|^${1}/||g" | sed "s|^${1}||g" >/tmp/.pbi.nDir.$$
+
+	echo "Getting permissions of changed files..."
+
+	while read line
+	do
+		# Make sure this file exists in the new / old dirs
+		if [ -z "$line" ] ; then continue ; fi
+		if [ ! -f "${1}/$line" ] ; then continue ; fi
+		if [ ! -e "${2}/$line" ] ; then continue ; fi
+
+		# Filter out any special files, we don't need diffs of them
+		if [ -L "${1}/$line" ] ; then continue ; fi
+		if [ -p "${1}/$line" ] ; then continue ; fi
+		if [ -S "${1}/$line" ] ; then continue ; fi
+		if [ -d "${1}/$line" ] ; then continue ; fi
+		if [ -b "${1}/$line" ] ; then continue ; fi
+		if [ -c "${1}/$line" ] ; then continue ; fi
+
+		_newPerm=`stat -f %Op "${1}/$line"  | cut -c 3-6`
+		_oldPerm=`stat -f %Op "${1}/$line"  | cut -c 3-6`
+		if [ "$_newPerm" != "$_oldPerm" ] ; then
+			# We have new permissions! Lets be sure to save them
+			echo "chmod $_newPerm $line" >> $_chList
+		fi
+
+	done < /tmp/.pbi.nDir.$$
+
+	# Remove the tmp list files
+	rm /tmp/.pbi.nDir.$$
+
+	if [ -e "$_chList" ] ; then
+		VAL="$_chList"
+	else
+		VAL=""
+	fi
+}
+
+
+
 # Function which compares two directories, and returns a list of files / dirs removed in the new dir
 gen_bsdiffs_dirs() {
 



More information about the Commits mailing list