Lines 29-35
_profile_node = collections.namedtuple('_profile_node',
Link Here
|
29 |
'location portage1_directories') |
29 |
'location portage1_directories') |
30 |
|
30 |
|
31 |
_allow_directories = frozenset( |
31 |
_allow_directories = frozenset( |
32 |
["portage-1-compat", "portage-1"]) |
32 |
["portage-1-compat", "portage-1", "portage-2"]) |
|
|
33 |
|
34 |
_allow_parent_colon = frozenset( |
35 |
["portage-2"]) |
33 |
|
36 |
|
34 |
class LocationsManager(object): |
37 |
class LocationsManager(object): |
35 |
|
38 |
|
Lines 96-102
class LocationsManager(object):
Link Here
|
96 |
if self.profile_path: |
99 |
if self.profile_path: |
97 |
try: |
100 |
try: |
98 |
self._addProfile(os.path.realpath(self.profile_path), |
101 |
self._addProfile(os.path.realpath(self.profile_path), |
99 |
known_repos) |
102 |
repositories, known_repos) |
100 |
except ParseError as e: |
103 |
except ParseError as e: |
101 |
writemsg(_("!!! Unable to parse profile: '%s'\n") % \ |
104 |
writemsg(_("!!! Unable to parse profile: '%s'\n") % \ |
102 |
self.profile_path, noiselevel=-1) |
105 |
self.profile_path, noiselevel=-1) |
Lines 123-131
class LocationsManager(object):
Link Here
|
123 |
noiselevel=-1) |
126 |
noiselevel=-1) |
124 |
raise DirectoryNotFound(var) |
127 |
raise DirectoryNotFound(var) |
125 |
|
128 |
|
126 |
def _addProfile(self, currentPath, known_repos): |
129 |
def _addProfile(self, currentPath, repositories, known_repos): |
127 |
current_abs_path = os.path.abspath(currentPath) |
130 |
current_abs_path = os.path.abspath(currentPath) |
128 |
allow_directories = True |
131 |
allow_directories = True |
|
|
132 |
allow_parent_colon = True |
129 |
repo_loc = None |
133 |
repo_loc = None |
130 |
compat_mode = False |
134 |
compat_mode = False |
131 |
intersecting_repos = [x for x in known_repos if current_abs_path.startswith(x[0])] |
135 |
intersecting_repos = [x for x in known_repos if current_abs_path.startswith(x[0])] |
Lines 136-141
class LocationsManager(object):
Link Here
|
136 |
allow_directories = any(x in _allow_directories |
140 |
allow_directories = any(x in _allow_directories |
137 |
for x in layout_data['profile-formats']) |
141 |
for x in layout_data['profile-formats']) |
138 |
compat_mode = layout_data['profile-formats'] == ('portage-1-compat',) |
142 |
compat_mode = layout_data['profile-formats'] == ('portage-1-compat',) |
|
|
143 |
allow_parent_colon = any(x in _allow_parent_colon |
144 |
for x in layout_data['profile-formats']) |
139 |
|
145 |
|
140 |
if compat_mode: |
146 |
if compat_mode: |
141 |
offenders = _PORTAGE1_DIRECTORIES.intersection(os.listdir(currentPath)) |
147 |
offenders = _PORTAGE1_DIRECTORIES.intersection(os.listdir(currentPath)) |
Lines 177-182
class LocationsManager(object):
Link Here
|
177 |
_("Empty parent file: '%s'") % parentsFile) |
183 |
_("Empty parent file: '%s'") % parentsFile) |
178 |
for parentPath in parents: |
184 |
for parentPath in parents: |
179 |
abs_parent = parentPath[:1] == os.sep |
185 |
abs_parent = parentPath[:1] == os.sep |
|
|
186 |
if not abs_parent and allow_parent_colon: |
187 |
parentPath = self._expand_parent_colon(parentsFile, |
188 |
parentPath, repo_loc, repositories) |
189 |
|
190 |
# NOTE: This os.path.join() call is intended to ignore |
191 |
# currentPath if parentPath is already absolute. |
180 |
parentPath = normalize_path(os.path.join( |
192 |
parentPath = normalize_path(os.path.join( |
181 |
currentPath, parentPath)) |
193 |
currentPath, parentPath)) |
182 |
|
194 |
|
Lines 187-193
class LocationsManager(object):
Link Here
|
187 |
parentPath = os.path.realpath(parentPath) |
199 |
parentPath = os.path.realpath(parentPath) |
188 |
|
200 |
|
189 |
if os.path.exists(parentPath): |
201 |
if os.path.exists(parentPath): |
190 |
self._addProfile(parentPath, known_repos) |
202 |
self._addProfile(parentPath, repositories, known_repos) |
191 |
else: |
203 |
else: |
192 |
raise ParseError( |
204 |
raise ParseError( |
193 |
_("Parent '%s' not found: '%s'") % \ |
205 |
_("Parent '%s' not found: '%s'") % \ |
Lines 197-202
class LocationsManager(object):
Link Here
|
197 |
self.profiles_complex.append( |
209 |
self.profiles_complex.append( |
198 |
_profile_node(currentPath, allow_directories)) |
210 |
_profile_node(currentPath, allow_directories)) |
199 |
|
211 |
|
|
|
212 |
def _expand_parent_colon(self, parentsFile, parentPath, |
213 |
repo_loc, repositories): |
214 |
colon = parentPath.find(":") |
215 |
if colon == -1: |
216 |
return parentPath |
217 |
|
218 |
if colon == 0: |
219 |
if repo_loc is None: |
220 |
raise ParseError( |
221 |
_("Parent '%s' not found: '%s'") % \ |
222 |
(parentPath, parentsFile)) |
223 |
else: |
224 |
parentPath = normalize_path(os.path.join( |
225 |
repo_loc, 'profiles', parentPath[colon+1:])) |
226 |
else: |
227 |
p_repo_name = parentPath[:colon] |
228 |
try: |
229 |
p_repo_loc = repositories.get_location_for_name(p_repo_name) |
230 |
except KeyError: |
231 |
raise ParseError( |
232 |
_("Parent '%s' not found: '%s'") % \ |
233 |
(parentPath, parentsFile)) |
234 |
else: |
235 |
parentPath = normalize_path(os.path.join( |
236 |
p_repo_loc, 'profiles', parentPath[colon+1:])) |
237 |
|
238 |
return parentPath |
239 |
|
200 |
def set_root_override(self, root_overwrite=None): |
240 |
def set_root_override(self, root_overwrite=None): |
201 |
# Allow ROOT setting to come from make.conf if it's not overridden |
241 |
# Allow ROOT setting to come from make.conf if it's not overridden |
202 |
# by the constructor argument (from the calling environment). |
242 |
# by the constructor argument (from the calling environment). |