Gentoo Archives: gentoo-user

From: Andrey Vul <andrey.vul@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] A question about emerge --info
Date: Wed, 29 Oct 2008 23:51:48
Message-Id: e38d12ff0810291651y245cba2k89b9cb2b8ee39dd9@mail.gmail.com
In Reply to: Re: [gentoo-user] A question about emerge --info by Andrey Vul
1 Found the code, and it's actually part of python (as of 2.4).
2 Gentoo sets aliased to 1 when printing the system uname.
3 /usr/lib/python2.{4,5,6}/platform.py:
4
5 def _platform(*args):
6
7 """ Helper to format the platform string in a filename
8 compatible format e.g. "system-version-machine".
9 """
10 # Format the platform string
11 platform = string.join(
12 map(string.strip,
13 filter(len,args)),
14 '-')
15
16 # Cleanup some possible filename obstacles...
17 replace = string.replace
18 platform = replace(platform,' ','_')
19 platform = replace(platform,'/','-')
20 platform = replace(platform,'\\','-')
21 platform = replace(platform,':','-')
22 platform = replace(platform,';','-')
23 platform = replace(platform,'"','-')
24 platform = replace(platform,'(','-')
25 platform = replace(platform,')','-')
26
27 # No need to report 'unknown' information...
28 platform = replace(platform,'unknown','')
29
30 # Fold '--'s and remove trailing '-'
31 while 1:
32 cleaned = replace(platform,'--','-')
33 if cleaned == platform:
34 break
35 platform = cleaned
36 while platform[-1] == '-':
37 platform = platform[:-1]
38
39 return platform
40
41 def platform(aliased=0, terse=0):
42
43 """ Returns a single string identifying the underlying platform
44 with as much useful information as possible (but no more :).
45
46 The output is intended to be human readable rather than
47 machine parseable. It may look different on different
48 platforms and this is intended.
49
50 If "aliased" is true, the function will use aliases for
51 various platforms that report system names which differ from
52 their common names, e.g. SunOS will be reported as
53 Solaris. The system_alias() function is used to implement
54 this.
55
56 Setting terse to true causes the function to return only the
57 absolute minimum information needed to identify the platform.
58
59 """
60 result = _platform_cache.get((aliased, terse), None)
61 if result is not None:
62 return result
63
64 # Get uname information and then apply platform specific cosmetics
65 # to it...
66 system,node,release,version,machine,processor = uname()
67 if machine == processor:
68 processor = ''
69 if aliased:
70 system,release,version = system_alias(system,release,version)
71
72 if system == 'Windows':
73 # MS platforms
74 rel,vers,csd,ptype = win32_ver(version)
75 if terse:
76 platform = _platform(system,release)
77 else:
78 platform = _platform(system,release,version,csd)
79
80 elif system in ('Linux',):
81 # Linux based systems
82 distname,distversion,distid = dist('')
83 if distname and not terse:
84 platform = _platform(system,release,machine,processor,
85 'with',
86 distname,distversion,distid)
87 else:
88 # If the distribution name is unknown check for libc vs. glibc
89 libcname,libcversion = libc_ver(sys.executable)
90 platform = _platform(system,release,machine,processor,
91 'with',
92 libcname+libcversion)
93 elif system == 'Java':
94 # Java platforms
95 r,v,vminfo,(os_name,os_version,os_arch) = java_ver()
96 if terse:
97 platform = _platform(system,release,version)
98 else:
99 platform = _platform(system,release,version,
100 'on',
101 os_name,os_version,os_arch)
102
103 elif system == 'MacOS':
104 # MacOS platforms
105 if terse:
106 platform = _platform(system,release)
107 else:
108 platform = _platform(system,release,machine)
109
110 else:
111 # Generic handler
112 if terse:
113 platform = _platform(system,release)
114 else:
115 bits,linkage = architecture(sys.executable)
116 platform = _platform(system,release,machine,processor,bits,linkage)
117
118 _platform_cache[(aliased, terse)] = platform
119 return platform
120
121
122 Proof: run /usr/lib/python2.{4,5,6}/platform.py
123 aliased and terse have no effect wrt output (kernel_version-with-libc_version)
124 --
125 Andrey Vul
126
127 A: Because it messes up the order in which people normally read text.
128 Q: Why is top-posting such a bad thing?
129 A: Top-posting.
130 Q: What is the most annoying thing in e-mail?

Replies

Subject Author
Re: [gentoo-user] A question about emerge --info Andrey Falko <ma3oxuct@×××××.com>
Re: [gentoo-user] A question about emerge --info Joshua Murphy <poisonbl@×××××.com>