From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1RZ9g7-0000j6-Hr for garchives@archives.gentoo.org; Fri, 09 Dec 2011 23:16:31 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 09A8621C0AF; Fri, 9 Dec 2011 23:16:22 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id D0E5A21C0AF for ; Fri, 9 Dec 2011 23:16:22 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 5746464194 for ; Fri, 9 Dec 2011 23:16:22 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 9074D80042 for ; Fri, 9 Dec 2011 23:16:21 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <9ba122ee2242369aed344e3756d29c9b153bdbc8.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/package/ebuild/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/package/ebuild/config.py X-VCS-Directories: pym/portage/package/ebuild/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 9ba122ee2242369aed344e3756d29c9b153bdbc8 Date: Fri, 9 Dec 2011 23:16:21 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: 874e6ebf-f968-49a9-8b16-14a4d82b3f7f X-Archives-Hash: 60885dcdf54a0b86508410a3b691db2c commit: 9ba122ee2242369aed344e3756d29c9b153bdbc8 Author: Zac Medico gentoo org> AuthorDate: Fri Dec 9 23:16:08 2011 +0000 Commit: Zac Medico gentoo org> CommitDate: Fri Dec 9 23:16:08 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3D9ba122ee Auto-generate PORTAGE_GRP/USERNAME for prefix. For prefix environments, default to the UID and GID of the top-level EROOT directory. This allows us to avoid using hardcoded defaults. It's still possible to override these variables via make.conf. --- pym/portage/package/ebuild/config.py | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-) diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/e= build/config.py index bf33978..1288881 100644 --- a/pym/portage/package/ebuild/config.py +++ b/pym/portage/package/ebuild/config.py @@ -7,8 +7,10 @@ __all__ =3D [ =20 import copy from itertools import chain +import grp import logging import platform +import pwd import re import sys import warnings @@ -739,6 +741,24 @@ class config(object): default_inst_ids["PORTAGE_INST_GID"] =3D str(eroot_st.st_gid) default_inst_ids["PORTAGE_INST_UID"] =3D str(eroot_st.st_uid) =20 + if "PORTAGE_USERNAME" not in self: + try: + pwd_struct =3D pwd.getpwuid(eroot_st.st_uid) + except KeyError: + pass + else: + self["PORTAGE_USERNAME"] =3D pwd_struct.pw_name + self.backup_changes("PORTAGE_USERNAME") + + if "PORTAGE_GRPNAME" not in self: + try: + grp_struct =3D grp.getgrgid(eroot_st.st_gid) + except KeyError: + pass + else: + self["PORTAGE_GRPNAME"] =3D grp_struct.gr_name + self.backup_changes("PORTAGE_GRPNAME") + for var, default_val in default_inst_ids.items(): try: self[var] =3D str(int(self.get(var, default_val)))