[pacman-dev] [PATCH] Allow makepkg to work correctly with busybox find
jhuntwork at lightcubesolutions.com
jhuntwork at lightcubesolutions.com
Thu May 3 20:17:25 EDT 2012
From: Jeremy Huntwork <jhuntwork at lightcubesolutions.com>
Allow makepkg to work correctly when used with find from busybox. The switches
-empty, -samefile and -lname are not available. To replace -samefile, it is
required to collect inode information and compare.
Signed-off-by: Jeremy Huntwork <jhuntwork at lightcubesolutions.com>
---
scripts/makepkg.sh.in | 46 +++++++++++++++++-----------------------------
1 files changed, 17 insertions(+), 29 deletions(-)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index d36dbd6..307d1c1 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -1057,38 +1057,26 @@ 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 file files inode link
+ while read -rd ' ' inode; do
+ read file
+ find ${MAN_DIRS[@]} -type l 2>/dev/null |
+ while read link ; do
+ if [[ "${file}" -ef "${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
+ done
+ if [[ -z ${files[$inode]} ]]; then
+ files[$inode]=$file
+ gzip -9 -f "$file"
+ else
+ rm -f "$file"
+ ln "${files[$inode]}.gz" "${file}.gz"
+ chmod 644 "${file}.gz"
fi
- done
+ done < <(find ${MAN_DIRS[@]} -type f \! -name "*.gz" \! -name "*.bz2" \
+ -exec ls -i '{}' + 2>/dev/null)
fi
if check_option "strip" "y"; then
@@ -1116,7 +1104,7 @@ tidy_install() {
if check_option "emptydirs" "n"; then
msg2 "$(gettext "Removing empty directories...")"
- find . -depth -type d -empty -delete
+ find . -mindepth 1 -depth -type d -exec rmdir '{}' + 2>/dev/null
fi
if check_option "upx" "y"; then
--
1.7.2.2
More information about the pacman-dev
mailing list