OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 def main(argv): | 127 def main(argv): |
128 parser = optparse.OptionParser() | 128 parser = optparse.OptionParser() |
129 parser.add_option("--basename") | 129 parser.add_option("--basename") |
130 parser.add_option("--remove-nonessential-files", | 130 parser.add_option("--remove-nonessential-files", |
131 dest="remove_nonessential_files", | 131 dest="remove_nonessential_files", |
132 action="store_true", default=False) | 132 action="store_true", default=False) |
133 parser.add_option("--test-data", action="store_true") | 133 parser.add_option("--test-data", action="store_true") |
134 # TODO(phajdan.jr): Remove --xz option when it's not needed for compatibility. | 134 # TODO(phajdan.jr): Remove --xz option when it's not needed for compatibility. |
135 parser.add_option("--xz", action="store_true") | 135 parser.add_option("--xz", action="store_true") |
136 parser.add_option("--verbose", action="store_true", default=False) | 136 parser.add_option("--verbose", action="store_true", default=False) |
| 137 parser.add_option("--progress", action="store_true", default=False) |
137 | 138 |
138 options, args = parser.parse_args(argv) | 139 options, args = parser.parse_args(argv) |
139 | 140 |
140 if len(args) != 1: | 141 if len(args) != 1: |
141 print 'You must provide only one argument: output file name' | 142 print 'You must provide only one argument: output file name' |
142 print '(without .tar.xz extension).' | 143 print '(without .tar.xz extension).' |
143 return 1 | 144 return 1 |
144 | 145 |
145 if not os.path.exists(GetSourceDirectory()): | 146 if not os.path.exists(GetSourceDirectory()): |
146 print 'Cannot find the src directory ' + GetSourceDirectory() | 147 print 'Cannot find the src directory ' + GetSourceDirectory() |
(...skipping 20 matching lines...) Expand all Loading... |
167 try: | 168 try: |
168 if options.test_data: | 169 if options.test_data: |
169 for directory in TESTDIRS: | 170 for directory in TESTDIRS: |
170 archive.add(os.path.join(GetSourceDirectory(), directory), | 171 archive.add(os.path.join(GetSourceDirectory(), directory), |
171 arcname=os.path.join(output_basename, directory)) | 172 arcname=os.path.join(output_basename, directory)) |
172 else: | 173 else: |
173 archive.add(GetSourceDirectory(), arcname=output_basename) | 174 archive.add(GetSourceDirectory(), arcname=output_basename) |
174 finally: | 175 finally: |
175 archive.close() | 176 archive.close() |
176 | 177 |
177 if subprocess.call(['xz', '-9', output_fullname]) != 0: | 178 if options.progress: |
| 179 sys.stdout.flush() |
| 180 pv = subprocess.Popen( |
| 181 ['pv', '--force', output_fullname], |
| 182 stdout=subprocess.PIPE, |
| 183 stderr=sys.stdout) |
| 184 with open(output_fullname + '.xz', 'w') as f: |
| 185 rc = subprocess.call(['xz', '-9', '-'], stdin=pv.stdout, stdout=f) |
| 186 pv.wait() |
| 187 else: |
| 188 rc = subprocess.call(['xz', '-9', output_fullname]) |
| 189 |
| 190 if rc != 0: |
178 print 'xz -9 failed!' | 191 print 'xz -9 failed!' |
179 return 1 | 192 return 1 |
180 | 193 |
181 return 0 | 194 return 0 |
182 | 195 |
183 | 196 |
184 if __name__ == "__main__": | 197 if __name__ == "__main__": |
185 sys.exit(main(sys.argv[1:])) | 198 sys.exit(main(sys.argv[1:])) |
OLD | NEW |