[pacman-dev] [PATCH] Allow makepkg to use busybox find

jhuntwork at lightcubesolutions.com jhuntwork at lightcubesolutions.com
Thu May 3 03:29:08 EDT 2012


From: Jeremy Huntwork <jhuntwork at lightcubesolutions.com>

This is an updated version to the previous patch which had a misplaced -o
option and a misformatted line.

Allow makepkg to work correctly when used with find from busybox. The switches
-empty, -samefile and -lname are not available. It is easy to work around
-empty with rmdir, and -lname with readlink. However, -samefile functionality
requires tracking and storing inodes to ensure hard links are re-created
correctly.

Signed-off-by: Jeremy Huntwork <jhuntwork at lightcubesolutions.com>
---
 scripts/makepkg.sh.in |   53 ++++++++++++++++++++++--------------------------
 1 files changed, 24 insertions(+), 29 deletions(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index d36dbd6..acf9c99 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -1057,37 +1057,32 @@ tidy_install() {
 
 	if check_option "zipman" "y" && [[ -n ${MAN_DIRS[*]} ]]; then
 		msg2 "$(gettext "Compressing man and info pages...")"
-		local manpage ext file link hardlinks hl
-		find ${MAN_DIRS[@]} -type f 2>/dev/null |
-		while read manpage ; do
-			ext="${manpage##*.}"
-			file="${manpage##*/}"
-			if [[ $ext != gz && $ext != bz2 ]]; then
-				# update symlinks to this manpage
-				find ${MAN_DIRS[@]} -lname "$file" 2>/dev/null |
-				while read link ; do
+		local manpages inode files link
+		#   the '|| true' part keeps the script from bailing on the EOF returned
+		#   by read at the end of the find output
+		IFS=$'\n' read -rd '' -a files < \
+			<(find ${MAN_DIRS[@]} \! -name "*.bz2" \! -name "*.gz" \
+				-type f 2>/dev/null || true) || true
+		for file in ${files[@]} ; do
+			# Track inodes so hard links can be identified and removed
+			inode=`stat -c %i ${file}`
+			if [ -z ${manpages[$inode]} ] ; then
+				manpages[$inode]="$file"
+				gzip -9 "$file"
+			else
+				rm -f "$file"
+				ln "${manpages[$inode]}.gz" "${file}.gz"
+				chmod 644 "${file}.gz"
+			fi
+			# update any symlinks to this manpage
+			file="${file##*/}"
+			find ${MAN_DIRS[@]} -type l 2>/dev/null |
+			while read link ; do
+				if [ "${file}" = "`readlink ${link}`" ] ; then
 					rm -f "$link" "${link}.gz"
 					ln -s -- "${file}.gz" "${link}.gz"
-				done
-
-				# check file still exists (potentially already compressed due to hardlink)
-				if [[ -f ${manpage} ]]; then
-					# find hard links and remove them
-					#   the '|| true' part keeps the script from bailing on the EOF returned
-					#   by read at the end of the find output
-					IFS=$'\n' read -rd '' -a hardlinks < \
-						<(find ${MAN_DIRS[@]} \! -name "$file" -samefile "$manpage" \
-								2>/dev/null || true) || true
-					rm -f "${hardlinks[@]}"
-					# compress the original
-					gzip -9 "$manpage"
-					# recreate hard links removed earlier
-					for hl in "${hardlinks[@]}"; do
-						ln "${manpage}.gz" "${hl}.gz"
-						chmod 644 ${hl}.gz
-					done
 				fi
-			fi
+			done
 		done
 	fi
 
@@ -1116,7 +1111,7 @@ tidy_install() {
 
 	if check_option "emptydirs" "n"; then
 		msg2 "$(gettext "Removing empty directories...")"
-		find . -depth -type d -empty -delete
+		find . -depth -mindepth 1 -type d -exec rmdir --ignore-fail-on-non-empty '{}' +
 	fi
 
 	if check_option "upx" "y"; then
-- 
1.7.2.2



More information about the pacman-dev mailing list