Gentoo Archives: gentoo-portage-dev

From: Ruud Koolen <redlizard@×××××××××.nl>
To: gentoo-portage-dev@l.g.o
Subject: [gentoo-portage-dev] [PATCH 2/3] Based GLOBAL_CONFIG_PATH and DEPCACHE_PATH on portage prefix
Date: Mon, 17 Jun 2013 07:24:08
Message-Id: 201306170923.58633.redlizard@redlizard.nl
In Reply to: [gentoo-portage-dev] [PATCH 0/3] Add cross-prefix support by Ruud Koolen
1 The GLOBAL_CONFIG_PATH constants and DEPCACHE_PATH constants should be
2 relative to the installation prefix of portage itself, not the installation
3 prefix of packages it is installing.
4 ---
5 pym/_emerge/actions.py | 6 ---
6 pym/portage/_sets/__init__.py | 3 --
7 pym/portage/const.py | 34 ++++++++++----------
8 .../package/ebuild/_config/LocationsManager.py | 22 -------------
9 pym/portage/package/ebuild/config.py | 15 ---------
10 pym/portage/package/ebuild/fetch.py | 4 --
11 pym/portage/tests/resolver/ResolverPlayground.py | 3 +-
12 7 files changed, 18 insertions(+), 69 deletions(-)
13
14 diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py
15 index 767a614..c76aefc 100644
16 --- a/pym/_emerge/actions.py
17 +++ b/pym/_emerge/actions.py
18 @@ -2019,9 +2019,6 @@ def action_sync(settings, trees, mtimedb, myopts, myaction):
19 myportdir = None
20 out = portage.output.EOutput()
21 global_config_path = GLOBAL_CONFIG_PATH
22 - if settings['EPREFIX']:
23 - global_config_path = os.path.join(settings['EPREFIX'],
24 - GLOBAL_CONFIG_PATH.lstrip(os.sep))
25 if not myportdir:
26 sys.stderr.write("!!! PORTDIR is undefined. " + \
27 "Is %s/make.globals missing?\n" % global_config_path)
28 @@ -3332,9 +3329,6 @@ def missing_sets_warning(root_config, missing_sets):
29 if root_config.sets:
30 msg.append(" sets defined: %s" % ", ".join(root_config.sets))
31 global_config_path = portage.const.GLOBAL_CONFIG_PATH
32 - if root_config.settings['EPREFIX']:
33 - global_config_path = os.path.join(root_config.settings['EPREFIX'],
34 - portage.const.GLOBAL_CONFIG_PATH.lstrip(os.sep))
35 msg.append(" This usually means that '%s'" % \
36 (os.path.join(global_config_path, "sets/portage.conf"),))
37 msg.append(" is missing or corrupt.")
38 diff --git a/pym/portage/_sets/__init__.py b/pym/portage/_sets/__init__.py
39 index c196a70..8123af7 100644
40 --- a/pym/portage/_sets/__init__.py
41 +++ b/pym/portage/_sets/__init__.py
42 @@ -295,9 +295,6 @@ def load_default_config(settings, trees):
43 return SetConfig(None, settings, trees)
44
45 global_config_path = GLOBAL_CONFIG_PATH
46 - if settings['EPREFIX']:
47 - global_config_path = os.path.join(settings['EPREFIX'],
48 - GLOBAL_CONFIG_PATH.lstrip(os.sep))
49 def _getfiles():
50 for path, dirs, files in os.walk(os.path.join(global_config_path, "sets")):
51 for f in files:
52 diff --git a/pym/portage/const.py b/pym/portage/const.py
53 index 5e960d9..d22d144 100644
54 --- a/pym/portage/const.py
55 +++ b/pym/portage/const.py
56 @@ -52,10 +52,23 @@ WORLD_SETS_FILE = PRIVATE_PATH + "/world_sets"
57 CONFIG_MEMORY_FILE = PRIVATE_PATH + "/config"
58 NEWS_LIB_PATH = "var/lib/gentoo"
59
60 -# these variables get EPREFIX prepended automagically when they are
61 -# translated into their lowercase variants
62 -DEPCACHE_PATH = "/var/cache/edb/dep"
63 -GLOBAL_CONFIG_PATH = "/usr/share/portage/config"
64 +# The EPREFIX for the current install is hardcoded here, but access to this
65 +# constant should be minimal, in favor of access via the EPREFIX setting of
66 +# a config instance (since it's possible to contruct a config instance with
67 +# a different EPREFIX).
68 +EPREFIX=""
69 +
70 +# pick up EPREFIX from the environment if set
71 +if "PORTAGE_OVERRIDE_EPREFIX" in os.environ:
72 + EPREFIX = os.environ["PORTAGE_OVERRIDE_EPREFIX"]
73 + if EPREFIX:
74 + EPREFIX = os.path.normpath(EPREFIX)
75 +
76 +# these variables are based on the prefix of the portage installation, not
77 +# the prefix of the installed packages, and as such use the builtin EPREFIX
78 +# rather than the EPREFIX setting in a config instance.
79 +DEPCACHE_PATH = EPREFIX + "/var/cache/edb/dep"
80 +GLOBAL_CONFIG_PATH = EPREFIX + "/usr/share/portage/config"
81
82 # these variables are not used with target_root or config_root
83 # NOTE: Use realpath(__file__) so that python module symlinks in site-packages
84 @@ -152,19 +165,6 @@ MANIFEST2_REQUIRED_HASH = "SHA256"
85
86 MANIFEST2_IDENTIFIERS = ("AUX", "MISC", "DIST", "EBUILD")
87
88 -# The EPREFIX for the current install is hardcoded here, but access to this
89 -# constant should be minimal, in favor of access via the EPREFIX setting of
90 -# a config instance (since it's possible to contruct a config instance with
91 -# a different EPREFIX). Therefore, the EPREFIX constant should *NOT* be used
92 -# in the definition of any other constants within this file.
93 -EPREFIX=""
94 -
95 -# pick up EPREFIX from the environment if set
96 -if "PORTAGE_OVERRIDE_EPREFIX" in os.environ:
97 - EPREFIX = os.environ["PORTAGE_OVERRIDE_EPREFIX"]
98 - if EPREFIX:
99 - EPREFIX = os.path.normpath(EPREFIX)
100 -
101 VCS_DIRS = ("CVS", "RCS", "SCCS", ".bzr", ".git", ".hg", ".svn")
102
103 # ===========================================================================
104 diff --git a/pym/portage/package/ebuild/_config/LocationsManager.py b/pym/portage/package/ebuild/_config/LocationsManager.py
105 index 5057f95..4171807 100644
106 --- a/pym/portage/package/ebuild/_config/LocationsManager.py
107 +++ b/pym/portage/package/ebuild/_config/LocationsManager.py
108 @@ -275,29 +275,7 @@ class LocationsManager(object):
109
110 self.eroot = self.target_root.rstrip(os.sep) + self.eprefix + os.sep
111
112 - # make.globals should not be relative to config_root
113 - # because it only contains constants. However, if EPREFIX
114 - # is set then there are two possible scenarios:
115 - # 1) If $ROOT == "/" then make.globals should be
116 - # relative to EPREFIX.
117 - # 2) If $ROOT != "/" then the correct location of
118 - # make.globals needs to be specified in the constructor
119 - # parameters, since it's a property of the host system
120 - # (and the current config represents the target system).
121 self.global_config_path = GLOBAL_CONFIG_PATH
122 - if self.eprefix:
123 - if self.target_root == "/":
124 - # case (1) above
125 - self.global_config_path = os.path.join(self.eprefix,
126 - GLOBAL_CONFIG_PATH.lstrip(os.sep))
127 - else:
128 - # case (2) above
129 - # For now, just assume make.globals is relative
130 - # to EPREFIX.
131 - # TODO: Pass in more info to the constructor,
132 - # so we know the host system configuration.
133 - self.global_config_path = os.path.join(self.eprefix,
134 - GLOBAL_CONFIG_PATH.lstrip(os.sep))
135
136 def set_port_dirs(self, portdir, portdir_overlay):
137 self.portdir = portdir
138 diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/ebuild/config.py
139 index 1c29af9..ea3839f 100644
140 --- a/pym/portage/package/ebuild/config.py
141 +++ b/pym/portage/package/ebuild/config.py
142 @@ -781,21 +781,6 @@ class config(object):
143 self.backupenv["USE_ORDER"] = "env:pkg:conf:defaults:pkginternal:repo:env.d"
144
145 self.depcachedir = DEPCACHE_PATH
146 - if eprefix:
147 - # See comments about make.globals and EPREFIX
148 - # above. DEPCACHE_PATH is similar.
149 - if target_root == "/":
150 - # case (1) above
151 - self.depcachedir = os.path.join(eprefix,
152 - DEPCACHE_PATH.lstrip(os.sep))
153 - else:
154 - # case (2) above
155 - # For now, just assume DEPCACHE_PATH is relative
156 - # to EPREFIX.
157 - # TODO: Pass in more info to the constructor,
158 - # so we know the host system configuration.
159 - self.depcachedir = os.path.join(eprefix,
160 - DEPCACHE_PATH.lstrip(os.sep))
161
162 if self.get("PORTAGE_DEPCACHEDIR", None):
163 self.depcachedir = self["PORTAGE_DEPCACHEDIR"]
164 diff --git a/pym/portage/package/ebuild/fetch.py b/pym/portage/package/ebuild/fetch.py
165 index 50a1b72..4cdf326 100644
166 --- a/pym/portage/package/ebuild/fetch.py
167 +++ b/pym/portage/package/ebuild/fetch.py
168 @@ -865,10 +865,6 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0,
169 protocol = loc[0:loc.find("://")]
170
171 global_config_path = GLOBAL_CONFIG_PATH
172 - if mysettings['EPREFIX']:
173 - global_config_path = os.path.join(mysettings['EPREFIX'],
174 - GLOBAL_CONFIG_PATH.lstrip(os.sep))
175 -
176 missing_file_param = False
177 fetchcommand_var = "FETCHCOMMAND_" + protocol.upper()
178 fetchcommand = mysettings.get(fetchcommand_var)
179 diff --git a/pym/portage/tests/resolver/ResolverPlayground.py b/pym/portage/tests/resolver/ResolverPlayground.py
180 index bff4512..eb15e1c 100644
181 --- a/pym/portage/tests/resolver/ResolverPlayground.py
182 +++ b/pym/portage/tests/resolver/ResolverPlayground.py
183 @@ -426,8 +426,7 @@ class ResolverPlayground(object):
184 f.close()
185
186 #Create /usr/share/portage/config/make.globals
187 - make_globals_path = os.path.join(self.eroot,
188 - GLOBAL_CONFIG_PATH.lstrip(os.sep), "make.globals")
189 + make_globals_path = os.path.join(GLOBAL_CONFIG_PATH, "make.globals")
190 ensure_dirs(os.path.dirname(make_globals_path))
191 os.symlink(os.path.join(PORTAGE_BASE_PATH, "cnf", "make.globals"),
192 make_globals_path)
193 --
194 1.7.2.5