diff options
author | Russel Winder <russel@winder.org.uk> | 2016-03-01 08:45:42 (GMT) |
---|---|---|
committer | Russel Winder <russel@winder.org.uk> | 2016-03-01 08:45:42 (GMT) |
commit | 14924bcc1713c5bd7dcf4db5b420204407048889 (patch) | |
tree | a679d247d04daf78f0a58ee0bb05afa04488704a /src/engine/SCons | |
parent | 193c96046004369ba13fb9b4fc0e992513cc8f78 (diff) | |
parent | 3791dc82915d61f0b9eee4738fc090c8a23b162c (diff) | |
download | SCons-14924bcc1713c5bd7dcf4db5b420204407048889.zip SCons-14924bcc1713c5bd7dcf4db5b420204407048889.tar.gz SCons-14924bcc1713c5bd7dcf4db5b420204407048889.tar.bz2 |
Resolved conflicting merge.
Diffstat (limited to 'src/engine/SCons')
-rw-r--r-- | src/engine/SCons/Defaults.py | 64 | ||||
-rw-r--r-- | src/engine/SCons/Platform/PlatformTests.py | 20 | ||||
-rw-r--r-- | src/engine/SCons/Platform/posix.py | 6 |
3 files changed, 84 insertions, 6 deletions
diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py index e26a5c0..b198a24 100644 --- a/src/engine/SCons/Defaults.py +++ b/src/engine/SCons/Defaults.py @@ -169,15 +169,73 @@ def get_paths_str(dest): else: return '"' + str(dest) + '"' +permission_dic = { + 'u':{ + 'r':stat.S_IRUSR, + 'w':stat.S_IWUSR, + 'x':stat.S_IXUSR + }, + 'g':{ + 'r':stat.S_IRGRP, + 'w':stat.S_IWGRP, + 'x':stat.S_IXGRP + }, + 'o':{ + 'r':stat.S_IROTH, + 'w':stat.S_IWOTH, + 'x':stat.S_IXOTH + } +} + def chmod_func(dest, mode): + import SCons.Util + from string import digits SCons.Node.FS.invalidate_node_memos(dest) if not SCons.Util.is_List(dest): dest = [dest] - for element in dest: - os.chmod(str(element), mode) + if SCons.Util.is_String(mode) and not 0 in [i in digits for i in mode]: + mode = int(mode, 8) + if not SCons.Util.is_String(mode): + for element in dest: + os.chmod(str(element), mode) + else: + mode = str(mode) + for operation in mode.split(","): + if "=" in operation: + operator = "=" + elif "+" in operation: + operator = "+" + elif "-" in operation: + operator = "-" + else: + raise SyntaxError("Could not find +, - or =") + operation_list = operation.split(operator) + if len(operation_list) is not 2: + raise SyntaxError("More than one operator found") + user = operation_list[0].strip().replace("a", "ugo") + permission = operation_list[1].strip() + new_perm = 0 + for u in user: + for p in permission: + try: + new_perm = new_perm | permission_dic[u][p] + except KeyError: + raise SyntaxError("Unrecognized user or permission format") + for element in dest: + curr_perm = os.stat(str(element)).st_mode + if operator == "=": + os.chmod(str(element), new_perm) + elif operator == "+": + os.chmod(str(element), curr_perm | new_perm) + elif operator == "-": + os.chmod(str(element), curr_perm & ~new_perm) def chmod_strfunc(dest, mode): - return 'Chmod(%s, 0%o)' % (get_paths_str(dest), mode) + import SCons.Util + if not SCons.Util.is_String(mode): + return 'Chmod(%s, 0%o)' % (get_paths_str(dest), mode) + else: + return 'Chmod(%s, "%s")' % (get_paths_str(dest), str(mode)) Chmod = ActionFactory(chmod_func, chmod_strfunc) diff --git a/src/engine/SCons/Platform/PlatformTests.py b/src/engine/SCons/Platform/PlatformTests.py index 38ea55a..3432e94 100644 --- a/src/engine/SCons/Platform/PlatformTests.py +++ b/src/engine/SCons/Platform/PlatformTests.py @@ -187,11 +187,29 @@ class TempFileMungeTestCase(unittest.TestCase): assert cmd != defined_cmd, cmd assert cmd == getattr(target[0].attributes, 'tempfile_cmdlist', None) +class PlatformEscapeTestCase(unittest.TestCase): + def test_posix_escape(self): + """ Check that paths with parens are escaped properly + """ + import SCons.Platform.posix + + test_string = "/my (really) great code/main.cpp" + output = SCons.Platform.posix.escape(test_string) + + # We expect the escape function to wrap the string + # in quotes, but not escape any internal characters + # in the test_string. (Parens doesn't require shell + # escaping if their quoted) + assert output[1:-1] == test_string + + if __name__ == "__main__": suite = unittest.TestSuite() tclasses = [ PlatformTestCase, - TempFileMungeTestCase ] + TempFileMungeTestCase, + PlatformEscapeTestCase, + ] for tclass in tclasses: names = unittest.getTestCaseNames(tclass, 'test_') suite.addTests(list(map(tclass, names))) diff --git a/src/engine/SCons/Platform/posix.py b/src/engine/SCons/Platform/posix.py index 7e69a7c..190a2a6 100644 --- a/src/engine/SCons/Platform/posix.py +++ b/src/engine/SCons/Platform/posix.py @@ -48,16 +48,18 @@ exitvalmap = { } def escape(arg): - "escape shell special characters" + "escape shell special characters" slash = '\\' - special = '"$()' + special = '"$' arg = arg.replace(slash, slash+slash) for c in special: arg = arg.replace(c, slash+c) + # print "ESCAPE RESULT: %s"%arg return '"' + arg + '"' + def exec_subprocess(l, env): proc = subprocess.Popen(l, env = env, close_fds = True) return proc.wait() |