quilt-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Quilt-dev] [PATCH 02/39] BSD compatibility: stat


From: Jean Delvare
Subject: [Quilt-dev] [PATCH 02/39] BSD compatibility: stat
Date: Sat, 19 Mar 2011 10:52:32 +0100
User-agent: quilt/0.48-17.1

The stat command on BSD takes different parameters from the GNU one.
Let configure find out which variant is available, and use the right
parameters.

Signed-off-by: Jean Delvare <address@hidden>
---
 Makefile.in                   |    2 ++
 configure.ac                  |   23 +++++++++++++++++++++++
 quilt/scripts/backup-files.in |    6 +++---
 3 files changed, 28 insertions(+), 3 deletions(-)

--- a/configure.ac
+++ b/configure.ac
@@ -145,6 +145,29 @@ Solaris users can use /usr/xpg4/bin/tr.
 ])
 fi
 
+QUILT_COMPAT_PROG_PATH(STAT, stat)
+
+AC_MSG_CHECKING([whether $STAT -c '%h' works])
+if $STAT -c '%h' /dev/null >/dev/null 2>/dev/null; then
+       AC_MSG_RESULT(yes)
+       STAT_HARDLINK="-c '%h'"
+else
+       AC_MSG_RESULT(no)
+       AC_MSG_CHECKING([whether $STAT -f '%l' works])
+       if $STAT -f '%l' /dev/null >/dev/null 2>/dev/null; then
+               AC_MSG_RESULT(yes)
+               STAT_HARDLINK="-f '%l'"
+       else
+               AC_MSG_RESULT(no)
+               AC_MSG_ERROR([
+Sorry, you have a version of stat which understands neither -c nor -f.
+$PACKAGE_NAME needs it.  If you have access to a version of stat which does
+understand -c or -f, you can supply its path with the '--with-stat=' option.
+])
+       fi
+fi
+AC_SUBST(STAT_HARDLINK)
+
 QUILT_COMPAT_PROG_PATH(SED, sed)
 
 AC_MSG_CHECKING([whether $SED understands (foo|bar)])
--- a/Makefile.in
+++ b/Makefile.in
@@ -41,6 +41,7 @@ RPMBUILD :=   @RPMBUILD@
 SENDMAIL :=    @SENDMAIL@
 
 USE_NLS :=     @USE_NLS@
+STAT_HARDLINK := @STAT_HARDLINK@
 PATCH_WRAPPER := @PATCH_WRAPPER@
 
 CC :=          @CC@
@@ -251,6 +252,7 @@ $(patsubst %.in,%,$(wildcard bin/*.in qu
                -e 's:@PERL''@:$(PERL):g'                               \
                -e 's:@BASH''@:$(BASH):g'                               \
                -e 's:@PATCH''@:$(PATCH):g'                             \
+               -e 's:@STAT_HARDLINK''@:$(STAT_HARDLINK):g'             \
                -e 's:@VERSION''@:$(VERSION):g'                         \
                -e 's:@RELEASE''@:$(RELEASE):g'                         \
                -e 's:@ETCDIR''@:$(etcdir):g'                           \
--- a/quilt/scripts/backup-files.in
+++ b/quilt/scripts/backup-files.in
@@ -66,7 +66,7 @@ ensure_nolinks() {
        local filename="$1"
        local link_count dirname basename tmpname
 
-       link_count=$(stat -c '%h' "$filename")
+       link_count=$(stat @STAT_HARDLINK@ "$filename")
        if [ -z "$link_count" ] || [ "$link_count" -gt 1 ]; then
                dirname=$(dirname "$filename")
                basename=$(basename "$filename")
@@ -92,7 +92,7 @@ process_file() {
                        touch "$backup"
                else
                        $ECHO "Copying $file"
-                       if [ -n "$OPT_NOLINKS" -a "$(stat -c '%h' "$file")" = 
"1" ]; then
+                       if [ -n "$OPT_NOLINKS" -a "$(stat @STAT_HARDLINK@ 
"$file")" = "1" ]; then
                                copy_file "$file" "$backup"
                        else
                                link_or_copy_file "$file" "$backup"
@@ -131,7 +131,7 @@ process_file() {
                        if [ -e "$file" ]; then
                                rm "$file"
                        fi
-                       if [ -n "$OPT_NOLINKS" -a "$(stat -c '%h' "$backup")" 
!= "1" ]; then
+                       if [ -n "$OPT_NOLINKS" -a "$(stat @STAT_HARDLINK@ 
"$backup")" != "1" ]; then
                                copy_file "$backup" "$file"
                        else
                                link_or_copy_file "$backup" "$file"




reply via email to

[Prev in Thread] Current Thread [Next in Thread]