| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """ | 6 """ |
| 7 This tool creates a tarball with all the sources, but without .svn directories. | 7 This tool creates a tarball with all the sources, but without .svn directories. |
| 8 | 8 |
| 9 It can also remove files which are not strictly required for build, so that | 9 It can also remove files which are not strictly required for build, so that |
| 10 the resulting tarball can be reasonably small (last time it was ~110 MB). | 10 the resulting tarball can be reasonably small (last time it was ~110 MB). |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 'third_party/lighttpd', | 31 'third_party/lighttpd', |
| 32 'third_party/WebKit/LayoutTests', | 32 'third_party/WebKit/LayoutTests', |
| 33 'webkit/data/layout_tests', | 33 'webkit/data/layout_tests', |
| 34 'webkit/tools/test/reference_build', | 34 'webkit/tools/test/reference_build', |
| 35 ) | 35 ) |
| 36 | 36 |
| 37 def GetSourceDirectory(): | 37 def GetSourceDirectory(): |
| 38 return os.path.realpath( | 38 return os.path.realpath( |
| 39 os.path.join(os.path.dirname(__file__), '..', '..', '..', 'src')) | 39 os.path.join(os.path.dirname(__file__), '..', '..', '..', 'src')) |
| 40 | 40 |
| 41 # Workaround lack of the exclude parameter in add method in python-2.4. |
| 42 # TODO(phajdan.jr): remove the workaround when it's not needed on the bot. |
| 43 class MyTarFile(tarfile.TarFile): |
| 44 def add(self, name, arcname=None, recursive=True, exclude=None): |
| 45 if exclude is not None and exclude(name): |
| 46 return |
| 47 tarfile.TarFile.add(self, name, arcname=arcname, recursive=recursive) |
| 48 |
| 41 def main(argv): | 49 def main(argv): |
| 42 parser = optparse.OptionParser() | 50 parser = optparse.OptionParser() |
| 43 parser.add_option("--remove-nonessential-files", | 51 parser.add_option("--remove-nonessential-files", |
| 44 dest="remove_nonessential_files", | 52 dest="remove_nonessential_files", |
| 45 action="store_true", default=False) | 53 action="store_true", default=False) |
| 46 | 54 |
| 47 options, args = parser.parse_args(argv) | 55 options, args = parser.parse_args(argv) |
| 48 | 56 |
| 49 if len(args) != 1: | 57 if len(args) != 1: |
| 50 print 'You must provide only one argument: output file name' | 58 print 'You must provide only one argument: output file name' |
| (...skipping 13 matching lines...) Expand all Loading... |
| 64 return True | 72 return True |
| 65 | 73 |
| 66 if not options.remove_nonessential_files: | 74 if not options.remove_nonessential_files: |
| 67 return False | 75 return False |
| 68 for nonessential_dir in NONESSENTIAL_DIRS: | 76 for nonessential_dir in NONESSENTIAL_DIRS: |
| 69 if path.startswith(os.path.join(GetSourceDirectory(), nonessential_dir)): | 77 if path.startswith(os.path.join(GetSourceDirectory(), nonessential_dir)): |
| 70 return True | 78 return True |
| 71 | 79 |
| 72 return False | 80 return False |
| 73 | 81 |
| 74 archive = tarfile.open(output_fullname, 'w:bz2') | 82 archive = MyTarFile.open(output_fullname, 'w:bz2') |
| 75 try: | 83 try: |
| 76 archive.add(GetSourceDirectory(), arcname=output_basename, | 84 archive.add(GetSourceDirectory(), arcname=output_basename, |
| 77 exclude=ShouldExcludePath) | 85 exclude=ShouldExcludePath) |
| 78 finally: | 86 finally: |
| 79 archive.close() | 87 archive.close() |
| 80 | 88 |
| 81 return 0 | 89 return 0 |
| 82 | 90 |
| 83 if __name__ == "__main__": | 91 if __name__ == "__main__": |
| 84 sys.exit(main(sys.argv[1:])) | 92 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |