<pre style='margin:0'>
Rainer Müller (raimue) pushed a commit to branch release-2.4
in repository macports-base.

</pre>
<p><a href="https://github.com/macports/macports-base/commit/7b2cf6ce8cb2337dc50d9a304a258c37bd964003">https://github.com/macports/macports-base/commit/7b2cf6ce8cb2337dc50d9a304a258c37bd964003</a></p>
<pre style="white-space: pre; background: #F8F8F8">The following commit(s) were added to refs/heads/release-2.4 by this push:
<span style='display:block; white-space:pre;color:#404040;'>     new 7b2cf6c  sip_copy_proc: Use copyfile(3) in sip-workaround
</span>7b2cf6c is described below

<span style='display:block; white-space:pre;color:#808000;'>commit 7b2cf6ce8cb2337dc50d9a304a258c37bd964003
</span>Author: Rainer Müller <raimue@macports.org>
AuthorDate: Tue Jul 11 22:09:38 2017 +0200

<span style='display:block; white-space:pre;color:#404040;'>    sip_copy_proc: Use copyfile(3) in sip-workaround
</span><span style='display:block; white-space:pre;color:#404040;'>    
</span><span style='display:block; white-space:pre;color:#404040;'>    Use copyfile(3) to copy binaries to the sip-workaround location. If the
</span><span style='display:block; white-space:pre;color:#404040;'>    filesystem supports it (such as APFS), the flag COPYFILE_CLONE is
</span><span style='display:block; white-space:pre;color:#404040;'>    supposed to share the underlying filesystem blocks as copy-on-write,
</span><span style='display:block; white-space:pre;color:#404040;'>    therefore reducing required disk space and runtime. If this is not
</span><span style='display:block; white-space:pre;color:#404040;'>    possible, it will just fallback to a normal copy operation.
</span><span style='display:block; white-space:pre;color:#404040;'>    
</span><span style='display:block; white-space:pre;color:#404040;'>    copyfile(3) is available on Mac OS X >= 10.5 Leopard. The previous
</span><span style='display:block; white-space:pre;color:#404040;'>    implementation will be used for compatibility with older releases.
</span><span style='display:block; white-space:pre;color:#404040;'>    
</span><span style='display:block; white-space:pre;color:#404040;'>    (cherry picked from commit 3d4c9b342d28abd0b7aaf7eb70fa4862e898542c)
</span>---
 src/pextlib1.0/sip_copy_proc.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/pextlib1.0/sip_copy_proc.c b/src/pextlib1.0/sip_copy_proc.c
</span><span style='display:block; white-space:pre;color:#808080;'>index 4de428f..b60f975 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/pextlib1.0/sip_copy_proc.c
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/pextlib1.0/sip_copy_proc.c
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -46,9 +46,14 @@
</span> #include <sys/uio.h>
 #include <unistd.h>
 
<span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <config.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#ifdef HAVE_COPYFILE
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#include <copyfile.h>
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> #include "sip_copy_proc.h"
 
<span style='display:block; white-space:pre;background:#ffe0e0;'>-#include <config.h>
</span> #ifndef DARWINTRACE_SIP_WORKAROUND_PATH
 #warning No value for DARWINTRACE_SIP_WORKAROUND_PATH found in config.h, using default of /tmp/macports-sip, which will fail unless you create it with mode 01777
 #define DARWINTRACE_SIP_WORKAROUND_PATH "/tmp/macports-sip"
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -327,6 +332,24 @@ static char *lazy_copy(const char *path, struct stat *in_st) {
</span>         goto lazy_copy_out;
     }
 
<span style='display:block; white-space:pre;background:#e0ffe0;'>+#ifdef HAVE_COPYFILE
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    // as copyfile(3) is not guaranteed to be atomic, copy to a temporary file first
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    if (mktemp(target_path_temp) == NULL) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+        fprintf(stderr, "sip_copy_proc: mktemp(%s): %s\n", target_path_temp, strerror(errno));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+        goto lazy_copy_out;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    // copyfile(3)/clonefile(2) will not preserve SF_RESTRICTED,
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    // we can safely clone the source file with all metadata
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    copyfile_flags_t flags = COPYFILE_ALL;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#ifdef COPYFILE_CLONE
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    flags = COPYFILE_CLONE;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    if (copyfile(path, target_path_temp, NULL, flags) != 0) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+        fprintf(stderr, "sip_copy_proc: copyfile(%s, %s): %s\n", path, target_path_temp, strerror(errno));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+        goto lazy_copy_out;
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+    }
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#else /* !HAVE_COPYFILE */
</span>     // create temporary file to copy into and then later atomically replace
     // target file
     if (-1 == (outfd = mkstemp(target_path_temp))) {
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -394,6 +417,7 @@ static char *lazy_copy(const char *path, struct stat *in_st) {
</span>         fprintf(stderr, "sip_copy_proc: futimes(%s): %s\n", target_path_temp, strerror(errno));
         goto lazy_copy_out;
     }
<span style='display:block; white-space:pre;background:#e0ffe0;'>+#endif /* HAVE_COPYFILE */
</span> 
     if (-1 == rename(target_path_temp, target_path)) {
         fprintf(stderr, "sip_copy_proc: rename(%s, %s): %s\n", target_path_temp, target_path, strerror(errno));
</pre><pre style='margin:0'>

</pre>