Changeset 1383

Show
Ignore:
Timestamp:
10/27/08 14:39:09 (15 years ago)
Author:
ppalmers
Message:

extend sandbox install tool

Files:

Legend:

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

    r1374 r1383  
    2525 
    2626FFADOSBI_VERSION = '0.1' 
    27 LATEST_FFADO_RELEASE_URL = 'http://www.ffado.org/files/libffado-2.0-beta6.tar.gz' 
    28 LATEST_FFADO_RELEASE_UNPACK_DIR = 'libffado-2.0-beta6
     27LATEST_FFADO_RELEASE_URL = 'http://www.ffado.org/files/libffado-2.0-beta7.tar.gz' 
     28LATEST_FFADO_RELEASE_UNPACK_DIR = 'libffado-2.0-beta7
    2929LATEST_JACK1_RELEASE_URL = 'http://jackaudio.org/downloads/jack-audio-connection-kit-0.109.2.tar.gz' 
    3030LATEST_JACK1_RELEASE_UNPACK_DIR = 'jack-audio-connection-kit-0.109.2' 
    3131 
    32 def ask_for_dir(descr): 
     32def ask_for_dir(descr, suggestion): 
    3333    ret_dir = None 
    3434    while True: 
    35         ret_dir = raw_input("Please specify a %s directory: " % descr) 
    36          
     35        ret_dir = raw_input("Please specify a %s directory [%s]: " % (descr, suggestion)) 
     36        if ret_dir == "": 
     37            ret_dir = suggestion 
     38 
    3739        if not os.path.exists(ret_dir): 
    3840            try: 
     
    4042            except: 
    4143                yesno = raw_input("Could not create the %s directory. Try again? [yes/no] " % descr) 
    42                 if yesno[0] != 'y': 
     44                if yesno == "" or yesno[0] != 'y': 
    4345                    return None 
    4446                else: 
     
    4648            break 
    4749        else: 
    48             yesno = raw_input("WARNING: the %s directory already exists. Do you want to overwrite it? [yes/no] " % descr
    49             if yesno[0] != 'y': 
    50                 yesno = raw_input("Try again? [yes/no] "
    51                 if yesno[0] != 'y': 
     50            yesno = raw_input("WARNING: the %s directory at %s already exists. Do you want to overwrite it? [yes/no] " % (descr, ret_dir)
     51            if yesno == "" or yesno[0] != 'y': 
     52                yesno = raw_input("Specify new %s directory? [yes/no] " % descr
     53                if yesno == "" or yesno[0] != 'y': 
    5254                    return None 
    5355                else: 
    5456                    continue 
    5557            else: 
    56                 os.system('rm -Rf "%s"' % ret_dir) 
    57                 os.makedirs(ret_dir) 
    58                 break 
     58                yesno = raw_input("WARNING: about to remove the old %s directory at %s. Proceed? [yes/no] " % (descr, ret_dir)) 
     59                if yesno == "" or yesno[0] != 'y': 
     60                    yesno = raw_input("Specify new %s directory? [yes/no] " % descr) 
     61                    if yesno == "" or yesno[0] != 'y': 
     62                        return None 
     63                    else: 
     64                        continue 
     65                else: 
     66                    os.system('rm -Rf "%s"' % ret_dir) 
     67                    os.makedirs(ret_dir) 
     68                    break 
    5969    return ret_dir 
    6070 
    6171def fetch_source(build_dir, source_descriptor, target): 
     72    logfile = "%s/%s.log" % (build_dir, target) 
     73    os.system('echo "" > %s' % logfile) 
     74 
    6275    if source_descriptor[1] == 'svn': 
    63         print " checking out SVN repository: %s" % source_descriptor[2] 
     76        print " Checking out SVN repository: %s" % source_descriptor[2] 
    6477        cwd = os.getcwd() 
    6578        os.chdir(build_dir) 
    66         os.system('svn co "%s" "%s"' % (source_descriptor[2], target)) 
     79        retval = os.system('svn co "%s" "%s" >> %s' % (source_descriptor[2], target, logfile)) 
    6780        os.chdir(cwd) 
     81        if retval: 
     82            print "  Failed to checkout the SVN repository. Inspect %s for details. (is subversion installed?)" % logfile 
     83            return False 
    6884        return True 
    6985    elif source_descriptor[1] == 'tar.gz': 
    70         print " downloading tarball: %s" % source_descriptor[2] 
     86        print " Downloading tarball: %s" % source_descriptor[2] 
    7187        import urllib 
    7288        tmp_file = '%s/tmp.tar.gz' % build_dir 
    73         urllib.urlretrieve(source_descriptor[2], tmp_file) 
     89        try: 
     90            urllib.urlretrieve(source_descriptor[2], tmp_file) 
     91        except: 
     92            print " Could not retrieve source tarball." 
     93            return False 
    7494        cwd = os.getcwd() 
    7595        os.chdir(build_dir) 
    7696        print " extracting tarball..." 
    77         os.system('tar -zxf "%s"' % tmp_file) 
     97        retval = os.system('tar -zxf "%s" > %s' % (tmp_file, logfile)) 
     98        if retval: 
     99            print "  Failed to extract the source tarball. Inspect %s for details." % logfile 
     100            os.chdir(cwd) 
     101            return False 
    78102        if source_descriptor[3]: 
    79             os.system('mv "%s" "%s"' % (source_descriptor[3], target)) 
     103            retval = os.system('mv "%s" "%s"' % (source_descriptor[3], target)) 
     104            if retval: 
     105                print "  Failed to move the extracted tarball" 
     106                os.chdir(cwd) 
     107                return False 
    80108        os.chdir(cwd) 
    81109        return True 
     
    84112        return False 
    85113 
     114 
    86115welcome_msg = """ 
    87116FFADO sandbox install utility """ + FFADOSBI_VERSION + """ 
     
    109138# get the paths to be used 
    110139if 'HOME' in os.environ.keys(): 
    111     suggestion = "%s/ffadosandbox" % os.environ['HOME'] 
     140    suggestion_sandbox = "%s/ffadosandbox" % os.environ['HOME'] 
    112141else: 
    113     suggestion = "/home/myuser/ffadosandbox" 
     142    suggestion_sandbox = "/home/myuser/ffadosandbox" 
    114143 
    115144sandbox_dir_msg = """ 
     
    130159system-wide (if run as root). This is not recommended, but can be 
    131160useful for automated installs. Uninstall will be a lot harder though. 
    132 """ % suggestion 
     161""" % suggestion_sandbox 
    133162 
    134163if 'HOME' in os.environ.keys(): 
    135     suggestion = "%s/ffadobuild" % os.environ['HOME'] 
     164    suggestion_build = "%s/ffadobuild" % os.environ['HOME'] 
    136165else: 
    137     suggestion = "/home/myuser/ffadobuild" 
     166    suggestion_build = "/home/myuser/ffadobuild" 
    138167 
    139168build_dir_msg = """ 
     
    149178 
    150179Suggestion: %s 
    151 """ % suggestion 
     180""" % suggestion_build 
    152181 
    153182print sandbox_dir_msg 
    154 sandbox_dir = ask_for_dir('sandbox'
     183sandbox_dir = ask_for_dir('sandbox', suggestion_sandbox
    155184if sandbox_dir == None: 
    156185    print "Cannot proceed without valid sandbox directory." 
     
    160189 
    161190print build_dir_msg 
    162 build_dir = ask_for_dir('build'
     191build_dir = ask_for_dir('build', suggestion_build
    163192if build_dir == None: 
    164193    print "Cannot proceed without valid build directory." 
     
    172201ffado_versions = {} 
    173202ffado_versions[0] = ['SVN trunk', 'svn', 'http://subversion.ffado.org/ffado/trunk/libffado', None] 
    174 ffado_versions[1] = ['libffado-2.0 (recommended)', 'svn', 'http://subversion.ffado.org/ffado/branches/libffado-2.0', None] 
     203ffado_versions[1] = ['SVN libffado-2.0 (recommended)', 'svn', 'http://subversion.ffado.org/ffado/branches/libffado-2.0', None] 
    175204ffado_versions[2] = ['latest release', 'tar.gz', LATEST_FFADO_RELEASE_URL, LATEST_FFADO_RELEASE_UNPACK_DIR] 
    176205 
     
    190219    except: 
    191220        yesno = raw_input("Invalid FFADO version specified. Try again? [yes/no] ") 
    192         if yesno[0] != 'y': 
     221        if yesno == "" or yesno[0] != 'y': 
    193222            print "Cannot proceed without valid FFADO version." 
    194223            exit(-1) 
     
    220249    except: 
    221250        yesno = raw_input("Invalid jack version specified. Try again? [yes/no] ") 
    222         if yesno[0] != 'y': 
     251        if yesno == "" or yesno[0] != 'y': 
    223252            print "Cannot proceed without valid jack version." 
    224253            exit(-1) 
     
    246275    print "Could not fetch FFADO source" 
    247276    exit(-1) 
    248 print " got FFADO source" 
     277print " Successfully fetched FFADO source" 
    249278 
    250279print "Fetching jack source..." 
     
    253282    print "Could not fetch jack source" 
    254283    exit(-1) 
    255 print " got jack source" 
     284print " Successfully fetched jack source" 
    256285 
    257286cwd = os.getcwd() 
     287 
     288ffado_log = "%s/ffadobuild.log" % build_dir 
     289ffado_scons_options = "-j2" # TODO: interactive config of the build 
     290os.system('echo "" > %s' % ffado_log)  
     291 
    258292# configure FFADO 
    259293os.chdir("%s/libffado/" % build_dir) 
    260 os.system('scons PREFIX="%s"' % sandbox_dir) 
     294print "Building FFADO..." 
     295print " Compiling..." 
     296retval = os.system('scons PREFIX="%s" %s >> %s' % (sandbox_dir, ffado_scons_options, ffado_log)) 
     297if retval: 
     298    print """ 
     299Failed to configure/build FFADO. Most likely this is due to uninstalled dependencies. 
     300Check %s for details. 
     301""" % ffado_log 
     302    exit(-1) 
    261303 
    262304# install FFADO 
    263 os.system('scons install') 
     305print " Installing into %s..." % sandbox_dir 
     306retval = os.system('scons install >> %s' % (ffado_log)) 
     307if retval: 
     308    print "Failed to install FFADO. Check %s for details." % ffado_log 
     309    exit(-1) 
    264310 
    265311# configure JACK 
    266312os.chdir("%s/jack/" % build_dir) 
     313jack_log = "%s/jackbuild.log" % build_dir 
     314os.system('echo "" > %s' % jack_log)  
     315 
     316print "Building Jack..." 
    267317if use_jack_version[1] == 'svn': 
    268     os.system('./autogen.sh')  
    269 os.system('./configure --prefix="%s"' % sandbox_dir) 
     318    print " Initializing build system..." 
     319    retval = os.system('./autogen.sh >> %s' % jack_log) 
     320    if retval: 
     321        print """ 
     322Failed to initialize the jack build system. Most likely this is due to uninstalled dependencies. 
     323Check %s for details. 
     324""" % jack_log 
     325        exit(-1) 
     326 
     327print " Configuring build..." 
     328retval = os.system('./configure --prefix="%s" >> %s' % (sandbox_dir, jack_log)) 
     329if retval: 
     330    print """ 
     331Failed to configure the jack build. Most likely this is due to uninstalled dependencies. 
     332Check %s for details. 
     333""" % jack_log 
     334    exit(-1) 
    270335 
    271336# build and install jack 
    272 os.system('make') 
    273 os.system('make install') 
     337print " Compiling..." 
     338retval = os.system('make >> %s' % (jack_log)) 
     339if retval: 
     340    print "Failed to build jack. Check %s for details." % jack_log 
     341    exit(-1) 
     342 
     343print " Installing into %s..." % sandbox_dir 
     344retval = os.system('make install >> %s' % (jack_log)) 
     345if retval: 
     346    print "Failed to install jack. Check %s for details." % jack_log 
     347    exit(-1) 
    274348 
    275349# write the bashrc file 
     
    287361""" % (sandbox_dir, sandbox_dir, sandbox_dir) 
    288362 
     363print "Writing shell configuration file..." 
    289364sandbox_rc_file = "%s/ffado.rc" % sandbox_dir 
    290  
    291 fid = open(sandbox_rc_file, "w") 
    292 fid.write(sandbox_bashrc) 
    293 fid.close() 
     365try: 
     366    fid = open(sandbox_rc_file, "w") 
     367    fid.write(sandbox_bashrc) 
     368    fid.close() 
     369except: 
     370    print "Could not write the sandbox rc file." 
     371    exit(-1) 
    294372 
    295373os.chdir(cwd) 
     
    302380If you use the bash shell (or compatible) you can use the following 
    303381rc script: %s. The procedure to use the sandboxed ffado+jack would be: 
    304     
     382 
    305383   $ source %s 
    306384   $ jackd -R -d firewire