Changeset 247

Show
Ignore:
Timestamp:
Mon Feb 6 08:41:29 2006
Author:
giovannibajo
Message:

Rework ldd-based bindepend to use popen and regexp

Files:

Legend:

Unmodified
Added
Removed
Modified
  • trunk/bindepend.py

    r245 r247  
    34 34 import string  
    35 35 import sys  
      36 import re  
    36 37  
    37 38 seen = {}  
     
    279 280  
    280 281         This implementation is for ldd platforms"""  
    281       import tempfile  
    282 282     rslt = []  
    283       tmpf = tempfile.mktemp()  
    284       os.system('ldd "%s" >%s' %(pth, tmpf))  
    285       time.sleep(0.1)  
    286       txt = open(tmpf,'r').readlines()  
    287       os.remove(tmpf)  
    288       i = 0  
    289       while i < len(txt):  
    290           tokens = string.split(string.strip(txt[i]))  
    291           if len(tokens) > 2 and tokens[1] == '=>':  
    292               lib = string.strip(tokens[2])  
    293               if string.strip(tokens[0])[:10] == 'linux-gate':  
      283     for line in os.popen('ldd "%s"' % pth).readlines():  
      284         m = re.search(r"\s+(.*?)\s+=>\s+(.*?)\s+\(.*\)", line)  
      285         if m:  
      286             name, lib = m.group(1), m.group(2)  
      287             if name[:10] == 'linux-gate':  
    294 288                 # linux-gate is a fake library which does not exist and  
    295 289                 # should be ignored. See also:  
     
    299 293                 rslt.append(lib)  
    300 294             else:  
    301                   print 'E: cannot find %s needed by %s' % (tokens[0], pth)  
    302           i = i + 1  
      295                 print 'E: cannot find %s in path %s (needed by %s)' % \  
      296                       (name, lib, pth)  
    303 297     return rslt  
    304 298