Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: third_party/instrumented_libraries/download_build_install.py

Issue 253493004: Instrumented libraries: use 'rm -rf' instead of 'shutil.rmtree'. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: restore empty line Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright 2013 The Chromium Authors. All rights reserved. 2 # Copyright 2013 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 """Downloads, builds (with instrumentation) and installs shared libraries.""" 6 """Downloads, builds (with instrumentation) and installs shared libraries."""
7 7
8 import argparse 8 import argparse
9 import os 9 import os
10 import platform 10 import platform
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 # library dependencies. 289 # library dependencies.
290 environment['LDFLAGS'] = '%s -L%s/lib %s' % ( 290 environment['LDFLAGS'] = '%s -L%s/lib %s' % (
291 sanitizer_params['linker_flags'], 291 sanitizer_params['linker_flags'],
292 install_prefix, parsed_arguments.extra_ldflags) 292 install_prefix, parsed_arguments.extra_ldflags)
293 293
294 library_directory = '%s/%s' % (parsed_arguments.intermediate_directory, 294 library_directory = '%s/%s' % (parsed_arguments.intermediate_directory,
295 parsed_arguments.library) 295 parsed_arguments.library)
296 296
297 # A failed build might have left a dirty source tree behind. 297 # A failed build might have left a dirty source tree behind.
298 if os.path.exists(library_directory): 298 if os.path.exists(library_directory):
299 shutil.rmtree(library_directory) 299 shell_call('rm -rf %s' % library_directory, parsed_arguments.verbose)
300 os.makedirs(library_directory) 300 os.makedirs(library_directory)
301 301
302 with ScopedChangeDirectory(library_directory) as cd_library: 302 with ScopedChangeDirectory(library_directory) as cd_library:
303 shell_call('apt-get source %s' % parsed_arguments.library, 303 shell_call('apt-get source %s' % parsed_arguments.library,
304 parsed_arguments.verbose) 304 parsed_arguments.verbose)
305 # There should be exactly one subdirectory after downloading a package. 305 # There should be exactly one subdirectory after downloading a package.
306 subdirectories = [d for d in os.listdir('.') if os.path.isdir(d)] 306 subdirectories = [d for d in os.listdir('.') if os.path.isdir(d)]
307 if len(subdirectories) != 1: 307 if len(subdirectories) != 1:
308 raise (Exception('There was not one directory after downloading ' 308 raise (Exception('There was not one directory after downloading '
309 'a package %s' % parsed_arguments.library)) 309 'a package %s' % parsed_arguments.library))
(...skipping 13 matching lines...) Expand all
323 print ('Probably, some of its dependencies are not installed: %s' % 323 print ('Probably, some of its dependencies are not installed: %s' %
324 ' '.join(get_library_build_dependencies(parsed_arguments.library) )) 324 ' '.join(get_library_build_dependencies(parsed_arguments.library) ))
325 sys.exit(1) 325 sys.exit(1)
326 326
327 # Touch a txt file to indicate library is installed. 327 # Touch a txt file to indicate library is installed.
328 open('%s/%s.txt' % (install_prefix, parsed_arguments.library), 'w').close() 328 open('%s/%s.txt' % (install_prefix, parsed_arguments.library), 'w').close()
329 329
330 # Remove downloaded package and generated temporary build files. 330 # Remove downloaded package and generated temporary build files.
331 # Failed builds intentionally skip this step, in order to aid in tracking down 331 # Failed builds intentionally skip this step, in order to aid in tracking down
332 # build failures. 332 # build failures.
333 shutil.rmtree(library_directory) 333 shell_call('rm -rf %s' % library_directory, parsed_arguments.verbose)
334 334
335 335
336 def main(): 336 def main():
337 argument_parser = argparse.ArgumentParser( 337 argument_parser = argparse.ArgumentParser(
338 description='Download, build and install instrumented library') 338 description='Download, build and install instrumented library')
339 339
340 argument_parser.add_argument('-j', '--jobs', type=int, default=1) 340 argument_parser.add_argument('-j', '--jobs', type=int, default=1)
341 argument_parser.add_argument('-l', '--library', required=True) 341 argument_parser.add_argument('-l', '--library', required=True)
342 argument_parser.add_argument( 342 argument_parser.add_argument(
343 '-i', '--product-directory', default='.', 343 '-i', '--product-directory', default='.',
(...skipping 26 matching lines...) Expand all
370 os.chdir(get_script_absolute_path()) 370 os.chdir(get_script_absolute_path())
371 # Ensure all build dependencies are installed. 371 # Ensure all build dependencies are installed.
372 if parsed_arguments.check_build_deps: 372 if parsed_arguments.check_build_deps:
373 check_library_build_dependencies(parsed_arguments.library) 373 check_library_build_dependencies(parsed_arguments.library)
374 374
375 download_build_install(parsed_arguments) 375 download_build_install(parsed_arguments)
376 376
377 377
378 if __name__ == '__main__': 378 if __name__ == '__main__':
379 main() 379 main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698