aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2018-08-16 04:12:29 +0200
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2018-08-17 16:41:09 +0200
commit2d010727ed6657cb53d5043032417e0a9035e117 (patch)
treed8ff48e0acfbc43a517e1ca8b56f7a7595ef145e
parent9f87d5d95545c29a1242a05c4db9ea7253a57ab6 (diff)
downloadmeson-2d010727ed6657cb53d5043032417e0a9035e117.zip
meson-2d010727ed6657cb53d5043032417e0a9035e117.tar.gz
meson-2d010727ed6657cb53d5043032417e0a9035e117.tar.bz2
minstall: never try to set chmod on symlinks
It's only supported by few platforms when the linked file exists, while it would cause an error otherwise. In any case just implement this via an helper set_chmod function that will handle the case where follow_symlinks is not supported by the platform and will just not set any mod for the link itself (as it would otherwise apply to the linked file). Fixes #3914
-rw-r--r--mesonbuild/minstall.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/mesonbuild/minstall.py b/mesonbuild/minstall.py
index f08a6b3..5ac1279 100644
--- a/mesonbuild/minstall.py
+++ b/mesonbuild/minstall.py
@@ -79,13 +79,20 @@ def append_to_log(lf, line):
lf.write('\n')
lf.flush()
+def set_chmod(path, mode, dir_fd=None, follow_symlinks=True):
+ try:
+ os.chmod(path, mode, dir_fd=dir_fd, follow_symlinks=follow_symlinks)
+ except (NotImplementedError, OSError, SystemError) as e:
+ if not os.path.islink(path):
+ os.chmod(path, mode, dir_fd=dir_fd)
+
def sanitize_permissions(path, umask):
if umask is None:
return
new_perms = 0o777 if is_executable(path) else 0o666
new_perms &= ~umask
try:
- os.chmod(path, new_perms)
+ set_chmod(path, new_perms, follow_symlinks=False)
except PermissionError as e:
msg = '{!r}: Unable to set permissions {!r}: {}, ignoring...'
print(msg.format(path, new_perms, e.strerror))
@@ -116,7 +123,7 @@ def set_mode(path, mode, default_umask):
# NOTE: On Windows you can set read/write perms; the rest are ignored
if mode.perms_s is not None:
try:
- os.chmod(path, mode.perms)
+ set_chmod(path, mode.perms, follow_symlinks=False)
except PermissionError as e:
msg = '{!r}: Unable to set permissions {!r}: {}, ignoring...'
print(msg.format(path, mode.perms_s, e.strerror))