Changeset 2745

Show
Ignore:
Timestamp:
01/31/18 02:17:49 (7 months ago)
Author:
jwoithe
Message:

[PATCH 09/13] tools: sandbox-install: use context managers for log files.

From Nicolas Boulenguez.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/support/tools/ffado-sandbox-install.py

    r2743 r2745  
    297297 
    298298ffado_log = "%s/ffadobuild.log" % build_dir 
    299 ffado_scons_options = ("-j2") # TODO: interactive config of the build 
    300 os.system('echo "" > %s' % ffado_log) 
    301  
    302 # configure FFADO 
    303 os.chdir("%s/libffado/" % build_dir) 
    304 print( "Building FFADO..." ) 
    305 print( " Compiling..." ) 
    306 retval = os.system('scons PREFIX="%s" %s >> %s' % (sandbox_dir, ffado_scons_options, ffado_log)) 
    307 if retval: 
     299ffado_scons_options = ("-j2",) # TODO: interactive config of the build 
     300with open (ffado_log, 'w') as log: 
     301  log.write ('\n') 
     302 
     303  # configure FFADO 
     304  os.chdir("%s/libffado/" % build_dir) 
     305  print( "Building FFADO..." ) 
     306  print( " Compiling..." ) 
     307  if subprocess.call (('scons', 'PREFIX="' + sandbox_dir + '"') + ffado_scons_options, 
     308                      stdout=log): 
    308309    print( """ ) 
    309310Failed to configure/build FFADO. Most likely this is due to uninstalled dependencies. 
     
    312313    exit(-1) 
    313314 
    314 # install FFADO 
    315 print( " Installing into %s..." % sandbox_dir ) 
    316 retval = os.system('scons install >> %s' % (ffado_log)) 
    317 if retval: 
     315  # install FFADO 
     316  print( " Installing into %s..." % sandbox_dir ) 
     317  if subprocess.check_output (('scons', 'install'), stdout=log): 
    318318    print( "Failed to install FFADO. Check %s for details." % ffado_log ) 
    319319    exit(-1) 
     
    322322os.chdir("%s/jack/" % build_dir) 
    323323jack_log = "%s/jackbuild.log" % build_dir 
    324 os.system('echo "" > %s' % jack_log) 
    325  
    326 print( "Building Jack..." ) 
    327 if use_jack_version[1] == 'svn': 
     324with open (jack_log, 'w') as log: 
     325  log.write ('\n') 
     326 
     327  print( "Building Jack..." ) 
     328  if use_jack_version[1] == 'svn': 
    328329    print( " Initializing build system..." ) 
    329     retval = os.system('./autogen.sh >> %s' % jack_log) 
    330     if retval: 
     330    if subprocess.check_output (('./autogen.sh',), stdout=log): 
    331331        print( """ ) 
    332332Failed to initialize the jack build system. Most likely this is due to uninstalled dependencies. 
     
    335335        exit(-1) 
    336336 
    337 print( " Configuring build..." ) 
    338 retval = os.system('./configure --prefix="%s" >> %s' % (sandbox_dir, jack_log)) 
    339 if retval
    340     print( """ ) 
     337    print( " Configuring build..." ) 
     338    if subprocess.check_output (('./configure', '--prefix="' + sandbox_dir + '"'), 
     339                                stdout=log)
     340        print( """ ) 
    341341Failed to configure the jack build. Most likely this is due to uninstalled dependencies. 
    342342Check %s for details. 
    343343""" % jack_log 
    344     exit(-1) 
    345  
    346 # build and install jack 
    347 print( " Compiling..." ) 
    348 retval = os.system('make >> %s' % (jack_log)) 
    349 if retval: 
    350     print( "Failed to build jack. Check %s for details." % jack_log ) 
    351     exit(-1) 
    352  
    353 print( " Installing into %s..." % sandbox_dir ) 
    354 retval = os.system('make install >> %s' % (jack_log)) 
    355 if retval: 
    356     print( "Failed to install jack. Check %s for details." % jack_log ) 
    357     exit(-1) 
     344        exit(-1) 
     345 
     346    # build and install jack 
     347    print( " Compiling..." ) 
     348    if subprocess.check_output (('make',), stdout=log): 
     349        print( "Failed to build jack. Check %s for details." % jack_log ) 
     350        exit(-1) 
     351 
     352    print( " Installing into %s..." % sandbox_dir ) 
     353    if subprocess.check_output (('make', 'install'), stdout=log): 
     354        print( "Failed to install jack. Check %s for details." % jack_log ) 
     355        exit(-1) 
    358356 
    359357# write the bashrc file