Gentoo Archives: gentoo-commits

From: Brian Dolbec <brian.dolbec@×××××.com>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/layman:master commit in: layman/
Date: Wed, 28 Nov 2012 04:02:19
Message-Id: 1354075271.58a50b8ab5290b93631f6e20609936d426b360b8.dol-sen@gentoo
1 commit: 58a50b8ab5290b93631f6e20609936d426b360b8
2 Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
3 AuthorDate: Wed Nov 28 04:01:11 2012 +0000
4 Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
5 CommitDate: Wed Nov 28 04:01:11 2012 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=58a50b8a
7
8 properly detect and enable gpg signed list support. prevents a build failure if pygpg is not installed.
9
10 ---
11 layman/remotedb.py | 52 ++++++++++++++++++++++++++++++++++++----------------
12 1 files changed, 36 insertions(+), 16 deletions(-)
13
14 diff --git a/layman/remotedb.py b/layman/remotedb.py
15 index 851b89b..f8aea16 100644
16 --- a/layman/remotedb.py
17 +++ b/layman/remotedb.py
18 @@ -31,14 +31,22 @@ import sys
19 import urllib2
20 import hashlib
21
22 -from pygpg.config import GPGConfig
23 -from pygpg.gpg import GPG
24 +
25 +GPG_ENABLED = False
26 +try:
27 + from pygpg.config import GPGConfig
28 + from pygpg.gpg import GPG
29 + GPG_ENABLED = True
30 +except ImportError:
31 + pass
32 +
33
34 from layman.utils import encoder
35 from layman.dbbase import DbBase
36 from layman.version import VERSION
37 from layman.compatibility import fileopen
38
39 +
40 class RemoteDB(DbBase):
41 '''Handles fetching the remote overlay list.'''
42
43 @@ -46,6 +54,8 @@ class RemoteDB(DbBase):
44
45 self.config = config
46 self.output = config['output']
47 + self.detached_urls = []
48 + self.signed_urls = []
49
50 self.proxies = {}
51
52 @@ -62,20 +72,10 @@ class RemoteDB(DbBase):
53 self.urls = [i.strip()
54 for i in config['overlays'].split('\n') if len(i)]
55
56 - #pair up the list url and detached sig url
57 - d_urls = [i.strip()
58 - for i in config['gpg_detached_lists'].split('\n') if len(i)]
59 - self.detached_urls = []
60 - #for index in range(0, len(d_urls), 2):
61 - # self.detached_urls.append((d_urls[index], d_urls[index+1]))
62 - for i in d_urls:
63 - u = i.split()
64 - self.detached_urls.append((u[0], u[1]))
65 -
66 - self.signed_urls = [i.strip()
67 - for i in config['gpg_signed_lists'].split('\n') if len(i)]
68 -
69 - self.output.debug('RemoteDB.__init__(), url lists= \nself.urls: %s\nself.detached_urls: %s\nself.signed_urls: %s' % (str(self.urls), str(self.detached_urls), str(self.signed_urls)), 2)
70 + if GPG_ENABLED:
71 + self.get_gpg_urls()
72 + else:
73 + self.output.debug('RemoteDB.__init__(), NOT GPG_ENABLED, bypassing...', 2)
74
75 # add up the lists to load for display, etc.
76 # unsigned overlay lists
77 @@ -85,6 +85,8 @@ class RemoteDB(DbBase):
78 # single file signed, compressed, clearsigned
79 paths.extend([self.filepath(i) + '.xml' for i in self.signed_urls])
80
81 + self.output.debug('RemoteDB.__init__(), url lists= \nself.urls: %s\nself.detached_urls: %s\nself.signed_urls: %s' % (str(self.urls), str(self.detached_urls), str(self.signed_urls)), 2)
82 +
83 self.output.debug('RemoteDB.__init__(), paths to load = %s' %str(paths), 2)
84
85 if config['nocheck']:
86 @@ -397,6 +399,24 @@ class RemoteDB(DbBase):
87 self.gpg = GPG(self.gpg_config)
88 self.output.debug("RemoteDB.init_gpg(), initialized :D",2)
89
90 + def get_gpg_urls(self):
91 + '''Extend paths with gpg signed url listings from the config
92 +
93 + @param paths: list or urls to fetch
94 + '''
95 + #pair up the list url and detached sig url
96 + d_urls = [i.strip()
97 + for i in self.config['gpg_detached_lists'].split('\n') if len(i)]
98 +
99 + #for index in range(0, len(d_urls), 2):
100 + # self.detached_urls.append((d_urls[index], d_urls[index+1]))
101 + for i in d_urls:
102 + u = i.split()
103 + self.detached_urls.append((u[0], u[1]))
104 +
105 + self.signed_urls = [i.strip()
106 + for i in config['gpg_signed_lists'].split('\n') if len(i)]
107 +
108
109 if __name__ == '__main__':
110 import doctest