OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import ast | 5 import ast |
6 import contextlib | 6 import contextlib |
7 import fnmatch | 7 import fnmatch |
8 import json | 8 import json |
9 import os | 9 import os |
10 import pipes | 10 import pipes |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 data: File data as a string. | 260 data: File data as a string. |
261 compress: Whether to enable compression. Default is take from ZipFile | 261 compress: Whether to enable compression. Default is take from ZipFile |
262 constructor. | 262 constructor. |
263 """ | 263 """ |
264 assert (src_path is None) != (data is None), ( | 264 assert (src_path is None) != (data is None), ( |
265 '|src_path| and |data| are mutually exclusive.') | 265 '|src_path| and |data| are mutually exclusive.') |
266 CheckZipPath(zip_path) | 266 CheckZipPath(zip_path) |
267 zipinfo = zipfile.ZipInfo(filename=zip_path, date_time=_HERMETIC_TIMESTAMP) | 267 zipinfo = zipfile.ZipInfo(filename=zip_path, date_time=_HERMETIC_TIMESTAMP) |
268 zipinfo.external_attr = _HERMETIC_FILE_ATTR | 268 zipinfo.external_attr = _HERMETIC_FILE_ATTR |
269 | 269 |
| 270 if src_path and os.path.islink(src_path): |
| 271 zipinfo.filename = zip_path |
| 272 zipinfo.external_attr |= stat.S_IFLNK << 16L # mark as a symlink |
| 273 zip_file.writestr(zipinfo, os.readlink(src_path)) |
| 274 return |
| 275 |
270 if src_path: | 276 if src_path: |
271 with file(src_path) as f: | 277 with file(src_path) as f: |
272 data = f.read() | 278 data = f.read() |
273 | 279 |
274 # zipfile will deflate even when it makes the file bigger. To avoid | 280 # zipfile will deflate even when it makes the file bigger. To avoid |
275 # growing files, disable compression at an arbitrary cut off point. | 281 # growing files, disable compression at an arbitrary cut off point. |
276 if len(data) < 16: | 282 if len(data) < 16: |
277 compress = False | 283 compress = False |
278 | 284 |
279 # None converts to ZIP_STORED, when passed explicitly rather than the | 285 # None converts to ZIP_STORED, when passed explicitly rather than the |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 | 521 |
516 md5_check.CallAndRecordIfStale( | 522 md5_check.CallAndRecordIfStale( |
517 on_stale_md5, | 523 on_stale_md5, |
518 record_path=record_path, | 524 record_path=record_path, |
519 input_paths=input_paths, | 525 input_paths=input_paths, |
520 input_strings=input_strings, | 526 input_strings=input_strings, |
521 output_paths=output_paths, | 527 output_paths=output_paths, |
522 force=force, | 528 force=force, |
523 pass_changes=True) | 529 pass_changes=True) |
524 | 530 |
OLD | NEW |