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