Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # Copyright 2016 the V8 project authors. All rights reserved. |
| 3 | # Use of this source code is governed by a BSD-style license that can be |
| 4 | # found in the LICENSE file. |
| 5 | |
| 6 | import os |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame] | 7 | import sys |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 8 | import tarfile |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame] | 9 | import time |
| 10 | |
| 11 | # In GN we expect the path to a stamp file as an argument. |
| 12 | if len(sys.argv) == 2: |
| 13 | STAMP_FILE = os.path.abspath(sys.argv[1]) |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 14 | |
| 15 | os.chdir(os.path.dirname(os.path.abspath(__file__))) |
| 16 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 17 | # Workaround for slow grp and pwd calls. |
| 18 | tarfile.grp = None |
| 19 | tarfile.pwd = None |
| 20 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 21 | def filter_git(tar_info): |
| 22 | if tar_info.name.startswith(os.path.join('data', '.git')): |
| 23 | return None |
| 24 | else: |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 25 | tar_info.uname = tar_info.gname = "test262" |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 26 | return tar_info |
| 27 | |
| 28 | with tarfile.open('data.tar', 'w') as tar: |
| 29 | tar.add('data', filter=filter_git) |
Ben Murdoch | 61f157c | 2016-09-16 13:49:30 +0100 | [diff] [blame] | 30 | |
| 31 | # Workaround for GN. We can't specify the tarfile as output because it's |
| 32 | # not in the product directory. Therefore we track running of this script |
| 33 | # with an extra stamp file in the product directory. |
| 34 | if len(sys.argv) == 2: |
| 35 | with open(STAMP_FILE, 'w') as f: |
| 36 | f.write(str(time.time())) |