Gentoo Archives: gentoo-commits

From: Brian Dolbec <dolsen@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/gentoo-keys:gsoc-2016 commit in: gkeys-gen/gkeygen/
Date: Sat, 24 Dec 2016 09:41:22
Message-Id: 1482572426.6b82f9204cb0522b6393fe673d7c4ed4617183c9.dolsen@gentoo
1 commit: 6b82f9204cb0522b6393fe673d7c4ed4617183c9
2 Author: aeroniero33 <justthisthing <AT> gmail <DOT> com>
3 AuthorDate: Fri Jun 17 13:56:24 2016 +0000
4 Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
5 CommitDate: Sat Dec 24 09:40:26 2016 +0000
6 URL: https://gitweb.gentoo.org/proj/gentoo-keys.git/commit/?id=6b82f920
7
8 Made the default GPG config file overridable
9
10 <rebase edit> Remove trailing whitespace </edit Brian Dolbec>
11
12 gkeys-gen/gkeygen/actions.py | 22 ++++++++++++++++------
13 1 file changed, 16 insertions(+), 6 deletions(-)
14
15 diff --git a/gkeys-gen/gkeygen/actions.py b/gkeys-gen/gkeygen/actions.py
16 index aaedcd1..403c779 100644
17 --- a/gkeys-gen/gkeygen/actions.py
18 +++ b/gkeys-gen/gkeygen/actions.py
19 @@ -127,6 +127,21 @@ class Actions(object):
20 self.output = output
21 self.logger = logger
22
23 + def configure_config_file(self,args, gpghome):
24 + '''Creates the config file'''
25 + newgpgconfpath = os.path.join(gpghome, 'gpg.conf')
26 + defaultpath = '/usr/share/gnupg/gpg-conf.skel'
27 + file_exists = False
28 + while not file_exists:
29 + skelconfpath = py_input("Path of default gpg configuration file to use (default: %s) " %defaultpath)
30 + if len(skelconfpath) <= 0:
31 + skelconfpath = defaultpath
32 + file_exists = os.path.exists(skelconfpath)
33 + shutil.copy(skelconfpath, newgpgconfpath)
34 + with open(newgpgconfpath, 'a') as conf:
35 + for line in urlopen(self.config.get_key('gpg-urls', args.spec)):
36 + conf.write(_unicode(line.decode('utf-8')))
37 +
38
39 def genkey(self, args):
40 '''Generate a gpg key using a spec file'''
41 @@ -158,12 +173,7 @@ class Actions(object):
42 self.output(["\n* Creating gpg folder at %s" % gpghome_full_path])
43 ensure_dirs(gpghome)
44 # Copy default gpg-conf.skel and append glep63 requirements
45 - self.output(["* Creating gpg.conf file at %s" % gpghome_full_path])
46 - newgpgconfpath = os.path.join(gpghome, 'gpg.conf')
47 - shutil.copy('/usr/share/gnupg/gpg-conf.skel', newgpgconfpath)
48 - with open(newgpgconfpath, 'a') as conf:
49 - for line in urlopen(self.config.get_key('gpg-urls', args.spec)):
50 - conf.write(_unicode(line.decode('utf-8')))
51 + self.configure_config_file(args, gpghome)
52 # Key generation
53 ctx = gpgme.Context()
54 self.logger.info("MAIN: _action_genkey: Generating GPG key...")