On Wed, Oct 29, 2008 at 8:47 PM, Joshua Murphy <[EMAIL PROTECTED]> wrote:
> On Wed, Oct 29, 2008 at 7:51 PM, Andrey Vul <[EMAIL PROTECTED]> wrote:
> <snip>
>>    elif system in ('Linux',):
>>        # Linux based systems
>>        distname,distversion,distid = dist('')
>>        if distname and not terse:
>>            platform = _platform(system,release,machine,processor,
>>                                 'with',
>>                                 distname,distversion,distid)
>>        else:
>>            # If the distribution name is unknown check for libc vs. glibc
>>            libcname,libcversion = libc_ver(sys.executable)
>>            platform = _platform(system,release,machine,processor,
>>                                 'with',
>>                                 libcname+libcversion)
> <snip>
>
> Hrm. I know just enough about python to get myself in trouble here...
> but it looks like a python bug in magicking up the libc name and
> version... but the below is WAY outside my level of practice with
> python (it'll take re-reading and digging elsewhere a good few times
> if I'm ever to make sense of it...
>
> ------------------
> def libc_ver(executable=sys.executable,lib='',version='',
>
>             chunksize=2048):
>
>    """ Tries to determine the libc version that the file executable
>        (which defaults to the Python interpreter) is linked against.
>
>        Returns a tuple of strings (lib,version) which default to the
>        given parameters in case the lookup fails.
>
>        Note that the function has intimate knowledge of how different
>        libc versions add symbols to the executable and thus is probably
>        only useable for executables compiled using gcc.
>
>        The file is read and scanned in chunks of chunksize bytes.
>
>    """
>    f = open(executable,'rb')
>    binary = f.read(chunksize)
>    pos = 0
>    while 1:
>        m = _libc_search.search(binary,pos)
>        if not m:
>            binary = f.read(chunksize)
>            if not binary:
>                break
>            pos = 0
>            continue
>        libcinit,glibc,glibcversion,so,threads,soversion = m.groups()
>        if libcinit and not lib:
>            lib = 'libc'
>        elif glibc:
>            if lib != 'glibc':
>                lib = 'glibc'
>                version = glibcversion
>            elif glibcversion > version:
>                version = glibcversion
>        elif so:
>            if lib != 'glibc':
>                lib = 'libc'
>                if soversion > version:
>                    version = soversion
>                if threads and version[-len(threads):] != threads:
>                    version = version + threads
>        pos = m.end()
>    f.close()
>    return lib,version
> ------------------
>
> It parses the header of an executable and guesses, but... the how is
> too many directions from this that I'm not seeing it with my haphazard
> abuse of grep. I'd presume anything that might care what platform it's
> running on (underneath python itself) would be susceptible, so a word
> thrown in the direction of upstream python would be the main way to
> go... though it looks like emerge didn't used to use that call...
>
> Portage 2.1.4.5 (default/linux/x86/2008.0, gcc-4.1.2, glibc-2.6.1-r0,
> 2.6.25-gentoo-r7-mahain i686)
> =================================================================
> System uname: 2.6.25-gentoo-r7-mahain i686 AMD Athlon(tm) MP 2400+
>
> is my output, based on a call in emerge to "uname -mrp" .. not
> platform.platform()
>
> Looks like gentoo-dev aimed to drop that dependency in newer versions after 
> all.
The creator of paludis was right ... portage is a jack of all trades
and a master of none.



-- 
Andrey Vul

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

Reply via email to