summaryrefslogtreecommitdiffstats
path: root/build
diff options
context:
space:
mode:
authormostynb <mostynb@opera.com>2016-01-30 11:03:21 -0800
committerCommit bot <commit-bot@chromium.org>2016-01-30 19:04:26 +0000
commitb5b49118799533bb4066d98d97990d3a7d60e7aa (patch)
treec6938365475d8b5246c578157bcf6c9ca965d526 /build
parent7ad924ce5484c0f8d43818ba48f4bfe87a53ea67 (diff)
downloadchromium_src-b5b49118799533bb4066d98d97990d3a7d60e7aa.zip
chromium_src-b5b49118799533bb4066d98d97990d3a7d60e7aa.tar.gz
chromium_src-b5b49118799533bb4066d98d97990d3a7d60e7aa.tar.bz2
support symlinks in zip files in build_utils.ExtractAll
Without this, extracting zip files which contain symlinks does not work- instead of creating symlinks, regular files are written with the symlink target. Review URL: https://codereview.chromium.org/1641703002 Cr-Commit-Position: refs/heads/master@{#372557}
Diffstat (limited to 'build')
-rw-r--r--build/android/gyp/util/build_utils.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/build/android/gyp/util/build_utils.py b/build/android/gyp/util/build_utils.py
index c601e06..da6e4cf 100644
--- a/build/android/gyp/util/build_utils.py
+++ b/build/android/gyp/util/build_utils.py
@@ -11,6 +11,7 @@ import pipes
import re
import shlex
import shutil
+import stat
import subprocess
import sys
import tempfile
@@ -209,6 +210,14 @@ def CheckZipPath(name):
raise Exception('Absolute zip path: %s' % name)
+def IsSymlink(zip_file, name):
+ zi = zip_file.getinfo(name)
+
+ # The two high-order bytes of ZipInfo.external_attr represent
+ # UNIX permissions and file type bits.
+ return stat.S_ISLNK(zi.external_attr >> 16L)
+
+
def ExtractAll(zip_path, path=None, no_clobber=True, pattern=None,
predicate=None):
if path is None:
@@ -232,7 +241,12 @@ def ExtractAll(zip_path, path=None, no_clobber=True, pattern=None,
raise Exception(
'Path already exists from zip: %s %s %s'
% (zip_path, name, output_path))
- z.extract(name, path)
+ if IsSymlink(z, name):
+ dest = os.path.join(path, name)
+ MakeDirectory(os.path.dirname(dest))
+ os.symlink(z.read(name), dest)
+ else:
+ z.extract(name, path)
def AddToZipHermetic(zip_file, zip_path, src_path=None, data=None,