/[gentoo-src]/portage/pym/portage_data.py
Gentoo

Contents of /portage/pym/portage_data.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (show annotations) (download) (as text)
Sat Feb 26 06:35:20 2005 UTC (9 years, 7 months ago) by jstubbs
Branch: MAIN
CVS Tags: HEAD
Branch point for: portage_2_1
Changes since 1.6: +2 -1 lines
File MIME type: text/x-python
Brought forward changes from portage_2_0

1 # portage_data.py -- Calculated/Discovered Data Values
2 # Copyright 1998-2004 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4 # $Header: /var/cvsroot/gentoo-src/portage/pym/portage_data.py,v 1.6 2004/11/07 11:58:29 ferringb Exp $
5 cvs_id_string="$Id: portage_data.py,v 1.5.2.1 2005/01/16 02:35:33 carpaski Exp $"[5:-2]
6
7 import os,pwd,grp
8 from portage_util import writemsg
9 from output import green,red
10
11 ostype=os.uname()[0]
12
13 lchown = None
14 if ostype=="Linux":
15 userland="GNU"
16 os.environ["XARGS"]="xargs -r"
17 elif ostype in ["Darwin","FreeBSD","OpenBSD"]:
18 if ostype == "Darwin":
19 lchown=os.chown
20 userland="BSD"
21 os.environ["XARGS"]="xargs"
22 else:
23 writemsg(red("Operating system")+" \""+ostype+"\" "+red("currently unsupported. Exiting.")+"\n")
24 sys.exit(1)
25
26 if not lchown:
27 if "lchown" in dir(os):
28 # Included in python-2.3
29 lchown = os.lchown
30 else:
31 import missingos
32 lchown = missingos.lchown
33
34
35
36 os.environ["USERLAND"]=userland
37
38 #Secpass will be set to 1 if the user is root or in the portage group.
39 secpass=0
40
41 uid=os.getuid()
42 wheelgid=0
43
44 if uid==0:
45 secpass=2
46 try:
47 wheelgid=grp.getgrnam("wheel")[2]
48 if (not secpass) and (wheelgid in os.getgroups()):
49 secpass=1
50 except KeyError:
51 writemsg("portage initialization: your system doesn't have a 'wheel' group.\n")
52 writemsg("Please fix this as it is a normal system requirement. 'wheel' is GID 10\n")
53 writemsg("'emerge baselayout' and an 'etc-update' should remedy this problem.\n")
54 pass
55
56 #Discover the uid and gid of the portage user/group
57 try:
58 portage_uid=pwd.getpwnam("portage")[2]
59 portage_gid=grp.getgrnam("portage")[2]
60 if (secpass==0):
61 secpass=1
62 except KeyError:
63 portage_uid=0
64 portage_gid=wheelgid
65 writemsg("\n")
66 writemsg( red("portage: 'portage' user or group missing. Please update baselayout\n"))
67 writemsg( red(" and merge portage user(250) and group(250) into your passwd\n"))
68 writemsg( red(" and group files. Non-root compilation is disabled until then.\n"))
69 writemsg( " Also note that non-root/wheel users will need to be added to\n")
70 writemsg( " the portage group to do portage commands.\n")
71 writemsg("\n")
72 writemsg( " For the defaults, line 1 goes into passwd, and 2 into group.\n")
73 writemsg(green(" portage:x:250:250:portage:/var/tmp/portage:/bin/false\n"))
74 writemsg(green(" portage::250:portage\n"))
75 writemsg("\n")
76
77 if (uid!=0) and (portage_gid not in os.getgroups()):
78 if not os.environ.has_key("PORTAGE_SCRIPT"):
79 writemsg("\n")
80 writemsg(red("*** You are not in the portage group. You may experience cache problems\n"))
81 writemsg(red("*** due to permissions preventing the creation of the on-disk cache.\n"))
82 writemsg(red("*** Please add this user to the portage group if you wish to use portage.\n"))
83 writemsg("\n")

  ViewVC Help
Powered by ViewVC 1.1.20