[pacman-dev] [PATCH] Portability fixes for makepkg
From: Jeremy Huntwork <jhuntwork@lightcubesolutions.com> Update to last patch submitted to use a templated stat command instead of ls to collect inodes. 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@lightcubesolutions.com> --- configure.ac | 5 +++++ scripts/Makefile.am | 1 + scripts/makepkg.sh.in | 46 +++++++++++++++++----------------------------- 3 files changed, 23 insertions(+), 29 deletions(-) diff --git a/configure.ac b/configure.ac index 15e93e7..5483ee1 100644 --- a/configure.ac +++ b/configure.ac @@ -287,6 +287,7 @@ GCC_VISIBILITY_CC GCC_GNU89_INLINE_CC # Host-dependant definitions +INODECMD="stat -c '%i %n'" SIZECMD="stat -c %s" SEDINPLACE="sed -i" STRIP_BINARIES="--strip-all" @@ -294,6 +295,7 @@ STRIP_SHARED="--strip-unneeded" STRIP_STATIC="--strip-debug" case "${host_os}" in *bsd*) + INODECMD="stat -f '%i %n'" SIZECMD="stat -f %z" SEDINPLACE="sed -i \"\"" ;; @@ -303,6 +305,7 @@ case "${host_os}" in ;; darwin*) host_os_darwin=yes + INODECMD="/usr/bin/stat -f '%i %n'" SIZECMD="/usr/bin/stat -f %z" SEDINPLACE="/usr/bin/sed -i ''" STRIP_BINARIES="" @@ -314,6 +317,7 @@ esac AM_CONDITIONAL([CYGWIN], test "x$host_os_cygwin" = "xyes") AM_CONDITIONAL([DARWIN], test "x$host_os_darwin" = "xyes") AC_PATH_PROGS([DUPATH], [du], [du], [/usr/bin$PATH_SEPARATOR/bin] ) +AC_SUBST(INODECMD) AC_SUBST(SIZECMD) AC_SUBST(SEDINPLACE) AC_SUBST(STRIP_BINARIES) @@ -487,6 +491,7 @@ ${PACKAGE_NAME}: Architecture : ${CARCH} Host Type : ${CHOST} + File inode command : ${INODECMD} Filesize command : ${SIZECMD} In-place sed command : ${SEDINPLACE} diff --git a/scripts/Makefile.am b/scripts/Makefile.am index a1a4f36..8d1a9e5 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -49,6 +49,7 @@ edit = sed \ -e 's|@PACKAGE_BUGREPORT[@]|$(PACKAGE_BUGREPORT)|g' \ -e 's|@PACKAGE_NAME[@]|$(PACKAGE_NAME)|g' \ -e 's|@BUILDSCRIPT[@]|$(BUILDSCRIPT)|g' \ + -e "s|@INODECMD[@]|$(INODECMD)|g" \ -e 's|@SIZECMD[@]|$(SIZECMD)|g' \ -e 's|@SEDINPLACE[@]|$(SEDINPLACE)|g' \ -e 's|@DUPATH[@]|$(DUPATH)|g' \ diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index d36dbd6..7999760 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 @INODECMD@ '{}' + 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
On 04/05/12 11:49, jhuntwork@lightcubesolutions.com wrote:
From: Jeremy Huntwork <jhuntwork@lightcubesolutions.com>
Update to last patch submitted to use a templated stat command instead of ls to collect inodes.
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@lightcubesolutions.com> ---
ls -lR pkg/usr/share/man/
This patch failed on the first package I tested it on... ==> Finished making: gimp 2.8.0-1 (Tue May 8 18:03:05 EST 2012) pkg/usr/share/man/: total 8 drwxr-xr-x 2 allan allan 4096 May 8 18:02 man1 drwxr-xr-x 2 allan allan 4096 May 8 18:02 man5 pkg/usr/share/man/man1: total 12 lrwxrwxrwx 1 allan allan 32 May 8 18:02 gimp.1.gz -> usr/share/man/man1/gimp-2.8.1.gz -rw-r--r-- 1 allan allan 4531 May 8 18:02 gimp-2.8.1.gz lrwxrwxrwx 1 allan allan 21 May 8 18:02 gimp-console.1.gz -> gimp-console-2.8.1.gz lrwxrwxrwx 1 allan allan 32 May 8 18:02 gimp-console-2.8.1.gz -> usr/share/man/man1/gimp-2.8.1.gz lrwxrwxrwx 1 allan allan 17 May 8 18:02 gimptool.1.gz -> gimptool-2.0.1.gz -rw-r--r-- 1 allan allan 2098 May 8 18:02 gimptool-2.0.1.gz pkg/usr/share/man/man5: total 8 -rw-r--r-- 1 allan allan 7000 May 8 18:02 gimprc-2.8.5.gz lrwxrwxrwx 1 allan allan 34 May 8 18:02 gimprc.5.gz -> usr/share/man/man5/gimprc-2.8.5.gz This looks quite similar to the issue fixed in https://bugs.archlinux.org/task/18568 (which is the reason I picked this package to test with...) but I have not looked into it further to confirm. Allan
On 5/8/12 4:16 AM, Allan McRae wrote:
ls -lR pkg/usr/share/man/ pkg/usr/share/man/: total 8 drwxr-xr-x 2 allan allan 4096 May 8 18:02 man1 drwxr-xr-x 2 allan allan 4096 May 8 18:02 man5
pkg/usr/share/man/man1: total 12 lrwxrwxrwx 1 allan allan 32 May 8 18:02 gimp.1.gz -> usr/share/man/man1/gimp-2.8.1.gz -rw-r--r-- 1 allan allan 4531 May 8 18:02 gimp-2.8.1.gz lrwxrwxrwx 1 allan allan 21 May 8 18:02 gimp-console.1.gz -> gimp-console-2.8.1.gz lrwxrwxrwx 1 allan allan 32 May 8 18:02 gimp-console-2.8.1.gz -> usr/share/man/man1/gimp-2.8.1.gz lrwxrwxrwx 1 allan allan 17 May 8 18:02 gimptool.1.gz -> gimptool-2.0.1.gz -rw-r--r-- 1 allan allan 2098 May 8 18:02 gimptool-2.0.1.gz
pkg/usr/share/man/man5: total 8 -rw-r--r-- 1 allan allan 7000 May 8 18:02 gimprc-2.8.5.gz lrwxrwxrwx 1 allan allan 34 May 8 18:02 gimprc.5.gz -> usr/share/man/man5/gimprc-2.8.5.gz
Sorry, but the failure here isn't obvious to me. Is it that gimp-console-2.8.1.gz is symlinked to gimp-2.8.1.gz? What does the directory structure look like before compression? JH
On Tue, May 8, 2012 at 9:53 AM, Jeremy Huntwork <jhuntwork@lightcubesolutions.com> wrote:
On 5/8/12 4:16 AM, Allan McRae wrote:
ls -lR pkg/usr/share/man/
pkg/usr/share/man/: total 8 drwxr-xr-x 2 allan allan 4096 May 8 18:02 man1 drwxr-xr-x 2 allan allan 4096 May 8 18:02 man5
pkg/usr/share/man/man1: total 12 lrwxrwxrwx 1 allan allan 32 May 8 18:02 gimp.1.gz -> usr/share/man/man1/gimp-2.8.1.gz -rw-r--r-- 1 allan allan 4531 May 8 18:02 gimp-2.8.1.gz lrwxrwxrwx 1 allan allan 21 May 8 18:02 gimp-console.1.gz -> gimp-console-2.8.1.gz lrwxrwxrwx 1 allan allan 32 May 8 18:02 gimp-console-2.8.1.gz -> usr/share/man/man1/gimp-2.8.1.gz lrwxrwxrwx 1 allan allan 17 May 8 18:02 gimptool.1.gz -> gimptool-2.0.1.gz -rw-r--r-- 1 allan allan 2098 May 8 18:02 gimptool-2.0.1.gz
pkg/usr/share/man/man5: total 8 -rw-r--r-- 1 allan allan 7000 May 8 18:02 gimprc-2.8.5.gz lrwxrwxrwx 1 allan allan 34 May 8 18:02 gimprc.5.gz -> usr/share/man/man5/gimprc-2.8.5.gz
Sorry, but the failure here isn't obvious to me. Is it that gimp-console-2.8.1.gz is symlinked to gimp-2.8.1.gz?
What does the directory structure look like before compression?
It looks to me like it is symlinked to a relative path that makes no sense; e.g., will be resolved like this: /usr/share/man/man1/gimp-console-2.8.1.gz -> /usr/share/man/man1/usr/share/man/man1/gimp-2.8.1.gz -Dan
On 5/8/12 10:57 AM, Dan McGee wrote:
It looks to me like it is symlinked to a relative path that makes no sense; e.g., will be resolved like this: /usr/share/man/man1/gimp-console-2.8.1.gz -> /usr/share/man/man1/usr/share/man/man1/gimp-2.8.1.gz
Ah, thanks - I'll dig in a bit. JH
participants (4)
-
Allan McRae
-
Dan McGee
-
Jeremy Huntwork
-
jhuntwork@lightcubesolutions.com