Changeset 1383
- Timestamp:
- 10/27/08 14:39:09 (15 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/libffado-2.0/support/tools/ffado-sandbox-install.py
r1374 r1383 25 25 26 26 FFADOSBI_VERSION = '0.1' 27 LATEST_FFADO_RELEASE_URL = 'http://www.ffado.org/files/libffado-2.0-beta 6.tar.gz'28 LATEST_FFADO_RELEASE_UNPACK_DIR = 'libffado-2.0-beta 6'27 LATEST_FFADO_RELEASE_URL = 'http://www.ffado.org/files/libffado-2.0-beta7.tar.gz' 28 LATEST_FFADO_RELEASE_UNPACK_DIR = 'libffado-2.0-beta7' 29 29 LATEST_JACK1_RELEASE_URL = 'http://jackaudio.org/downloads/jack-audio-connection-kit-0.109.2.tar.gz' 30 30 LATEST_JACK1_RELEASE_UNPACK_DIR = 'jack-audio-connection-kit-0.109.2' 31 31 32 def ask_for_dir(descr ):32 def ask_for_dir(descr, suggestion): 33 33 ret_dir = None 34 34 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 37 39 if not os.path.exists(ret_dir): 38 40 try: … … 40 42 except: 41 43 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': 43 45 return None 44 46 else: … … 46 48 break 47 49 else: 48 yesno = raw_input("WARNING: the %s directory a lready 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': 52 54 return None 53 55 else: 54 56 continue 55 57 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 59 69 return ret_dir 60 70 61 71 def fetch_source(build_dir, source_descriptor, target): 72 logfile = "%s/%s.log" % (build_dir, target) 73 os.system('echo "" > %s' % logfile) 74 62 75 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] 64 77 cwd = os.getcwd() 65 78 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)) 67 80 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 68 84 return True 69 85 elif source_descriptor[1] == 'tar.gz': 70 print " downloading tarball: %s" % source_descriptor[2]86 print " Downloading tarball: %s" % source_descriptor[2] 71 87 import urllib 72 88 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 74 94 cwd = os.getcwd() 75 95 os.chdir(build_dir) 76 96 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 78 102 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 80 108 os.chdir(cwd) 81 109 return True … … 84 112 return False 85 113 114 86 115 welcome_msg = """ 87 116 FFADO sandbox install utility """ + FFADOSBI_VERSION + """ … … 109 138 # get the paths to be used 110 139 if 'HOME' in os.environ.keys(): 111 suggestion = "%s/ffadosandbox" % os.environ['HOME']140 suggestion_sandbox = "%s/ffadosandbox" % os.environ['HOME'] 112 141 else: 113 suggestion = "/home/myuser/ffadosandbox"142 suggestion_sandbox = "/home/myuser/ffadosandbox" 114 143 115 144 sandbox_dir_msg = """ … … 130 159 system-wide (if run as root). This is not recommended, but can be 131 160 useful for automated installs. Uninstall will be a lot harder though. 132 """ % suggestion 161 """ % suggestion_sandbox 133 162 134 163 if 'HOME' in os.environ.keys(): 135 suggestion = "%s/ffadobuild" % os.environ['HOME']164 suggestion_build = "%s/ffadobuild" % os.environ['HOME'] 136 165 else: 137 suggestion = "/home/myuser/ffadobuild"166 suggestion_build = "/home/myuser/ffadobuild" 138 167 139 168 build_dir_msg = """ … … 149 178 150 179 Suggestion: %s 151 """ % suggestion 180 """ % suggestion_build 152 181 153 182 print sandbox_dir_msg 154 sandbox_dir = ask_for_dir('sandbox' )183 sandbox_dir = ask_for_dir('sandbox', suggestion_sandbox) 155 184 if sandbox_dir == None: 156 185 print "Cannot proceed without valid sandbox directory." … … 160 189 161 190 print build_dir_msg 162 build_dir = ask_for_dir('build' )191 build_dir = ask_for_dir('build', suggestion_build) 163 192 if build_dir == None: 164 193 print "Cannot proceed without valid build directory." … … 172 201 ffado_versions = {} 173 202 ffado_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]203 ffado_versions[1] = ['SVN libffado-2.0 (recommended)', 'svn', 'http://subversion.ffado.org/ffado/branches/libffado-2.0', None] 175 204 ffado_versions[2] = ['latest release', 'tar.gz', LATEST_FFADO_RELEASE_URL, LATEST_FFADO_RELEASE_UNPACK_DIR] 176 205 … … 190 219 except: 191 220 yesno = raw_input("Invalid FFADO version specified. Try again? [yes/no] ") 192 if yesno [0] != 'y':221 if yesno == "" or yesno[0] != 'y': 193 222 print "Cannot proceed without valid FFADO version." 194 223 exit(-1) … … 220 249 except: 221 250 yesno = raw_input("Invalid jack version specified. Try again? [yes/no] ") 222 if yesno [0] != 'y':251 if yesno == "" or yesno[0] != 'y': 223 252 print "Cannot proceed without valid jack version." 224 253 exit(-1) … … 246 275 print "Could not fetch FFADO source" 247 276 exit(-1) 248 print " gotFFADO source"277 print " Successfully fetched FFADO source" 249 278 250 279 print "Fetching jack source..." … … 253 282 print "Could not fetch jack source" 254 283 exit(-1) 255 print " gotjack source"284 print " Successfully fetched jack source" 256 285 257 286 cwd = os.getcwd() 287 288 ffado_log = "%s/ffadobuild.log" % build_dir 289 ffado_scons_options = "-j2" # TODO: interactive config of the build 290 os.system('echo "" > %s' % ffado_log) 291 258 292 # configure FFADO 259 293 os.chdir("%s/libffado/" % build_dir) 260 os.system('scons PREFIX="%s"' % sandbox_dir) 294 print "Building FFADO..." 295 print " Compiling..." 296 retval = os.system('scons PREFIX="%s" %s >> %s' % (sandbox_dir, ffado_scons_options, ffado_log)) 297 if retval: 298 print """ 299 Failed to configure/build FFADO. Most likely this is due to uninstalled dependencies. 300 Check %s for details. 301 """ % ffado_log 302 exit(-1) 261 303 262 304 # install FFADO 263 os.system('scons install') 305 print " Installing into %s..." % sandbox_dir 306 retval = os.system('scons install >> %s' % (ffado_log)) 307 if retval: 308 print "Failed to install FFADO. Check %s for details." % ffado_log 309 exit(-1) 264 310 265 311 # configure JACK 266 312 os.chdir("%s/jack/" % build_dir) 313 jack_log = "%s/jackbuild.log" % build_dir 314 os.system('echo "" > %s' % jack_log) 315 316 print "Building Jack..." 267 317 if 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 """ 322 Failed to initialize the jack build system. Most likely this is due to uninstalled dependencies. 323 Check %s for details. 324 """ % jack_log 325 exit(-1) 326 327 print " Configuring build..." 328 retval = os.system('./configure --prefix="%s" >> %s' % (sandbox_dir, jack_log)) 329 if retval: 330 print """ 331 Failed to configure the jack build. Most likely this is due to uninstalled dependencies. 332 Check %s for details. 333 """ % jack_log 334 exit(-1) 270 335 271 336 # build and install jack 272 os.system('make') 273 os.system('make install') 337 print " Compiling..." 338 retval = os.system('make >> %s' % (jack_log)) 339 if retval: 340 print "Failed to build jack. Check %s for details." % jack_log 341 exit(-1) 342 343 print " Installing into %s..." % sandbox_dir 344 retval = os.system('make install >> %s' % (jack_log)) 345 if retval: 346 print "Failed to install jack. Check %s for details." % jack_log 347 exit(-1) 274 348 275 349 # write the bashrc file … … 287 361 """ % (sandbox_dir, sandbox_dir, sandbox_dir) 288 362 363 print "Writing shell configuration file..." 289 364 sandbox_rc_file = "%s/ffado.rc" % sandbox_dir 290 291 fid = open(sandbox_rc_file, "w") 292 fid.write(sandbox_bashrc) 293 fid.close() 365 try: 366 fid = open(sandbox_rc_file, "w") 367 fid.write(sandbox_bashrc) 368 fid.close() 369 except: 370 print "Could not write the sandbox rc file." 371 exit(-1) 294 372 295 373 os.chdir(cwd) … … 302 380 If you use the bash shell (or compatible) you can use the following 303 381 rc script: %s. The procedure to use the sandboxed ffado+jack would be: 304 382 305 383 $ source %s 306 384 $ jackd -R -d firewire