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 4A56E1393F1 for ; Thu, 17 Sep 2015 04:52:12 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 6BF8521C06C; Thu, 17 Sep 2015 04:51:47 +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 5445021C068 for ; Thu, 17 Sep 2015 04:51:44 +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 76B9B340C24 for ; Thu, 17 Sep 2015 04:51:43 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 4F44922C for ; Thu, 17 Sep 2015 04:51:39 +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: <1442464888.1b2e25d7d5d283962b257f9d9c645650de037cc0.dolsen@gentoo> Subject: [gentoo-commits] proj/portage:repoman commit in: pym/repoman/ X-VCS-Repository: proj/portage X-VCS-Files: pym/repoman/main.py X-VCS-Directories: pym/repoman/ X-VCS-Committer: dolsen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: 1b2e25d7d5d283962b257f9d9c645650de037cc0 X-VCS-Branch: repoman Date: Thu, 17 Sep 2015 04:51:39 +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: 0584f03b-2c33-4f05-a3eb-3cbc2f2de699 X-Archives-Hash: 739c06c9e6b6f4aa7524180e0e1127e0 commit: 1b2e25d7d5d283962b257f9d9c645650de037cc0 Author: Brian Dolbec gentoo org> AuthorDate: Thu Sep 17 00:13:13 2015 +0000 Commit: Brian Dolbec gentoo org> CommitDate: Thu Sep 17 04:41:28 2015 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=1b2e25d7 repoman/main.py: Move some functions out of the main code definition Move gpgsign and need_signature to their own file: gpg.py Move sort_key() to the main body ahead of the main code. Signed-off-by: Brian Dolbec gentoo.org> pym/repoman/main.py | 78 +++++------------------------------------------------ 1 file changed, 7 insertions(+), 71 deletions(-) diff --git a/pym/repoman/main.py b/pym/repoman/main.py index 4dbc09e..e276aba 100755 --- a/pym/repoman/main.py +++ b/pym/repoman/main.py @@ -38,7 +38,6 @@ import portage.repository.config from portage import cvstree, normalize_path from portage import util from portage.dep import Atom -from portage.exception import MissingParameter from portage.process import find_binary, spawn from portage.output import ( bold, create_color_func, green, nocolor, red) @@ -67,6 +66,7 @@ from repoman.checks.ebuilds.variables.license import LicenseChecks from repoman.checks.ebuilds.variables.restrict import RestrictChecks from repoman.ebuild import Ebuild from repoman.errors import err +from repoman.gpg import gpgsign, need_signature from repoman.modules.commit import repochecks from repoman.profile import check_profiles, dev_keywords, setup_profile from repoman.qa_data import ( @@ -97,6 +97,11 @@ non_ascii_re = re.compile(r'[^\x00-\x7f]') # A sane umask is needed for files that portage creates. os.umask(0o22) + +def sort_key(item): + return item[2].sub_path + + # Repoman sets it's own ACCEPT_KEYWORDS and we don't want it to # behave incrementally. repoman_incrementals = tuple( @@ -673,9 +678,6 @@ for xpkg in effective_scanlist: relevant_profiles.extend( (keyword, groups, prof) for prof in profiles[arch]) - def sort_key(item): - return item[2].sub_path - relevant_profiles.sort(key=sort_key) for keyword, groups, prof in relevant_profiles: @@ -1441,72 +1443,6 @@ else: except OSError: pass - # Setup the GPG commands - def gpgsign(filename): - gpgcmd = repoman_settings.get("PORTAGE_GPG_SIGNING_COMMAND") - if gpgcmd in [None, '']: - raise MissingParameter("PORTAGE_GPG_SIGNING_COMMAND is unset!" - " Is make.globals missing?") - if "${PORTAGE_GPG_KEY}" in gpgcmd and \ - "PORTAGE_GPG_KEY" not in repoman_settings: - raise MissingParameter("PORTAGE_GPG_KEY is unset!") - if "${PORTAGE_GPG_DIR}" in gpgcmd: - if "PORTAGE_GPG_DIR" not in repoman_settings: - repoman_settings["PORTAGE_GPG_DIR"] = \ - os.path.expanduser("~/.gnupg") - logging.info( - "Automatically setting PORTAGE_GPG_DIR to '%s'" % - repoman_settings["PORTAGE_GPG_DIR"]) - else: - repoman_settings["PORTAGE_GPG_DIR"] = \ - os.path.expanduser(repoman_settings["PORTAGE_GPG_DIR"]) - if not os.access(repoman_settings["PORTAGE_GPG_DIR"], os.X_OK): - raise portage.exception.InvalidLocation( - "Unable to access directory: PORTAGE_GPG_DIR='%s'" % - repoman_settings["PORTAGE_GPG_DIR"]) - gpgvars = {"FILE": filename} - for k in ("PORTAGE_GPG_DIR", "PORTAGE_GPG_KEY"): - v = repoman_settings.get(k) - if v is not None: - gpgvars[k] = v - gpgcmd = portage.util.varexpand(gpgcmd, mydict=gpgvars) - if options.pretend: - print("(" + gpgcmd + ")") - else: - # Encode unicode manually for bug #310789. - gpgcmd = portage.util.shlex_split(gpgcmd) - - if sys.hexversion < 0x3020000 and sys.hexversion >= 0x3000000 and \ - not os.path.isabs(gpgcmd[0]): - # Python 3.1 _execvp throws TypeError for non-absolute executable - # path passed as bytes (see http://bugs.python.org/issue8513). - fullname = find_binary(gpgcmd[0]) - if fullname is None: - raise portage.exception.CommandNotFound(gpgcmd[0]) - gpgcmd[0] = fullname - - gpgcmd = [ - _unicode_encode(arg, encoding=_encodings['fs'], errors='strict') - for arg in gpgcmd] - rValue = subprocess.call(gpgcmd) - if rValue == os.EX_OK: - os.rename(filename + ".asc", filename) - else: - raise portage.exception.PortageException( - "!!! gpg exited with '" + str(rValue) + "' status") - - def need_signature(filename): - try: - with open( - _unicode_encode( - filename, encoding=_encodings['fs'], errors='strict'), - 'rb') as f: - return b"BEGIN PGP SIGNED MESSAGE" not in f.readline() - except IOError as e: - if e.errno in (errno.ENOENT, errno.ESTALE): - return False - raise - # When files are removed and re-added, the cvs server will put /Attic/ # inside the $Header path. This code detects the problem and corrects it # so that the Manifest will generate correctly. See bug #169500. @@ -1557,7 +1493,7 @@ else: manifest_path = os.path.join(repoman_settings["O"], "Manifest") if not need_signature(manifest_path): continue - gpgsign(manifest_path) + gpgsign(manifest_path, repoman_settings, options) except portage.exception.PortageException as e: portage.writemsg("!!! %s\n" % str(e)) portage.writemsg("!!! Disabled FEATURES='sign'\n")