From: "Brian Dolbec" <dolsen@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:repoman commit in: pym/repoman/
Date: Mon, 21 Sep 2015 23:47:55 +0000 (UTC) [thread overview]
Message-ID: <1442878965.001dd58b705449b08acb34a085673a69b41b697e.dolsen@gentoo> (raw)
Message-ID: <20150921234755.4f8-SkP8wLIo2-88kqyjSWkLLor75-sDIOnCqtr3cas@z> (raw)
commit: 001dd58b705449b08acb34a085673a69b41b697e
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Sep 17 00:13:13 2015 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Mon Sep 21 23:42:45 2015 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=001dd58b
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.
Add new file gpg.py
pym/repoman/gpg.py | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++
pym/repoman/main.py | 78 +++++-----------------------------------------------
2 files changed, 86 insertions(+), 71 deletions(-)
diff --git a/pym/repoman/gpg.py b/pym/repoman/gpg.py
new file mode 100644
index 0000000..a6c4c5f
--- /dev/null
+++ b/pym/repoman/gpg.py
@@ -0,0 +1,79 @@
+
+import errno
+import logging
+import subprocess
+import sys
+
+import portage
+from portage import os
+from portage import _encodings
+from portage import _unicode_encode
+from portage.exception import MissingParameter
+from portage.process import find_binary
+
+
+# Setup the GPG commands
+def gpgsign(filename, repoman_settings, options):
+ 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
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")
next reply other threads:[~2015-09-21 23:48 UTC|newest]
Thread overview: 124+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-21 23:51 Brian Dolbec [this message]
2015-09-21 23:47 ` [gentoo-commits] proj/portage:repoman commit in: pym/repoman/ Brian Dolbec
-- strict thread matches above, loose matches on Subject: below --
2016-04-29 17:24 [gentoo-commits] proj/portage:master " Brian Dolbec
2016-04-29 17:24 Brian Dolbec
2016-04-29 17:24 Brian Dolbec
2016-04-29 17:24 Brian Dolbec
2016-04-28 15:05 [gentoo-commits] proj/portage:repoman " Brian Dolbec
2016-04-29 17:24 ` [gentoo-commits] proj/portage:master " Brian Dolbec
2016-03-10 22:39 Brian Dolbec
2016-01-30 16:44 Brian Dolbec
2016-01-29 23:04 Brian Dolbec
2016-01-29 5:34 Brian Dolbec
2016-01-27 20:39 Brian Dolbec
2015-12-29 20:29 Zac Medico
2015-12-24 14:30 Brian Dolbec
2015-10-13 16:27 Michał Górny
2015-10-07 23:22 Brian Dolbec
2015-10-07 23:09 Brian Dolbec
2015-10-04 21:15 Brian Dolbec
2015-09-26 20:53 Brian Dolbec
2015-09-26 20:53 Brian Dolbec
2015-09-26 20:49 Brian Dolbec
2015-09-26 20:49 Brian Dolbec
2015-09-24 16:19 Brian Dolbec
2015-09-24 16:19 Brian Dolbec
2015-09-24 15:24 Brian Dolbec
2015-09-21 23:51 Brian Dolbec
2015-09-21 23:51 Brian Dolbec
2015-09-21 23:51 Brian Dolbec
2015-09-21 23:51 Brian Dolbec
2015-09-21 23:47 [gentoo-commits] proj/portage:repoman " Brian Dolbec
2015-09-21 23:51 ` [gentoo-commits] proj/portage:master " Brian Dolbec
2015-09-21 23:47 [gentoo-commits] proj/portage:repoman " Brian Dolbec
2015-09-21 23:51 ` [gentoo-commits] proj/portage:master " Brian Dolbec
2015-09-21 23:47 [gentoo-commits] proj/portage:repoman " Brian Dolbec
2015-09-21 23:51 ` [gentoo-commits] proj/portage:master " Brian Dolbec
2015-09-21 23:47 [gentoo-commits] proj/portage:repoman " Brian Dolbec
2015-09-21 23:51 ` [gentoo-commits] proj/portage:master " Brian Dolbec
2015-09-21 23:47 [gentoo-commits] proj/portage:repoman " Brian Dolbec
2015-09-21 23:51 ` [gentoo-commits] proj/portage:master " Brian Dolbec
2015-09-21 23:47 [gentoo-commits] proj/portage:repoman " Brian Dolbec
2015-09-21 23:51 ` [gentoo-commits] proj/portage:master " Brian Dolbec
2015-09-21 23:47 [gentoo-commits] proj/portage:repoman " Brian Dolbec
2015-09-21 23:51 ` [gentoo-commits] proj/portage:master " Brian Dolbec
2015-09-21 23:47 [gentoo-commits] proj/portage:repoman " Brian Dolbec
2015-09-21 23:51 ` [gentoo-commits] proj/portage:master " Brian Dolbec
2015-09-21 23:47 [gentoo-commits] proj/portage:repoman " Brian Dolbec
2015-09-21 23:51 ` [gentoo-commits] proj/portage:master " Brian Dolbec
2015-09-21 23:47 [gentoo-commits] proj/portage:repoman " Brian Dolbec
2015-09-21 23:51 ` [gentoo-commits] proj/portage:master " Brian Dolbec
2015-09-21 23:47 [gentoo-commits] proj/portage:repoman " Brian Dolbec
2015-09-21 23:51 ` [gentoo-commits] proj/portage:master " Brian Dolbec
2015-09-21 23:47 [gentoo-commits] proj/portage:repoman " Brian Dolbec
2015-09-21 23:51 ` [gentoo-commits] proj/portage:master " Brian Dolbec
2015-08-10 14:44 Michał Górny
2015-02-11 8:00 Michał Górny
2014-09-11 23:45 Brian Dolbec
2014-04-04 23:01 Brian Dolbec
2014-04-04 23:01 Brian Dolbec
2014-01-27 3:13 Chris Reffett
2013-08-08 17:33 Zac Medico
2013-05-24 19:00 Zac Medico
2013-04-22 21:08 Zac Medico
2013-03-19 16:50 Zac Medico
2013-03-15 3:30 Arfrever Frehtes Taifersar Arahesis
2013-03-14 17:18 Zac Medico
2013-02-11 9:50 Zac Medico
2013-01-19 19:11 Zac Medico
2013-01-01 23:40 Zac Medico
2013-01-01 23:23 Zac Medico
2012-12-15 20:08 Zac Medico
2012-11-22 22:12 Arfrever Frehtes Taifersar Arahesis
2012-11-22 21:53 Arfrever Frehtes Taifersar Arahesis
2012-11-22 21:51 Arfrever Frehtes Taifersar Arahesis
2012-10-31 14:11 Zac Medico
2012-10-08 14:17 Zac Medico
2012-09-12 4:56 Zac Medico
2012-09-10 21:07 Zac Medico
2012-09-10 5:52 Zac Medico
2012-09-10 5:46 Zac Medico
2012-06-21 1:02 Zac Medico
2012-06-09 2:03 Zac Medico
2012-06-08 2:52 Zac Medico
2012-06-04 4:06 Zac Medico
2012-06-04 3:25 Zac Medico
2012-06-02 6:24 Zac Medico
2012-06-02 6:24 Zac Medico
2012-06-02 5:14 Zac Medico
2012-06-01 3:32 Zac Medico
2012-06-01 2:23 Zac Medico
2012-05-31 22:27 Zac Medico
2012-05-31 0:59 Zac Medico
2012-05-30 23:56 Zac Medico
2012-05-30 23:20 Zac Medico
2012-05-25 16:18 Mike Frysinger
2012-04-23 20:18 Zac Medico
2012-04-23 20:16 Zac Medico
2012-04-23 20:08 Zac Medico
2012-04-22 23:01 Zac Medico
2012-04-22 22:58 Zac Medico
2012-04-22 22:53 Zac Medico
2012-03-05 0:01 Zac Medico
2012-02-15 0:04 Zac Medico
2012-02-12 23:32 Zac Medico
2011-10-26 18:13 Zac Medico
2011-10-21 8:11 Zac Medico
2011-10-21 7:38 Zac Medico
2011-10-21 7:20 Zac Medico
2011-10-21 7:06 Zac Medico
2011-10-21 4:53 Zac Medico
2011-10-21 1:27 Zac Medico
2011-10-20 21:51 Zac Medico
2011-10-20 21:29 Zac Medico
2011-10-20 21:26 Zac Medico
2011-10-20 20:40 Fabian Groffen
2011-10-20 20:40 Fabian Groffen
2011-10-20 19:11 Zac Medico
2011-10-17 15:53 Zac Medico
2011-10-17 3:47 Zac Medico
2011-10-17 1:11 Zac Medico
2011-10-17 0:14 Zac Medico
2011-10-15 12:42 Fabian Groffen
2011-09-24 19:30 Zac Medico
2011-09-10 19:40 Zac Medico
2011-08-30 16:26 Zac Medico
2011-08-09 6:44 Zac Medico
2011-07-08 8:08 Zac Medico
2011-07-08 7:47 Zac Medico
2011-07-08 7:13 Zac Medico
2011-05-31 22:25 Zac Medico
2011-04-20 23:58 Zac Medico
2011-02-28 20:39 Zac Medico
2011-02-28 5:27 Zac Medico
2011-02-19 23:49 Zac Medico
2011-02-13 7:52 Zac Medico
2011-02-05 0:58 Zac Medico
2011-02-04 5:02 zmedico
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1442878965.001dd58b705449b08acb34a085673a69b41b697e.dolsen@gentoo \
--to=dolsen@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox