def Move(src, dst): """Move the path src to dst.""" print 'mv -f %s %s' % (src, dst) oshelpers.Move(['-f', src, dst])
def Main(args): parser = optparse.OptionParser() # Modes parser.add_option('-s', '--sdk', help='SDK directory.', dest='sdk') parser.add_option('-t', '--tool', help='Which toolchain.', dest='tool') parser.add_option('-o', '--os', help='Untar for which OS.', dest='os') parser.add_option('-T', '--tmp', help='Temp directory.', dest='tmp') parser.add_option('-f', '--fin', help='Final output directory.', dest='fin') parser.add_option('-v', '--verbose', dest='verbose', default=False, help='Enable verbosity', action='store_true') options, args = parser.parse_args(args[1:]) if not options.sdk: parser.error('Expecting SDK directory.') if not options.os: parser.error('Expecting OS to be specified.') if not options.tool: parser.error('Expecting which tool to untar.') if not options.fin: parser.error('Expecting final output directory.') if len(args) < 1: parser.error('Expecting path(s) to tarball(s).') untar_path = os.path.join(options.tmp, options.tool) if options.tool == 'x86_newlib': tool_path = os.path.join(untar_path, 'sdk', 'nacl-sdk') elif options.tool == 'x86_glibc': tool_path = os.path.join(untar_path, 'toolchain', options.os + '_x86') elif options.tool in ('pnacl', 'arm_newlib'): tool_path = untar_path else: parser.error('Unknown tool type: ' + options.tool) final_path = os.path.abspath(options.fin) stamp_path = os.path.join(final_path, 'stamp.untar') final_path = os.path.abspath(final_path) untar_path = os.path.abspath(untar_path) stamp_path = os.path.abspath(stamp_path) tool_path = os.path.abspath(tool_path) if options.verbose: print 'Delete: ' + untar_path oshelpers.Remove(['-fr', untar_path]) if options.verbose: print 'Mkdir: ' + untar_path oshelpers.Mkdir(['-p', untar_path]) if options.verbose: print 'Delete: ' + final_path oshelpers.Remove(['-fr', final_path]) if options.verbose: print 'Mkdir: ' + os.path.join(options.sdk, 'toolchain') oshelpers.Mkdir(['-p', os.path.join(options.sdk, 'toolchain')]) args = [os.path.abspath(a) for a in args] old_path = os.getcwd() os.chdir(untar_path) for arg in args: if options.verbose: print 'Open: ' + arg tar = cygtar.CygTar(arg, 'r', verbose=options.verbose) if options.verbose: print 'Extract' tar.Extract() os.chdir(old_path) if options.verbose: print 'Move: %s to %s' % (tool_path, final_path) oshelpers.Move([tool_path, final_path]) if options.verbose: print 'Stamp: ' + stamp_path fh = open(stamp_path, 'w') fh.write(args[0] + '\n') fh.close() if options.verbose: print 'Done.' return 0
def Move(src, dst): """Move the path src to dst.""" Trace('mv -f %s %s' % (ShortFilename(src), ShortFilename(dst))) oshelpers.Move(['-f', src, dst])
def Move(src, dst): """Move the path src to dst.""" Trace('mv -f %s %s' % (src, dst)) oshelpers.Move(['-f', src, dst])