diff options
author | Alon Zakai <alonzakai@gmail.com> | 2014-03-07 15:28:36 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2014-03-07 15:28:36 -0800 |
commit | 019fb8814987e951b46318e22d175186c877b94c (patch) | |
tree | b433b2e2dde624acedb59297d8566e1b7d18a3fa | |
parent | 8b9e832213215111e221880259154cdd255f052e (diff) | |
parent | 0ad0c0266ba30e3d5dc1a01109feb3e22d55964f (diff) |
Merge pull request #2206 from juj/fix_osx_test_preload_file
Resolve symbolic links when checking for destination locations in file_packager. Fixes browser.test_preload_file on OSX.
-rw-r--r-- | tools/file_packager.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/tools/file_packager.py b/tools/file_packager.py index 12cc5475..0ab68511 100644 --- a/tools/file_packager.py +++ b/tools/file_packager.py @@ -113,7 +113,7 @@ for arg in sys.argv[2:]: try: from shared import CRUNCH except Exception, e: - print >> sys.stderr, 'count not import CRUNCH (make sure it is defined properly in ~/.emscripten)' + print >> sys.stderr, 'could not import CRUNCH (make sure it is defined properly in ~/.emscripten)' raise e crunch = arg.split('=')[1] if '=' in arg else '128' leading = '' @@ -123,12 +123,13 @@ for arg in sys.argv[2:]: leading = '' elif leading == 'preload' or leading == 'embed': mode = leading - if '@' in arg: + uses_at_notation = '@' in arg + if uses_at_notation: srcpath, dstpath = arg.split('@') # User is specifying destination filename explicitly. else: srcpath = dstpath = arg # Use source path as destination path. if os.path.isfile(srcpath) or os.path.isdir(srcpath): - data_files.append({ 'srcpath': srcpath, 'dstpath': dstpath, 'mode': mode }) + data_files.append({ 'srcpath': srcpath, 'dstpath': dstpath, 'mode': mode, 'explicit_dst_path': uses_at_notation }) else: print >> sys.stderr, 'Warning: ' + arg + ' does not exist, ignoring.' elif leading == 'exclude': @@ -206,7 +207,7 @@ def add(arg, dirname, names): new_names.append(name) if not os.path.isdir(fullname): dstpath = os.path.join(rootpathdst, os.path.relpath(fullname, rootpathsrc)) # Convert source filename relative to root directory of target FS. - new_data_files.append({ 'srcpath': fullname, 'dstpath': dstpath, 'mode': mode }) + new_data_files.append({ 'srcpath': fullname, 'dstpath': dstpath, 'mode': mode, 'explicit_dst_path': True }) del names[:] names.extend(new_names) @@ -223,13 +224,14 @@ if len(data_files) == 0: sys.exit(1) # Absolutize paths, and check that they make sense -curr_abspath = os.path.abspath(os.getcwd()) +curr_abspath = os.path.abspath(os.getcwd()) # os.getcwd() always returns the hard path with any symbolic links resolved, even if we cd'd into a symbolic link. + for file_ in data_files: - if file_['srcpath'] == file_['dstpath']: + if not file_['explicit_dst_path']: # This file was not defined with src@dst, so we inferred the destination from the source. In that case, # we require that the destination not be under the current location path = file_['dstpath'] - abspath = os.path.abspath(path) + abspath = os.path.realpath(os.path.abspath(path)) # Use os.path.realpath to resolve any symbolic links to hard paths, to match the structure in curr_abspath. if DEBUG: print >> sys.stderr, path, abspath, curr_abspath if not abspath.startswith(curr_abspath): print >> sys.stderr, 'Error: Embedding "%s" which is below the current directory "%s". This is invalid since the current directory becomes the root that the generated code will see' % (path, curr_abspath) |