From a94d160dcddad551b9485fca20d63c92deb9d544 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Thu, 10 May 2012 15:45:42 -0700 Subject: [PATCH] Substitute ':' in profile parent for bug #414961. If "profile-formats = portage-2" is specified in metadata/layout.conf, then paths beginning with ':' in profile parent files will have the path of the parent repository's profile directory substituted in place of the colon. --- .../package/ebuild/_config/LocationsManager.py | 19 ++++++++++++++++--- pym/portage/repository/config.py | 7 +++++-- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/pym/portage/package/ebuild/_config/LocationsManager.py b/pym/portage/package/ebuild/_config/LocationsManager.py index 9c73612..e8d7edd 100644 --- a/pym/portage/package/ebuild/_config/LocationsManager.py +++ b/pym/portage/package/ebuild/_config/LocationsManager.py @@ -28,6 +28,12 @@ _PORTAGE1_DIRECTORIES = frozenset([ _profile_node = collections.namedtuple('_profile_node', 'location portage1_directories') +_allow_directories = frozenset( + ["portage-1-compat", "portage-1", "portage-2"]) + +_allow_parent_colon = frozenset( + ["portage-2"]) + class LocationsManager(object): def __init__(self, config_root=None, eprefix=None, config_profile_path=None, local_config=True, \ @@ -114,6 +120,7 @@ class LocationsManager(object): def _addProfile(self, currentPath, known_repos): current_abs_path = os.path.abspath(currentPath) allow_directories = True + allow_parent_colon = False repo_loc = None compat_mode = False intersecting_repos = [x for x in known_repos if current_abs_path.startswith(x[0])] @@ -121,9 +128,11 @@ class LocationsManager(object): # protect against nested repositories. Insane configuration, but the longest # path will be the correct one. repo_loc, layout_data = max(intersecting_repos, key=lambda x:len(x[0])) - allow_directories = any(x.startswith("portage-1") + allow_directories = any(x in _allow_directories for x in layout_data['profile-formats']) compat_mode = layout_data['profile-formats'] == ('portage-1-compat',) + allow_parent_colon = any(x in _allow_parent_colon + for x in layout_data['profile-formats']) if compat_mode: offenders = _PORTAGE1_DIRECTORIES.intersection(os.listdir(currentPath)) @@ -165,8 +174,12 @@ class LocationsManager(object): _("Empty parent file: '%s'") % parentsFile) for parentPath in parents: abs_parent = parentPath[:1] == os.sep - parentPath = normalize_path(os.path.join( - currentPath, parentPath)) + if allow_parent_colon and parentPath[:1] == ":": + parentPath = normalize_path(os.path.join( + repo_loc, 'profiles', parentPath[1:])) + else: + parentPath = normalize_path(os.path.join( + currentPath, parentPath)) if abs_parent or repo_loc is None or \ not parentPath.startswith(repo_loc): diff --git a/pym/portage/repository/config.py b/pym/portage/repository/config.py index defdb47..f9fe7ed 100644 --- a/pym/portage/repository/config.py +++ b/pym/portage/repository/config.py @@ -27,6 +27,9 @@ from portage import _unicode_encode from portage import _encodings from portage import manifest +_profile_formats = frozenset( + ['pms', 'portage-1', 'portage-2']) + _repo_name_sub_re = re.compile(r'[^\w-]') def _gen_valid_repo(name): @@ -760,7 +763,7 @@ def parse_layout_conf(repo_location, repo_name=None): raw_formats = ('portage-1-compat',) else: raw_formats = set(raw_formats.split()) - unknown = raw_formats.difference(['pms', 'portage-1']) + unknown = raw_formats.difference(_profile_formats) if unknown: repo_name = _get_repo_name(repo_location, cached=repo_name) warnings.warn((_("Repository named '%(repo_name)s' has unsupported " @@ -770,7 +773,7 @@ def parse_layout_conf(repo_location, repo_name=None): layout_filename=layout_filename, unknown_fmts=" ".join(unknown))), DeprecationWarning) - raw_formats = tuple(raw_formats.intersection(['pms', 'portage-1'])) + raw_formats = tuple(raw_formats.intersection(_profile_formats)) data['profile-formats'] = raw_formats return data, layout_errors -- 1.7.9.7