Changeset 2765
- Timestamp:
- 02/15/18 03:13:46 (6 years ago)
- Files:
-
- trunk/libffado/deb/SConscript (modified) (2 diffs)
- trunk/libffado/SConstruct (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/deb/SConscript
r2764 r2765 23 23 24 24 # from: http://www.qandr.org/quentin/writings/debscons.html 25 import os, shutil, sys 25 import os 26 26 27 Import('env') # exported by parent SConstruct 27 28 … … 124 125 DEBNAME, installed_size, DEBMAINT, DEBARCH, DEBVERSION, 125 126 DEBDEPENDS, DEBDESC) 126 f = open(str(target[0]), 'w') 127 f.write(control_info) 128 f.close() 127 with open(str(target[0]), 'w') as f: 128 f.write(control_info) 129 129 130 130 # We can generate the control file by calling make_control trunk/libffado/SConstruct
r2764 r2765 23 23 # along with this program. If not, see <http://www.gnu.org/licenses/>. 24 24 # 25 from __future__ import print_function 25 26 26 27 FFADO_API_VERSION = "9" 27 28 FFADO_VERSION="2.4.9999" 28 29 29 from subprocess import Popen, PIPE 30 from subprocess import Popen, PIPE, check_output 30 31 import os 31 32 import re 32 33 import sys 33 34 from string import Template 34 import imp35 35 import distutils.sysconfig 36 36 … … 157 157 def ConfigGuess( context ): 158 158 context.Message( "Trying to find the system triple: " ) 159 ret = os.popen( "/bin/sh admin/config.guess" ).read()[:-1]159 ret = check_output(("/bin/sh", "admin/config.guess")).rstrip() 160 160 context.Result( ret ) 161 161 return ret … … 220 220 version_re = re.compile(r'^(\d+)\.(\d+)\.(\d+)') 221 221 222 def VersionInt(vers):223 match = version_re.match(vers)224 if not match:225 return -1226 (maj, min, patch) = match.group(1, 2, 3)227 # For now allow "min" to run up to 65535. "maj" and "patch" are228 # restricted to 0-255.229 return (int(maj) << 24) | (int(min) << 8) | int(patch)230 231 222 def CheckJackdVer(): 232 # Suppress newline in python 2 and 3233 sys.stdout.write('Checking jackd version...')234 s ys.stdout.flush()235 ret = Popen("which jackd >/dev/null 2>&1 && jackd --version | tail -n 1 | cut -d ' ' -f 3", shell=True, stdout=PIPE).stdout.read()[:-1].decode()236 if (ret == ""):223 print('Checking jackd version...', end='') 224 popen = Popen(("which", 'jackd'), stdout=PIPE, stderr=PIPE) 225 stdout, stderr = popen.communicate() 226 assert popen.returncode in (0, 1), "which returned a unexpected status" 227 if popen.returncode == 1: 237 228 print("not installed") 238 return -1 239 else: 240 print(ret) 241 return VersionInt(ret) 229 return None 230 jackd = stdout.decode ().rstrip () 231 ret = check_output ((jackd, '--version')).decode() .rstrip () 232 ret = ret.split ('\n') [-1]; # Last line. 233 ret = ret.split () [2]; # Third field. 234 if not version_re.match (ret): 235 print("failed to parse version") 236 return None 237 print (ret) 238 239 # Trim off any "rc" (release candidate) components from the end of the 240 # version string 241 ret = ret.split ('rc')[0] 242 ret = ret.split ('.') 243 ret = map (int, ret) 244 return tuple (ret) 242 245 243 246 if env['SERIALIZE_USE_EXPAT']: … … 297 300 else: 298 301 jackd_ver = CheckJackdVer() 299 if (jackd_ver != -1):302 if jackd_ver: 300 303 # If jackd is unknown to pkg-config but is never-the-less 301 304 # runnable, use the version number reported by it. This means 302 305 # users don't have to have jack development files present on 303 306 # their system for this to work. 304 have_jack = (jackd_ver >= VersionInt('0.0.0'))305 good_jack1 = (jackd_ver < VersionInt('1.9.0')) and (jackd_ver >= VersionInt('0.121.4'))306 good_jack2 = (jackd_ver >= VersionInt('1.9.9'))307 have_jack = jackd_ver >= (0, 0, 0) 308 good_jack1 = jackd_ver < (1, 9, 0) and jackd_ver >= (0, 121, 4) 309 good_jack2 = jackd_ver >= (1, 9, 9) 307 310 308 311 if env['ENABLE_SETBUFFERSIZE_API_VER'] == 'auto': … … 567 570 568 571 #=== Begin Revised CXXFLAGS ========================================= 569 def outputof(*cmd):570 """Run a command without running a shell, return cmd's stdout571 """572 p = Popen(cmd, stdout=PIPE)573 return p.communicate()[0]574 575 572 def cpuinfo_kv(): 576 573 """generator which reads lines from Linux /proc/cpuinfo and splits them 577 574 into key:value tokens and yields (key, value) tuple. 578 575 """ 579 f = open('/proc/cpuinfo', 'r')580 for line in f:576 with open('/proc/cpuinfo', 'r') as f: 577 for line in f: 581 578 line = line.strip() 582 579 if line: 583 580 k,v = line.split(':', 1) 584 581 yield (k.strip(), v.strip()) 585 f.close()586 587 582 588 583 class CpuInfo (object): … … 718 713 # presumably if a person is running this script, they should have 719 714 # a gcc toolchain installed... 720 x = outputof('objdump', '-Wi', real_exe)715 x = check_output(('objdump', '-Wi', real_exe)) 721 716 # should emit a line that looks like this: 722 717 # /bin/mount: file format elf32-i386 … … 859 854 print("Doing an optimized build...") 860 855 861 env['REVISION'] = os.popen('svnversion .').read()[:-1]856 env['REVISION'] = check_output(('svnversion', '.',)).rstrip() 862 857 # This may be as simple as '89' or as complex as '4123:4184M'. 863 858 # We'll just use the last bit. … … 865 860 866 861 # Assume an unversioned directory indicates a release. 867 if env['REVISION'] [0:11] == 'Unversioned':862 if env['REVISION'].startswith ('Unversioned'): 868 863 env['REVISION'] = '' 869 864 870 865 # try to circumvent localized versions 871 if len(env['REVISION']) >= 5 and env['REVISION'][0:6] == 'export':866 if env['REVISION'].startswith ('export'): 872 867 env['REVISION'] = '' 873 868