From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 2356C1389F5 for ; Mon, 17 Nov 2014 00:55:36 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 1939EE0D7A; Mon, 17 Nov 2014 00:55:31 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 0D0FAE0D63 for ; Mon, 17 Nov 2014 00:55:29 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id DD5A73404BB for ; Mon, 17 Nov 2014 00:55:27 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 3DAFD2A04 for ; Mon, 17 Nov 2014 00:55:25 +0000 (UTC) From: "Brian Dolbec" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Brian Dolbec" Message-ID: <1416185593.e409bc3aa41c61f50cd8712d36f7b8b097112283.dol-sen@gentoo> Subject: [gentoo-commits] proj/portage:repoman commit in: pym/repoman/ X-VCS-Repository: proj/portage X-VCS-Files: pym/repoman/main.py pym/repoman/repos.py X-VCS-Directories: pym/repoman/ X-VCS-Committer: dol-sen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: e409bc3aa41c61f50cd8712d36f7b8b097112283 X-VCS-Branch: repoman Date: Mon, 17 Nov 2014 00:55:25 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: b00f847b-a531-4b85-8240-35a6b21ab681 X-Archives-Hash: 4f7da6fa841d2f9ffac25c1e33793141 commit: e409bc3aa41c61f50cd8712d36f7b8b097112283 Author: Brian Dolbec gentoo org> AuthorDate: Tue Jun 3 18:00:05 2014 +0000 Commit: Brian Dolbec gmail com> CommitDate: Mon Nov 17 00:53:13 2014 +0000 URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=e409bc3a Repoman: Refactor repos.RepoSettings class, fix the repoman_settings not being re-assigned When the repo is not in the confiig'd repos, it creates a ne repoman_settings object which contains the temporaily activated repo. main.py was not re-assigning repoman_settings to the new object. Split out _add_repo() to it's own function. Split out the gpg-sign specific function for git into plugin-ready functions, for later. --- pym/repoman/main.py | 2 + pym/repoman/repos.py | 119 ++++++++++++++++++++++++++++++++------------------- 2 files changed, 77 insertions(+), 44 deletions(-) diff --git a/pym/repoman/main.py b/pym/repoman/main.py index 3b5296b..47ada0c 100755 --- a/pym/repoman/main.py +++ b/pym/repoman/main.py @@ -135,6 +135,8 @@ vcs_settings = VCSSettings(options, repoman_settings) repo_settings = RepoSettings(config_root, portdir, portdir_overlay, repoman_settings, vcs_settings, options, qawarnings) +repoman_settings = repo_settings.repoman_settings + portdb = repo_settings.portdb ################## diff --git a/pym/repoman/repos.py b/pym/repoman/repos.py index b79e241..6bd1eb4 100644 --- a/pym/repoman/repos.py +++ b/pym/repoman/repos.py @@ -26,75 +26,46 @@ class RepoSettings(object): def __init__(self, config_root, portdir, portdir_overlay, repoman_settings=None, vcs_settings=None, options=None, qawarnings=None): + self.repoman_settings = repoman_settings + self.vcs_settings = vcs_settings + # Ensure that current repository is in the list of enabled repositories. self.repodir = os.path.realpath(portdir_overlay) try: repoman_settings.repositories.get_repo_for_location(self.repodir) except KeyError: - self.repo_conf = portage.repository.config - self.repo_name = self.repo_conf.RepoConfig._read_valid_repo_name(portdir_overlay)[0] - self.layout_conf_data = self.repo_conf.parse_layout_conf(portdir_overlay)[0] - if self.layout_conf_data['repo-name']: - self.repo_name = self.layout_conf_data['repo-name'] - tmp_conf_file = io.StringIO(textwrap.dedent(""" - [%s] - location = %s - """) % (self.repo_name, portdir_overlay)) - # Ensure that the repository corresponding to $PWD overrides a - # repository of the same name referenced by the existing PORTDIR - # or PORTDIR_OVERLAY settings. - repoman_settings['PORTDIR_OVERLAY'] = "%s %s" % ( - repoman_settings.get('PORTDIR_OVERLAY', ''), - portage._shell_quote(portdir_overlay)) - self.repositories = self.repo_conf.load_repository_config( - repoman_settings, extra_files=[tmp_conf_file]) - # We have to call the config constructor again so that attributes - # dependent on config.repositories are initialized correctly. - repoman_settings = portage.config( - config_root=config_root, local_config=False, repositories=self.repositories) + self._add_repo(config_root, portdir_overlay) - self.root = repoman_settings['EROOT'] + self.root = self.repoman_settings['EROOT'] self.trees = { - self.root: {'porttree': portage.portagetree(settings=repoman_settings)} + self.root: {'porttree': portage.portagetree(settings=self.repoman_settings)} } self.portdb = self.trees[self.root]['porttree'].dbapi # Constrain dependency resolution to the master(s) # that are specified in layout.conf. - self.repo_config = repoman_settings.repositories.get_repo_for_location(self.repodir) + self.repo_config = self.repoman_settings.repositories.get_repo_for_location(self.repodir) self.portdb.porttrees = list(self.repo_config.eclass_db.porttrees) self.portdir = self.portdb.porttrees[0] self.commit_env = os.environ.copy() # list() is for iteration on a copy. - for repo in list(repoman_settings.repositories): + for repo in list(self.repoman_settings.repositories): # all paths are canonical if repo.location not in self.repo_config.eclass_db.porttrees: - del repoman_settings.repositories[repo.name] + del self.repoman_settings.repositories[repo.name] if self.repo_config.allow_provide_virtual: qawarnings.add("virtual.oldstyle") if self.repo_config.sign_commit: - if vcs_settings.vcs == 'git': - # NOTE: It's possible to use --gpg-sign=key_id to specify the key in - # the commit arguments. If key_id is unspecified, then it must be - # configured by `git config user.signingkey key_id`. - vcs_settings.vcs_local_opts.append("--gpg-sign") - if repoman_settings.get("PORTAGE_GPG_DIR"): - # Pass GNUPGHOME to git for bug #462362. - self.commit_env["GNUPGHOME"] = repoman_settings["PORTAGE_GPG_DIR"] - - # Pass GPG_TTY to git for bug #477728. - try: - self.commit_env["GPG_TTY"] = os.ttyname(sys.stdin.fileno()) - except OSError: - pass + func = getattr(self, '_vcs_gpg_%s' % vcs_settings.vcs) + func() # In order to disable manifest signatures, repos may set # "sign-manifests = false" in metadata/layout.conf. This # can be used to prevent merge conflicts like those that # thin-manifests is designed to prevent. - self.sign_manifests = "sign" in repoman_settings.features and \ + self.sign_manifests = "sign" in self.repoman_settings.features and \ self.repo_config.sign_manifest if self.repo_config.sign_manifest and self.repo_config.name == "gentoo" and \ @@ -110,13 +81,13 @@ class RepoSettings(object): logging.warn(line) is_commit = options.mode in ("commit",) - valid_gpg_key = repoman_settings.get("PORTAGE_GPG_KEY") and re.match( - r'^%s$' % GPG_KEY_ID_REGEX, repoman_settings["PORTAGE_GPG_KEY"]) + valid_gpg_key = self.repoman_settings.get("PORTAGE_GPG_KEY") and re.match( + r'^%s$' % GPG_KEY_ID_REGEX, self.repoman_settings["PORTAGE_GPG_KEY"]) if self.sign_manifests and is_commit and not valid_gpg_key: logging.error( "PORTAGE_GPG_KEY value is invalid: %s" % - repoman_settings["PORTAGE_GPG_KEY"]) + self.repoman_settings["PORTAGE_GPG_KEY"]) sys.exit(1) manifest_hashes = self.repo_config.manifest_hashes @@ -150,6 +121,66 @@ class RepoSettings(object): logging.error(line) sys.exit(1) + + def _add_repo(self, config_root, portdir_overlay): + self.repo_conf = portage.repository.config + self.repo_name = self.repo_conf.RepoConfig._read_valid_repo_name(portdir_overlay)[0] + self.layout_conf_data = self.repo_conf.parse_layout_conf(portdir_overlay)[0] + if self.layout_conf_data['repo-name']: + self.repo_name = self.layout_conf_data['repo-name'] + tmp_conf_file = io.StringIO(textwrap.dedent(""" + [%s] + location = %s + """) % (self.repo_name, portdir_overlay)) + # Ensure that the repository corresponding to $PWD overrides a + # repository of the same name referenced by the existing PORTDIR + # or PORTDIR_OVERLAY settings. + self.repoman_settings['PORTDIR_OVERLAY'] = "%s %s" % ( + self.repoman_settings.get('PORTDIR_OVERLAY', ''), + portage._shell_quote(portdir_overlay)) + self.repositories = self.repo_conf.load_repository_config( + self.repoman_settings, extra_files=[tmp_conf_file]) + # We have to call the config constructor again so that attributes + # dependent on config.repositories are initialized correctly. + self.repoman_settings = portage.config( + config_root=config_root, local_config=False, repositories=self.repositories) + + ########### future vcs plugin functions + + def _vcs_gpg_bzr(self): + pass + + + def _vcs_gpg_cvs(self): + pass + + + def _vcs_gpg_git(self): + # NOTE: It's possible to use --gpg-sign=key_id to specify the key in + # the commit arguments. If key_id is unspecified, then it must be + # configured by `git config user.signingkey key_id`. + self.vcs_settings.vcs_local_opts.append("--gpg-sign") + if self.repoman_settings.get("PORTAGE_GPG_DIR"): + # Pass GNUPGHOME to git for bug #462362. + self.commit_env["GNUPGHOME"] = self.repoman_settings["PORTAGE_GPG_DIR"] + + # Pass GPG_TTY to git for bug #477728. + try: + self.commit_env["GPG_TTY"] = os.ttyname(sys.stdin.fileno()) + except OSError: + pass + + + def _vcs_gpg_hg(self): + pass + + + def _vcs_gpg_svn(self): + pass + + + + def list_checks(kwlist, liclist, uselist, repoman_settings): liclist_deprecated = set() if "DEPRECATED" in repoman_settings._license_manager._license_groups: