summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pym/portage/package/ebuild/config.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/ebuild/config.py
index bf33978e2..128888137 100644
--- a/pym/portage/package/ebuild/config.py
+++ b/pym/portage/package/ebuild/config.py
@@ -7,8 +7,10 @@ __all__ = [
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"] = str(eroot_st.st_gid)
default_inst_ids["PORTAGE_INST_UID"] = str(eroot_st.st_uid)
+ if "PORTAGE_USERNAME" not in self:
+ try:
+ pwd_struct = pwd.getpwuid(eroot_st.st_uid)
+ except KeyError:
+ pass
+ else:
+ self["PORTAGE_USERNAME"] = pwd_struct.pw_name
+ self.backup_changes("PORTAGE_USERNAME")
+
+ if "PORTAGE_GRPNAME" not in self:
+ try:
+ grp_struct = grp.getgrgid(eroot_st.st_gid)
+ except KeyError:
+ pass
+ else:
+ self["PORTAGE_GRPNAME"] = grp_struct.gr_name
+ self.backup_changes("PORTAGE_GRPNAME")
+
for var, default_val in default_inst_ids.items():
try:
self[var] = str(int(self.get(var, default_val)))