-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[rules_apple] add upstream filesystem patches (#13)
this adds [this commit](bazelbuild/rules_apple@306e300) to address this error when copying results files across filesystem boundaries.
- Loading branch information
1 parent
0add154
commit 86b8d2d
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
diff --git a/tools/bundletool/bundletool_experimental.py b/tools/bundletool/bundletool_experimental.py | ||
index 78f4923e..ab6d1d19 100644 | ||
--- a/tools/bundletool/bundletool_experimental.py | ||
+++ b/tools/bundletool/bundletool_experimental.py | ||
@@ -46,21 +46,23 @@ following keys: | ||
bundle is complete but before it is signed. | ||
""" | ||
|
||
+import errno | ||
import filecmp | ||
import json | ||
import os | ||
import shutil | ||
import sys | ||
import zipfile | ||
-from ctypes import cdll, c_char_p, c_int | ||
+from ctypes import CDLL, c_char_p, c_int, get_errno | ||
|
||
_CLONEFILE = None | ||
+_USE_CLONEFILE = sys.platform == "darwin" | ||
def _load_clonefile(): | ||
global _CLONEFILE | ||
if _CLONEFILE: | ||
return _CLONEFILE | ||
|
||
- system = cdll.LoadLibrary('/usr/lib/libSystem.dylib') | ||
+ system = CDLL('/usr/lib/libSystem.dylib', use_errno=True) | ||
_CLONEFILE = system.clonefile | ||
_CLONEFILE.argtypes = [c_char_p, c_char_p, c_int] # src, dest, flags | ||
_CLONEFILE.restype = c_int # 0 on success | ||
@@ -212,11 +214,16 @@ class Bundler(object): | ||
raise BundleConflictError(dest) | ||
|
||
self._makedirs_safely(os.path.dirname(full_dest)) | ||
- if sys.platform == "darwin": | ||
+ global _USE_CLONEFILE | ||
+ if _USE_CLONEFILE: | ||
clonefile = _load_clonefile() | ||
result = clonefile(src.encode(), full_dest.encode(), 0) | ||
if result != 0: | ||
- raise Exception(f"failed to clonefile {src} to {full_dest}") | ||
+ if get_errno() in (errno.EXDEV, errno.ENOTSUP): | ||
+ _USE_CLONEFILE = False | ||
+ shutil.copy(src, full_dest) | ||
+ else: | ||
+ raise Exception(f"failed to clonefile {src} to {full_dest}") | ||
else: | ||
shutil.copy(src, full_dest) | ||
os.chmod(full_dest, 0o755 if executable else 0o644) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters