From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([69.77.167.62] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1KvMN7-0004c7-Ew for garchives@archives.gentoo.org; Thu, 30 Oct 2008 01:30:51 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id EE843E0371; Thu, 30 Oct 2008 01:30:47 +0000 (UTC) Received: from mu-out-0910.google.com (mu-out-0910.google.com [209.85.134.189]) by pigeon.gentoo.org (Postfix) with ESMTP id 8B011E0371 for ; Thu, 30 Oct 2008 01:30:47 +0000 (UTC) Received: by mu-out-0910.google.com with SMTP id i2so273205mue.6 for ; Wed, 29 Oct 2008 18:30:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=tbJXlWpumhV2POWxQ2LP2HLkPGSeMXB2I7zPmUOX0Jg=; b=LvYycBnXdUQDCWJ3/ht20zjjfDA4n9vT7YHyksa5vpeq2Uc0f9kjeIR4+X0fhlLVPs OjSsZ3MbpaAM6OGgouEY5KwJIhgkpcJDiUxkvNCVgjkKrqloOw2TI3D10TkMJ3EIPzX/ IHJHrzAmshIsPgDYkSbnL7HMcXQXnVgZmedJU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=INdFX5F7W+dp3zRHtfUQYlcnMqEwIUdZC+RjiOfLDx5L+NBLpRoAQ7cK0aV/CX7xUC ofihlJ3KPxY/8LOFj0j/EtQX7HTEJHKCQ0uy3qStf/OlYGiE8Jml/4APClWw0ZwbjurN 0r4Qg1Zq7cKrtW086FUrpgLqNByTS0d1yw8rA= Received: by 10.103.22.16 with SMTP id z16mr1059469mui.97.1225330245744; Wed, 29 Oct 2008 18:30:45 -0700 (PDT) Received: by 10.103.204.9 with HTTP; Wed, 29 Oct 2008 18:30:45 -0700 (PDT) Message-ID: Date: Wed, 29 Oct 2008 21:30:45 -0400 From: "Andrey Vul" To: gentoo-user@lists.gentoo.org Subject: Re: [gentoo-user] A question about emerge --info In-Reply-To: Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-user@lists.gentoo.org Reply-to: gentoo-user@lists.gentoo.org MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <58965d8a0810291553x50e4068ehc58834dfdbce285b@mail.gmail.com> <350fc7cf0810291609v335f4909nbcd90ab7d368cb5d@mail.gmail.com> <350fc7cf0810291623j5fb5608rf311cd0d2a371d2a@mail.gmail.com> X-Archives-Salt: fdc1a682-41e8-4001-828b-97ead8902582 X-Archives-Hash: 328daa825ea92796a22ff33280fd8d78 On Wed, Oct 29, 2008 at 8:47 PM, Joshua Murphy wrote: > On Wed, Oct 29, 2008 at 7:51 PM, Andrey Vul wrote: > >> 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) > > > 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. Is it really better than making a small umake clone (to remove the coreutils dependency)? All *nixes (should) have uname, and you can scan PATH if uname exists. If it doesn't, then emerge & install the mini-uname. -- 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?