Darwin7 doesn't have lchown implementation. We only need it for links,
authorFabian Groffen <grobian@gentoo.org>
Mon, 29 Oct 2007 19:54:08 +0000 (19:54 -0000)
committerFabian Groffen <grobian@gentoo.org>
Mon, 29 Oct 2007 19:54:08 +0000 (19:54 -0000)
which on Darwin don't have an owner, so only try that when lchown is
available.

svn path=/main/branches/prefix/; revision=8339

configure.in
src/chpathtool.c

index 5f4bd00aab011b5e5a74e5c3cd21518e685bd303..f7b4987a9fcff5799cf6a0914cc5618915a45e1a 100644 (file)
@@ -133,6 +133,20 @@ AC_TRY_LINK([
                 ]
 )
 
+AC_MSG_CHECKING([if lchown exists])
+AC_TRY_LINK([
+                        #include <sys/types.h>
+                        #include <unistd.h>
+                ], [
+                        lchown("", -1, -1);
+                ], [
+                        AC_DEFINE(HAVE_LCHOWN, 1, [defined when LCHOWN exists])
+                        AC_MSG_RESULT([yes])
+                ], [
+                        AC_MSG_RESULT([no])
+                ]
+)
+
 AC_ARG_ENABLE(tbz2tool,
 AC_HELP_STRING([--enable-tbz2tool],[build tbz2tool, tool for creating binpkgs (default yes)]),
 [case "${enableval}" in
index 0b16bcd6b1da2ce299e6f50f3e321ebdb2607534..04a170a3492c1fe599dc25858cad2de8b2f42b5c 100644 (file)
@@ -251,7 +251,7 @@ int dirwalk(char *src, char *srcp, char *trg, char *trgp) {
                                                trg, strerror(errno));
                                return(-1);
                        }
-                       if (lchown(trg, s.st_uid, s.st_gid) != 0) {
+                       if (chown(trg, s.st_uid, s.st_gid) != 0) {
                                fprintf(stderr, "failed to set ownership of %s: %s\n",
                                                trg, strerror(errno));
                                return(-1);
@@ -307,11 +307,13 @@ int dirwalk(char *src, char *srcp, char *trg, char *trgp) {
                                                src, strerror(errno));
                                return(-1);
                        }
+#ifdef HAVE_LCHOWN
                        if (lchown(trg, s.st_uid, s.st_gid) != 0) {
                                fprintf(stderr, "failed to set ownership of %s: %s\n",
                                                trg, strerror(errno));
                                return(-1);
                        }
+#endif
                }
 
                /* restore modified path */
@@ -331,7 +333,7 @@ int dirwalk(char *src, char *srcp, char *trg, char *trgp) {
                                trg, strerror(errno));
                return(-1);
        }
-       if (lchown(trg, s.st_uid, s.st_gid) != 0) {
+       if (chown(trg, s.st_uid, s.st_gid) != 0) {
                fprintf(stderr, "failed to set ownership of %s: %s\n",
                                trg, strerror(errno));
                return(-1);