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 |
| 7 | import tarfile |
| 8 | |
| 9 | os.chdir(os.path.dirname(os.path.abspath(__file__))) |
| 10 | |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 11 | # Workaround for slow grp and pwd calls. |
| 12 | tarfile.grp = None |
| 13 | tarfile.pwd = None |
| 14 | |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 15 | def filter_git(tar_info): |
| 16 | if tar_info.name.startswith(os.path.join('data', '.git')): |
| 17 | return None |
| 18 | else: |
Ben Murdoch | da12d29 | 2016-06-02 14:46:10 +0100 | [diff] [blame] | 19 | tar_info.uname = tar_info.gname = "test262" |
Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 20 | return tar_info |
| 21 | |
| 22 | with tarfile.open('data.tar', 'w') as tar: |
| 23 | tar.add('data', filter=filter_git) |