1 |
On Wed, Oct 29, 2008 at 8:47 PM, Joshua Murphy <poisonbl@×××××.com> wrote: |
2 |
> On Wed, Oct 29, 2008 at 7:51 PM, Andrey Vul <andrey.vul@×××××.com> wrote: |
3 |
> <snip> |
4 |
>> elif system in ('Linux',): |
5 |
>> # Linux based systems |
6 |
>> distname,distversion,distid = dist('') |
7 |
>> if distname and not terse: |
8 |
>> platform = _platform(system,release,machine,processor, |
9 |
>> 'with', |
10 |
>> distname,distversion,distid) |
11 |
>> else: |
12 |
>> # If the distribution name is unknown check for libc vs. glibc |
13 |
>> libcname,libcversion = libc_ver(sys.executable) |
14 |
>> platform = _platform(system,release,machine,processor, |
15 |
>> 'with', |
16 |
>> libcname+libcversion) |
17 |
> <snip> |
18 |
> |
19 |
> Hrm. I know just enough about python to get myself in trouble here... |
20 |
> but it looks like a python bug in magicking up the libc name and |
21 |
> version... but the below is WAY outside my level of practice with |
22 |
> python (it'll take re-reading and digging elsewhere a good few times |
23 |
> if I'm ever to make sense of it... |
24 |
> |
25 |
> ------------------ |
26 |
> def libc_ver(executable=sys.executable,lib='',version='', |
27 |
> |
28 |
> chunksize=2048): |
29 |
> |
30 |
> """ Tries to determine the libc version that the file executable |
31 |
> (which defaults to the Python interpreter) is linked against. |
32 |
> |
33 |
> Returns a tuple of strings (lib,version) which default to the |
34 |
> given parameters in case the lookup fails. |
35 |
> |
36 |
> Note that the function has intimate knowledge of how different |
37 |
> libc versions add symbols to the executable and thus is probably |
38 |
> only useable for executables compiled using gcc. |
39 |
> |
40 |
> The file is read and scanned in chunks of chunksize bytes. |
41 |
> |
42 |
> """ |
43 |
> f = open(executable,'rb') |
44 |
> binary = f.read(chunksize) |
45 |
> pos = 0 |
46 |
> while 1: |
47 |
> m = _libc_search.search(binary,pos) |
48 |
> if not m: |
49 |
> binary = f.read(chunksize) |
50 |
> if not binary: |
51 |
> break |
52 |
> pos = 0 |
53 |
> continue |
54 |
> libcinit,glibc,glibcversion,so,threads,soversion = m.groups() |
55 |
> if libcinit and not lib: |
56 |
> lib = 'libc' |
57 |
> elif glibc: |
58 |
> if lib != 'glibc': |
59 |
> lib = 'glibc' |
60 |
> version = glibcversion |
61 |
> elif glibcversion > version: |
62 |
> version = glibcversion |
63 |
> elif so: |
64 |
> if lib != 'glibc': |
65 |
> lib = 'libc' |
66 |
> if soversion > version: |
67 |
> version = soversion |
68 |
> if threads and version[-len(threads):] != threads: |
69 |
> version = version + threads |
70 |
> pos = m.end() |
71 |
> f.close() |
72 |
> return lib,version |
73 |
> ------------------ |
74 |
> |
75 |
> It parses the header of an executable and guesses, but... the how is |
76 |
> too many directions from this that I'm not seeing it with my haphazard |
77 |
> abuse of grep. I'd presume anything that might care what platform it's |
78 |
> running on (underneath python itself) would be susceptible, so a word |
79 |
> thrown in the direction of upstream python would be the main way to |
80 |
> go... though it looks like emerge didn't used to use that call... |
81 |
> |
82 |
> Portage 2.1.4.5 (default/linux/x86/2008.0, gcc-4.1.2, glibc-2.6.1-r0, |
83 |
> 2.6.25-gentoo-r7-mahain i686) |
84 |
> ================================================================= |
85 |
> System uname: 2.6.25-gentoo-r7-mahain i686 AMD Athlon(tm) MP 2400+ |
86 |
> |
87 |
> is my output, based on a call in emerge to "uname -mrp" .. not |
88 |
> platform.platform() |
89 |
> |
90 |
> Looks like gentoo-dev aimed to drop that dependency in newer versions after all. |
91 |
The creator of paludis was right ... portage is a jack of all trades |
92 |
and a master of none. |
93 |
|
94 |
|
95 |
|
96 |
-- |
97 |
Andrey Vul |
98 |
|
99 |
A: Because it messes up the order in which people normally read text. |
100 |
Q: Why is top-posting such a bad thing? |
101 |
A: Top-posting. |
102 |
Q: What is the most annoying thing in e-mail? |