Gentoo Archives: gentoo-portage-dev

From: Brian Dolbec <dolsen@g.o>
To: gentoo-portage-dev@l.g.o
Subject: [gentoo-portage-dev] plugin-sync progress report
Date: Sat, 15 Mar 2014 20:32:23
Message-Id: 20140315133210.32f79f55.dolsen@gentoo.org
1 I've started working on the repository/config.py changes needed for the
2 plugin-sync system.
3
4 First:
5 The following class performed checks on the
6 repos.conf entries for the sync variables regardless if they were being
7 used or not. I would like to remove that code block completely from
8 this loader/parser. I would prefer to have the sync module perform
9 it's own checks and only when syncing or from a future emaint module
10 with that specific 'check-config' option.
11
12 I've sectioned off the code I'd like to remove below.
13 Is there any reason they must be done here and during initial parsing?
14
15 Advantages:
16 - No need to import and initialize the sync module and the plugin system
17 for other emerge/portage operations.
18 - Should speed things up slightly with less to do.
19 - Makes the sync module responsible the validation of any sync specific variables.
20
21
22 Second:
23 - Should all the repos.conf entires to be synced be validated prior to syncing and fail
24 if there are any errors?
25 - Or, just call each sync module's sync() and let each fail individually
26 and continue syncing remaining repos?
27
28 Third:
29 - I would like to add a new config item for all repos.
30 It is a variable to define which sources of sync operations which
31 the repo will be allowed to be synced from. It could be a space separated list
32 which could be used to prevent it from being synced via certain commands.
33
34 i.e:
35
36 [repo1]
37 sync-from = emerge emaint
38
39 [repo2]
40 sync-from = emerge emaint layman
41
42 [repo3]
43 sync-from = None
44
45 - Thoughts?
46 - Opinions?
47
48 ############
49
50 class RepoConfigLoader(object):
51 """Loads and store config of several repositories, loaded from PORTDIR_OVERLAY or repos.conf"""
52
53 @staticmethod
54 def _parse(paths, prepos, ignored_map, ignored_location_map, local_config, portdir):
55 """Parse files in paths to load config"""
56 parser = SafeConfigParser()
57
58 # use read_file/readfp in order to control decoding of unicode
59 try:
60 # Python >=3.2
61 read_file = parser.read_file
62 source_kwarg = 'source'
63 except AttributeError:
64 read_file = parser.readfp
65 source_kwarg = 'filename'
66
67 recursive_paths = []
68 for p in paths:
69 if isinstance(p, basestring):
70 recursive_paths.extend(_recursive_file_list(p))
71 else:
72 recursive_paths.append(p)
73
74 for p in recursive_paths:
75 if isinstance(p, basestring):
76 f = None
77 try:
78 f = io.open(_unicode_encode(p,
79 encoding=_encodings['fs'], errors='strict'),
80 mode='r', encoding=_encodings['repo.content'],
81 errors='replace')
82 except EnvironmentError:
83 pass
84 else:
85 # The 'source' keyword argument is needed since otherwise
86 # ConfigParser in Python <3.3.3 may throw a TypeError
87 # because it assumes that f.name is a native string rather
88 # than binary when constructing error messages.
89 kwargs = {source_kwarg: p}
90 read_file(f, **portage._native_kwargs(kwargs))
91 finally:
92 if f is not None:
93 f.close()
94 elif isinstance(p, io.StringIO):
95 kwargs = {source_kwarg: "<io.StringIO>"}
96 read_file(p, **portage._native_kwargs(kwargs))
97 else:
98 raise TypeError("Unsupported type %r of element %r of 'paths' argument" % (type(p), p))
99
100 prepos['DEFAULT'] = RepoConfig("DEFAULT",
101 parser.defaults(), local_config=local_config)
102
103 for sname in parser.sections():
104 optdict = {}
105 for oname in parser.options(sname):
106 optdict[oname] = parser.get(sname, oname)
107
108 repo = RepoConfig(sname, optdict, local_config=local_config)
109
110 ###################################
111 # remove these checks
112 ###################################
113 if repo.sync_type is not None and repo.sync_uri is None:
114 writemsg_level("!!! %s\n" % _("Repository '%s' has sync-type attribute, but is missing sync-uri attribute") %
115 sname, level=logging.ERROR, noiselevel=-1)
116 continue
117
118 if repo.sync_uri is not None and repo.sync_type is None:
119 writemsg_level("!!! %s\n" % _("Repository '%s' has sync-uri attribute, but is missing sync-type attribute") %
120 sname, level=logging.ERROR, noiselevel=-1)
121 continue
122
123 if repo.sync_type not in portage.sync.module_names + [None]:
124 writemsg_level("!!! %s\n" % _("Repository '%s' has sync-type attribute set to unsupported value: '%s'") %
125 (sname, repo.sync_type), level=logging.ERROR, noiselevel=-1)
126 continue
127
128 if repo.sync_type == "cvs" and repo.sync_cvs_repo is None:
129 writemsg_level("!!! %s\n" % _("Repository '%s' has sync-type=cvs, but is missing sync-cvs-repo attribute") %
130 sname, level=logging.ERROR, noiselevel=-1)
131 continue
132 ###################################
133 # end remove
134 ###################################
135
136 # For backward compatibility with locations set via PORTDIR and
137 # PORTDIR_OVERLAY, delay validation of the location and repo.name
138 # until after PORTDIR and PORTDIR_OVERLAY have been processed.
139 prepos[sname] = repo
140
141
142 --
143 Brian Dolbec <dolsen>

Replies

Subject Author
Re: [gentoo-portage-dev] plugin-sync progress report Sebastian Luther <SebastianLuther@×××.de>
Re: [gentoo-portage-dev] plugin-sync progress report Alec Warner <antarus@g.o>