From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1RIonr-0000qI-QX for garchives@archives.gentoo.org; Tue, 25 Oct 2011 21:45:00 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id C475921C07A; Tue, 25 Oct 2011 21:44:50 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 7A41721C07A for ; Tue, 25 Oct 2011 21:44:50 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id D01C01B401A for ; Tue, 25 Oct 2011 21:44:49 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 42EB880042 for ; Tue, 25 Oct 2011 21:44:49 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <0be173a54a5248cfd70a3543d7099d2dd3ee254b.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/repository/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/repository/config.py X-VCS-Directories: pym/portage/repository/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 0be173a54a5248cfd70a3543d7099d2dd3ee254b Date: Tue, 25 Oct 2011 21:44:49 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 8f4f178d02d2be551f57d0ff435acc6d commit: 0be173a54a5248cfd70a3543d7099d2dd3ee254b Author: Brian Harring chromium org> AuthorDate: Tue Oct 25 00:38:33 2011 +0000 Commit: Zac Medico gentoo org> CommitDate: Tue Oct 25 21:36:42 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3D0be173a5 split out layout.conf parsing so it's usable elsewhere --- pym/portage/repository/config.py | 155 +++++++++++++++++++++-----------= ------ 1 files changed, 86 insertions(+), 69 deletions(-) diff --git a/pym/portage/repository/config.py b/pym/portage/repository/co= nfig.py index fddba6c..fe2bd33 100644 --- a/pym/portage/repository/config.py +++ b/pym/portage/repository/config.py @@ -358,82 +358,27 @@ class RepoConfigLoader(object): if not repo.location: continue layout_filename =3D os.path.join(repo.location, "metadata", "layout.c= onf") - layout_file =3D KeyValuePairFileLoader(layout_filename, None, None) - layout_data, layout_errors =3D layout_file.load() - - # Only set masters here if is None, so that repos.conf settings - # will override those from layout.conf. This gives the - # user control over inherited repositories and their settings - # (the user must ensure that any required dependencies such as - # eclasses are satisfied). + layout_data, layout_errors =3D parse_layout_conf(repo.location, repo.= name) + if repo.masters is None: - masters =3D layout_data.get('masters') - if masters is not None: - # We support empty masters settings here, in case a - # repo wants to avoid implicit inheritance of PORTDIR - # settings like package.mask. - masters =3D tuple(masters.split()) - repo.masters =3D masters + repo.masters =3D layout_data['masters'] =20 aliases =3D layout_data.get('aliases') if aliases and aliases.strip(): aliases =3D aliases.split() else: aliases =3D None - if aliases: - if repo.aliases: - aliases.extend(repo.aliases) - repo.aliases =3D tuple(sorted(set(aliases))) - - if layout_data.get('sign-manifests', '').lower() =3D=3D 'false': - repo.sign_manifest =3D False - - if layout_data.get('thin-manifests', '').lower() =3D=3D 'true': - repo.thin_manifest =3D True - - manifest_policy =3D layout_data.get('use-manifests', 'strict').lower(= ) - repo.allow_missing_manifest =3D manifest_policy !=3D 'strict' - repo.create_manifest =3D manifest_policy !=3D 'false' - repo.disable_manifest =3D manifest_policy =3D=3D 'false' - - # for compatibility w/ PMS, fallback to pms; but also check if the - # cache exists or not. - repo.cache_format =3D layout_data.get('cache-format', 'pms').lower() - if repo.cache_format =3D=3D 'pms' and not os.path.isdir( - os.path.join(repo.location, 'metadata', 'cache')): - repo.cache_format =3D None - - manifest_hashes =3D layout_data.get('manifest-hashes') - if manifest_hashes is not None: - manifest_hashes =3D frozenset(manifest_hashes.upper().split()) - if MANIFEST2_REQUIRED_HASH not in manifest_hashes: - warnings.warn((_("Repository named '%(repo_name)s' has a " - "'manifest-hashes' setting that does not contain " - "the '%(hash)s' hash which is required by this " - "portage version. You will have to upgrade portage " - "if you want to generate valid manifests for this " - "repository: %(layout_filename)s") % - {"repo_name":repo.name, - "hash":MANIFEST2_REQUIRED_HASH, - "layout_filename":layout_filename}), - DeprecationWarning) - unsupported_hashes =3D manifest_hashes.difference( - MANIFEST2_HASH_FUNCTIONS) - if unsupported_hashes: - warnings.warn((_("Repository named '%(repo_name)s' has a " - "'manifest-hashes' setting that contains one " - "or more hash types '%(hashes)s' which are not supported by " - "this portage version. You will have to upgrade " - "portage if you want to generate valid manifests for " - "this repository: %(layout_filename)s") % - {"repo_name":repo.name, - "hashes":" ".join(sorted(unsupported_hashes)), - "layout_filename":layout_filename}), - DeprecationWarning) - repo.manifest_hashes =3D manifest_hashes - - if layout_data.get('update-changelog', '').lower() =3D=3D 'true': - repo.update_changelog =3D True + + if layout_data['aliases']: + aliases =3D repo.aliases + if aliases is None: + aliases =3D () + repo.aliases =3D tuple(aliases) + layout_data['aliases'] + + for value in ('sign-manifest', 'thin-manifest', 'allow-missing-manife= st', + 'create-manifest', 'disable-manifest', 'cache-format', 'manifest-has= hes', + 'update-changelog'): + setattr(repo, value.lower().replace("-", "_"), layout_data[value]) =20 #Take aliases into account. new_prepos =3D {} @@ -623,3 +568,75 @@ def load_repository_config(settings): repoconfigpaths.append(os.path.join(settings["PORTAGE_CONFIGROOT"], USER_CONFIG_PATH, "repos.conf")) return RepoConfigLoader(repoconfigpaths, settings) + + +def parse_layout_conf(repo_location, repo_name=3DNone): + if repo_name is None: + repo_name =3D "unspecified" + + layout_filename =3D os.path.join(repo_location, "metadata", "layout.con= f") + layout_file =3D KeyValuePairFileLoader(layout_filename, None, None) + layout_data, layout_errors =3D layout_file.load() + + data =3D {} + + # allow None to slip through; later code spots that as an indication + # that an explicit nulling of the overlaying is desired. + masters =3D layout_data.get('masters') + if masters is not None: + masters =3D tuple(masters.split()) + data['masters'] =3D masters + data['aliases'] =3D tuple(layout_data.get('aliases', '').split()) + + data['sign-manifest'] =3D layout_data.get('sign-manifests', 'true').low= er() \ + =3D=3D 'true' + + data['thin-manifest'] =3D layout_data.get('thin-manifests', 'false').lo= wer() \ + =3D=3D 'true' + + manifest_policy =3D layout_data.get('use-manifests', 'strict').lower() + data['allow-missing-manifest'] =3D manifest_policy !=3D 'strict' + data['create-manifest'] =3D manifest_policy !=3D 'false' + data['disable-manifest'] =3D manifest_policy =3D=3D 'false' + + # for compatibility w/ PMS, fallback to pms; but also check if the + # cache exists or not. + cache_format =3D layout_data.get('cache-format', 'pms').lower() + if cache_format =3D=3D 'pms' and not os.path.isdir( + os.path.join(repo_location, 'metadata', 'cache')): + cache_format =3D None + data['cache-format'] =3D cache_format + + manifest_hashes =3D layout_data.get('manifest-hashes') + if manifest_hashes is not None: + manifest_hashes =3D frozenset(manifest_hashes.upper().split()) + if MANIFEST2_REQUIRED_HASH not in manifest_hashes: + warnings.warn((_("Repository named '%(repo_name)s' has a " + "'manifest-hashes' setting that does not contain " + "the '%(hash)s' hash which is required by this " + "portage version. You will have to upgrade portage " + "if you want to generate valid manifests for this " + "repository: %(layout_filename)s") % + {"repo_name":repo.name, + "hash":MANIFEST2_REQUIRED_HASH, + "layout_filename":layout_filename}), + DeprecationWarning) + unsupported_hashes =3D manifest_hashes.difference( + MANIFEST2_HASH_FUNCTIONS) + if unsupported_hashes: + warnings.warn((_("Repository named '%(repo_name)s' has a " + "'manifest-hashes' setting that contains one " + "or more hash types '%(hashes)s' which are not supported by " + "this portage version. You will have to upgrade " + "portage if you want to generate valid manifests for " + "this repository: %(layout_filename)s") % + {"repo_name":repo_name, + "hashes":" ".join(sorted(unsupported_hashes)), + "layout_filename":layout_filename}), + DeprecationWarning) + data['manifest-hashes'] =3D manifest_hashes + + data['update-changelog'] =3D layout_data.get('update-changelog', 'false= ').lower() \ + =3D=3D 'false' + + return data, layout_errors