Portability fixes for makepkg

Allow makepkg to work correctly when used with find from busybox.
Fix handling of cross directory symlinks.

Signed-off-by: Jeremy Huntwork <jhuntwork@lightcubesolutions.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
Jeremy Huntwork 2012-05-23 03:18:42 +00:00 committed by Dan McGee
parent da0dcc29cf
commit 19c2347507
3 changed files with 28 additions and 29 deletions

View File

@ -287,6 +287,7 @@ GCC_VISIBILITY_CC
GCC_GNU89_INLINE_CC GCC_GNU89_INLINE_CC
# Host-dependant definitions # Host-dependant definitions
INODECMD="stat -c '%i %n'"
SIZECMD="stat -c %s" SIZECMD="stat -c %s"
SEDINPLACE="sed -i" SEDINPLACE="sed -i"
STRIP_BINARIES="--strip-all" STRIP_BINARIES="--strip-all"
@ -294,6 +295,7 @@ STRIP_SHARED="--strip-unneeded"
STRIP_STATIC="--strip-debug" STRIP_STATIC="--strip-debug"
case "${host_os}" in case "${host_os}" in
*bsd*) *bsd*)
INODECMD="stat -f '%i %n'"
SIZECMD="stat -f %z" SIZECMD="stat -f %z"
SEDINPLACE="sed -i \"\"" SEDINPLACE="sed -i \"\""
;; ;;
@ -303,6 +305,7 @@ case "${host_os}" in
;; ;;
darwin*) darwin*)
host_os_darwin=yes host_os_darwin=yes
INODECMD="/usr/bin/stat -f '%i %n'"
SIZECMD="/usr/bin/stat -f %z" SIZECMD="/usr/bin/stat -f %z"
SEDINPLACE="/usr/bin/sed -i ''" SEDINPLACE="/usr/bin/sed -i ''"
STRIP_BINARIES="" STRIP_BINARIES=""
@ -314,6 +317,7 @@ esac
AM_CONDITIONAL([CYGWIN], test "x$host_os_cygwin" = "xyes") AM_CONDITIONAL([CYGWIN], test "x$host_os_cygwin" = "xyes")
AM_CONDITIONAL([DARWIN], test "x$host_os_darwin" = "xyes") AM_CONDITIONAL([DARWIN], test "x$host_os_darwin" = "xyes")
AC_PATH_PROGS([DUPATH], [du], [du], [/usr/bin$PATH_SEPARATOR/bin] ) AC_PATH_PROGS([DUPATH], [du], [du], [/usr/bin$PATH_SEPARATOR/bin] )
AC_SUBST(INODECMD)
AC_SUBST(SIZECMD) AC_SUBST(SIZECMD)
AC_SUBST(SEDINPLACE) AC_SUBST(SEDINPLACE)
AC_SUBST(STRIP_BINARIES) AC_SUBST(STRIP_BINARIES)
@ -487,6 +491,7 @@ ${PACKAGE_NAME}:
Architecture : ${CARCH} Architecture : ${CARCH}
Host Type : ${CHOST} Host Type : ${CHOST}
File inode command : ${INODECMD}
Filesize command : ${SIZECMD} Filesize command : ${SIZECMD}
In-place sed command : ${SEDINPLACE} In-place sed command : ${SEDINPLACE}

View File

@ -51,6 +51,7 @@ edit = sed \
-e 's|@PACKAGE_BUGREPORT[@]|$(PACKAGE_BUGREPORT)|g' \ -e 's|@PACKAGE_BUGREPORT[@]|$(PACKAGE_BUGREPORT)|g' \
-e 's|@PACKAGE_NAME[@]|$(PACKAGE_NAME)|g' \ -e 's|@PACKAGE_NAME[@]|$(PACKAGE_NAME)|g' \
-e 's|@BUILDSCRIPT[@]|$(BUILDSCRIPT)|g' \ -e 's|@BUILDSCRIPT[@]|$(BUILDSCRIPT)|g' \
-e "s|@INODECMD[@]|$(INODECMD)|g" \
-e 's|@SIZECMD[@]|$(SIZECMD)|g' \ -e 's|@SIZECMD[@]|$(SIZECMD)|g' \
-e 's|@SEDINPLACE[@]|$(SEDINPLACE)|g' \ -e 's|@SEDINPLACE[@]|$(SEDINPLACE)|g' \
-e 's|@DUPATH[@]|$(DUPATH)|g' \ -e 's|@DUPATH[@]|$(DUPATH)|g' \

View File

@ -1057,37 +1057,30 @@ tidy_install() {
if check_option "zipman" "y" && [[ -n ${MAN_DIRS[*]} ]]; then if check_option "zipman" "y" && [[ -n ${MAN_DIRS[*]} ]]; then
msg2 "$(gettext "Compressing man and info pages...")" msg2 "$(gettext "Compressing man and info pages...")"
local manpage ext file link hardlinks hl local file files inode link
find ${MAN_DIRS[@]} -type f 2>/dev/null | while read -rd ' ' inode; do
while read manpage ; do read file
ext="${manpage##*.}" find ${MAN_DIRS[@]} -type l 2>/dev/null |
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 while read link ; do
if [[ "${file}" -ef "${link}" ]] ; then
rm -f "$link" "${link}.gz" rm -f "$link" "${link}.gz"
ln -s -- "${file}.gz" "${link}.gz" if [[ ${file%/*} = ${link%/*} ]]; then
done ln -s -- "${file##*/}.gz" "${link}.gz"
else
# check file still exists (potentially already compressed due to hardlink) ln -s -- "/${file}.gz" "${link}.gz"
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
mapfile -t hardlinks < \
<(find ${MAN_DIRS[@]} ! -name "$file" -samefile "$manpage" 2>/dev/null)
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
fi fi
done 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 < <(find ${MAN_DIRS[@]} -type f \! -name "*.gz" \! -name "*.bz2" \
-exec @INODECMD@ '{}' + 2>/dev/null)
fi fi
if check_option "strip" "y"; then if check_option "strip" "y"; then
@ -1115,7 +1108,7 @@ tidy_install() {
if check_option "emptydirs" "n"; then if check_option "emptydirs" "n"; then
msg2 "$(gettext "Removing empty directories...")" msg2 "$(gettext "Removing empty directories...")"
find . -depth -type d -empty -delete find . -depth -type d -exec rmdir '{}' + 2>/dev/null
fi fi
if check_option "upx" "y"; then if check_option "upx" "y"; then