Gentoo Archives: gentoo-portage-dev

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