Merge lp:~wgrant/launchpad/publisher-release-cleanup into lp:launchpad
- publisher-release-cleanup
- Merge into devel
Status: | Merged |
---|---|
Approved by: | Abel Deuring |
Approved revision: | no longer in the source branch. |
Merged at revision: | 11730 |
Proposed branch: | lp:~wgrant/launchpad/publisher-release-cleanup |
Merge into: | lp:launchpad |
Prerequisite: | lp:~wgrant/launchpad/better-publisher-index-tests |
Diff against target: |
509 lines (+95/-202) 3 files modified
lib/lp/archivepublisher/ftparchive.py (+12/-71) lib/lp/archivepublisher/publishing.py (+76/-82) lib/lp/archivepublisher/tests/test_publisher.py (+7/-49) |
To merge this branch: | bzr merge lp:~wgrant/launchpad/publisher-release-cleanup |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Abel Deuring (community) | code | Approve | |
Review via email: mp+38530@code.launchpad.net |
Commit message
Replace the messy FTPArchiveHandl
Description of the change
= Summary =
lp.archivepublisher has two index generation mechanisms: native DB publication for partner, debug and PPA archives; and apt-ftparchive publication for primary and copy archives. The apt-ftparchive handler is deprecated and to be phased out, but its release_
== Proposed fix ==
Move release_
== Implementation details ==
While moving release_
So I changed release_
I also removed some duplicated code from lib/lp/
== Tests ==
test_publisher.py has had complex release_
== Demo and Q/A ==
This is just a refactoring. It's fine as long as the tests work.
= Launchpad lint =
There is plenty of inherited lint that could be fixed, but this branch is heavy enough, and there are five following it fixing most of it.
Abel Deuring (adeuring) : | # |
Preview Diff
1 | === modified file 'lib/lp/archivepublisher/ftparchive.py' | |||
2 | --- lib/lp/archivepublisher/ftparchive.py 2010-10-06 13:50:50 +0000 | |||
3 | +++ lib/lp/archivepublisher/ftparchive.py 2010-10-15 11:41:18 +0000 | |||
4 | @@ -157,7 +157,6 @@ | |||
5 | 157 | else: | 157 | else: |
6 | 158 | self.distroseries.append(distroseries) | 158 | self.distroseries.append(distroseries) |
7 | 159 | self.publisher = publisher | 159 | self.publisher = publisher |
8 | 160 | self.release_files_needed = {} | ||
9 | 161 | 160 | ||
10 | 162 | # We need somewhere to note down where the debian-installer | 161 | # We need somewhere to note down where the debian-installer |
11 | 163 | # components came from. in _di_release_components we store | 162 | # components came from. in _di_release_components we store |
12 | @@ -199,13 +198,9 @@ | |||
13 | 199 | We do this to have Packages or Sources for them even if we lack | 198 | We do this to have Packages or Sources for them even if we lack |
14 | 200 | anything in them currently. | 199 | anything in them currently. |
15 | 201 | """ | 200 | """ |
16 | 202 | # XXX: kiko 2006-08-24: suffix is completely unnecessary here. Just | ||
17 | 203 | # iterate over the pockets, and do the suffix check inside | ||
18 | 204 | # createEmptyPocketRequest; that would also allow us to replace | ||
19 | 205 | # the == "" check we do there by a RELEASE match | ||
20 | 206 | for distroseries in self.distroseries: | 201 | for distroseries in self.distroseries: |
21 | 207 | components = self._config.componentsForSeries(distroseries.name) | 202 | components = self._config.componentsForSeries(distroseries.name) |
23 | 208 | for pocket, suffix in pocketsuffix.items(): | 203 | for pocket in PackagePublishingPocket.items: |
24 | 209 | if not fullpublish: | 204 | if not fullpublish: |
25 | 210 | if not self.publisher.isDirty(distroseries, pocket): | 205 | if not self.publisher.isDirty(distroseries, pocket): |
26 | 211 | continue | 206 | continue |
27 | @@ -213,29 +208,15 @@ | |||
28 | 213 | if not self.publisher.isAllowed(distroseries, pocket): | 208 | if not self.publisher.isAllowed(distroseries, pocket): |
29 | 214 | continue | 209 | continue |
30 | 215 | 210 | ||
31 | 211 | self.publisher.release_files_needed.add( | ||
32 | 212 | (distroseries.name, pocket)) | ||
33 | 213 | |||
34 | 216 | for comp in components: | 214 | for comp in components: |
52 | 217 | self.createEmptyPocketRequest(distroseries, suffix, comp) | 215 | self.createEmptyPocketRequest(distroseries, pocket, comp) |
53 | 218 | 216 | ||
54 | 219 | def requestReleaseFile(self, suite_name, component_name, arch_name): | 217 | def createEmptyPocketRequest(self, distroseries, pocket, comp): |
38 | 220 | """Request Release file generation for given context. | ||
39 | 221 | |||
40 | 222 | 'suite_name', 'component_name' and 'arch_name' will be organised as | ||
41 | 223 | a dictionary (self.release_files_needed) keyed by 'suite_name' which | ||
42 | 224 | value will be another dictionary keyed by 'component_name' and | ||
43 | 225 | containing a set of 'arch_name's as value. | ||
44 | 226 | """ | ||
45 | 227 | suite_special = self.release_files_needed.setdefault( | ||
46 | 228 | suite_name, {}) | ||
47 | 229 | suite_component_special = suite_special.setdefault( | ||
48 | 230 | component_name, set()) | ||
49 | 231 | suite_component_special.add(arch_name) | ||
50 | 232 | |||
51 | 233 | def createEmptyPocketRequest(self, distroseries, suffix, comp): | ||
55 | 234 | """Creates empty files for a release pocket and distroseries""" | 218 | """Creates empty files for a release pocket and distroseries""" |
60 | 235 | full_distroseries_name = distroseries.name + suffix | 219 | if pocket == PackagePublishingPocket.RELEASE: |
57 | 236 | arch_tags = self._config.archTagsForSeries(distroseries.name) | ||
58 | 237 | |||
59 | 238 | if suffix == "": | ||
61 | 239 | # organize distroseries and component pair as | 220 | # organize distroseries and component pair as |
62 | 240 | # debian-installer -> distroseries_component | 221 | # debian-installer -> distroseries_component |
63 | 241 | # internal map. Only the main pocket actually | 222 | # internal map. Only the main pocket actually |
64 | @@ -246,6 +227,8 @@ | |||
65 | 246 | ".".join(["override", distroseries.name, comp, | 227 | ".".join(["override", distroseries.name, comp, |
66 | 247 | "debian-installer"])) | 228 | "debian-installer"])) |
67 | 248 | 229 | ||
68 | 230 | full_distroseries_name = distroseries.name + pocketsuffix[pocket] | ||
69 | 231 | |||
70 | 249 | # Touch the source file lists and override files | 232 | # Touch the source file lists and override files |
71 | 250 | f_touch(self._config.overrideroot, | 233 | f_touch(self._config.overrideroot, |
72 | 251 | ".".join(["override", full_distroseries_name, comp])) | 234 | ".".join(["override", full_distroseries_name, comp])) |
73 | @@ -254,20 +237,10 @@ | |||
74 | 254 | f_touch(self._config.overrideroot, | 237 | f_touch(self._config.overrideroot, |
75 | 255 | ".".join(["override", full_distroseries_name, comp, "src"])) | 238 | ".".join(["override", full_distroseries_name, comp, "src"])) |
76 | 256 | 239 | ||
77 | 257 | dr_comps = self.release_files_needed.setdefault( | ||
78 | 258 | full_distroseries_name, {}) | ||
79 | 259 | |||
80 | 260 | f_touch(self._config.overrideroot, | 240 | f_touch(self._config.overrideroot, |
81 | 261 | "_".join([full_distroseries_name, comp, "source"])) | 241 | "_".join([full_distroseries_name, comp, "source"])) |
91 | 262 | dr_comps.setdefault(comp, set()).add("source") | 242 | |
92 | 263 | 243 | for arch in self._config.archTagsForSeries(distroseries.name): | |
84 | 264 | for arch in arch_tags: | ||
85 | 265 | # organize dr/comp/arch into temporary binary | ||
86 | 266 | # archive map for the architecture in question. | ||
87 | 267 | dr_special = self.release_files_needed.setdefault( | ||
88 | 268 | full_distroseries_name, {}) | ||
89 | 269 | dr_special.setdefault(comp, set()).add("binary-"+arch) | ||
90 | 270 | |||
93 | 271 | # Touch more file lists for the archs. | 244 | # Touch more file lists for the archs. |
94 | 272 | f_touch(self._config.overrideroot, | 245 | f_touch(self._config.overrideroot, |
95 | 273 | "_".join([full_distroseries_name, comp, "binary-"+arch])) | 246 | "_".join([full_distroseries_name, comp, "binary-"+arch])) |
96 | @@ -714,9 +687,6 @@ | |||
97 | 714 | 687 | ||
98 | 715 | Also outputs a debian-installer file list if necessary. | 688 | Also outputs a debian-installer file list if necessary. |
99 | 716 | """ | 689 | """ |
100 | 717 | self.release_files_needed.setdefault( | ||
101 | 718 | dr_pocketed, {}).setdefault(component, set()).add(arch) | ||
102 | 719 | |||
103 | 720 | files = [] | 690 | files = [] |
104 | 721 | di_files = [] | 691 | di_files = [] |
105 | 722 | f_path = os.path.join(self._config.overrideroot, | 692 | f_path = os.path.join(self._config.overrideroot, |
106 | @@ -807,37 +777,8 @@ | |||
107 | 807 | """Generates the config stanza for an individual pocket.""" | 777 | """Generates the config stanza for an individual pocket.""" |
108 | 808 | dr_pocketed = distroseries_name + pocketsuffix[pocket] | 778 | dr_pocketed = distroseries_name + pocketsuffix[pocket] |
109 | 809 | 779 | ||
110 | 810 | # XXX kiko 2006-08-24: I have no idea what the code below is meant | ||
111 | 811 | # to do -- it appears to be a rehash of createEmptyPocketRequests. | ||
112 | 812 | archs = self._config.archTagsForSeries(distroseries_name) | 780 | archs = self._config.archTagsForSeries(distroseries_name) |
113 | 813 | comps = self._config.componentsForSeries(distroseries_name) | 781 | comps = self._config.componentsForSeries(distroseries_name) |
114 | 814 | for comp in comps: | ||
115 | 815 | comp_path = os.path.join(self._config.overrideroot, | ||
116 | 816 | "_".join([dr_pocketed, comp, "source"])) | ||
117 | 817 | if not os.path.exists(comp_path): | ||
118 | 818 | # Create empty files so that even if we don't output | ||
119 | 819 | # anything here apt-ftparchive will DTRT | ||
120 | 820 | f_touch(comp_path) | ||
121 | 821 | f_touch(self._config.overrideroot, | ||
122 | 822 | ".".join(["override", dr_pocketed, comp])) | ||
123 | 823 | f_touch(self._config.overrideroot, | ||
124 | 824 | ".".join(["override", dr_pocketed, comp, "src"])) | ||
125 | 825 | |||
126 | 826 | if len(comps) == 0: | ||
127 | 827 | self.log.debug("Did not find any components to create config " | ||
128 | 828 | "for %s" % dr_pocketed) | ||
129 | 829 | return | ||
130 | 830 | |||
131 | 831 | # Second up, pare archs down as appropriate | ||
132 | 832 | for arch in archs: | ||
133 | 833 | # XXX: kiko 2006-08-24: why is it comps[0] here? | ||
134 | 834 | arch_path = os.path.join(self._config.overrideroot, | ||
135 | 835 | "_".join([dr_pocketed, comps[0], "binary-"+arch])) | ||
136 | 836 | if not os.path.exists(arch_path): | ||
137 | 837 | # Create an empty file if we don't have one so that | ||
138 | 838 | # apt-ftparchive will dtrt. | ||
139 | 839 | f_touch(arch_path) | ||
140 | 840 | # XXX kiko 2006-08-24: End uncomprehensible code. | ||
141 | 841 | 782 | ||
142 | 842 | self.log.debug("Generating apt config for %s" % dr_pocketed) | 783 | self.log.debug("Generating apt config for %s" % dr_pocketed) |
143 | 843 | apt_config.write(STANZA_TEMPLATE % { | 784 | apt_config.write(STANZA_TEMPLATE % { |
144 | 844 | 785 | ||
145 | === modified file 'lib/lp/archivepublisher/publishing.py' | |||
146 | --- lib/lp/archivepublisher/publishing.py 2010-10-06 13:49:38 +0000 | |||
147 | +++ lib/lp/archivepublisher/publishing.py 2010-10-15 11:41:18 +0000 | |||
148 | @@ -58,13 +58,19 @@ | |||
149 | 58 | Over time this method needs to be removed and replaced by having | 58 | Over time this method needs to be removed and replaced by having |
150 | 59 | component ordering codified in the database. | 59 | component ordering codified in the database. |
151 | 60 | """ | 60 | """ |
153 | 61 | ret = [] | 61 | remaining = list(components) |
154 | 62 | ordered = [] | ||
155 | 62 | for comp in HARDCODED_COMPONENT_ORDER: | 63 | for comp in HARDCODED_COMPONENT_ORDER: |
161 | 63 | if comp in components: | 64 | if comp in remaining: |
162 | 64 | ret.append(comp) | 65 | ordered.append(comp) |
163 | 65 | components.remove(comp) | 66 | remaining.remove(comp) |
164 | 66 | ret.extend(components) | 67 | ordered.extend(remaining) |
165 | 67 | return ret | 68 | return ordered |
166 | 69 | |||
167 | 70 | |||
168 | 71 | def get_suffixed_indices(path): | ||
169 | 72 | """Return a set of paths to compressed copies of the given index.""" | ||
170 | 73 | return set([path + suffix for suffix in ('', '.gz', '.bz2')]) | ||
171 | 68 | 74 | ||
172 | 69 | 75 | ||
173 | 70 | def _getDiskPool(pubconf, log): | 76 | def _getDiskPool(pubconf, log): |
174 | @@ -147,21 +153,19 @@ | |||
175 | 147 | else: | 153 | else: |
176 | 148 | self._library = library | 154 | self._library = library |
177 | 149 | 155 | ||
178 | 150 | # Grab a reference to an apt_handler as we use it later to | ||
179 | 151 | # probe which components need releases files generated. | ||
180 | 152 | self.apt_handler = FTPArchiveHandler(self.log, self._config, | ||
181 | 153 | self._diskpool, self.distro, | ||
182 | 154 | self) | ||
183 | 155 | # Track which distroseries pockets have been dirtied by a | 156 | # Track which distroseries pockets have been dirtied by a |
184 | 156 | # change, and therefore need domination/apt-ftparchive work. | 157 | # change, and therefore need domination/apt-ftparchive work. |
185 | 157 | # This is a set of tuples in the form (distroseries.name, pocket) | 158 | # This is a set of tuples in the form (distroseries.name, pocket) |
186 | 158 | self.dirty_pockets = set() | 159 | self.dirty_pockets = set() |
187 | 159 | 160 | ||
188 | 161 | # Track which pockets need release files. This will contain more | ||
189 | 162 | # than dirty_pockets in the case of a careful index run. | ||
190 | 163 | # This is a set of tuples in the form (distroseries.name, pocket) | ||
191 | 164 | self.release_files_needed = set() | ||
192 | 165 | |||
193 | 160 | def isDirty(self, distroseries, pocket): | 166 | def isDirty(self, distroseries, pocket): |
194 | 161 | """True if a publication has happened in this release and pocket.""" | 167 | """True if a publication has happened in this release and pocket.""" |
198 | 162 | if not (distroseries.name, pocket) in self.dirty_pockets: | 168 | return (distroseries.name, pocket) in self.dirty_pockets |
196 | 163 | return False | ||
197 | 164 | return True | ||
199 | 165 | 169 | ||
200 | 166 | def markPocketDirty(self, distroseries, pocket): | 170 | def markPocketDirty(self, distroseries, pocket): |
201 | 167 | """Mark a pocket dirty only if it's allowed.""" | 171 | """Mark a pocket dirty only if it's allowed.""" |
202 | @@ -176,10 +180,8 @@ | |||
203 | 176 | 180 | ||
204 | 177 | Otherwise, return False. | 181 | Otherwise, return False. |
205 | 178 | """ | 182 | """ |
210 | 179 | if (self.allowed_suites and | 183 | return (not self.allowed_suites or |
211 | 180 | (distroseries.name, pocket) not in self.allowed_suites): | 184 | (distroseries.name, pocket) in self.allowed_suites) |
208 | 181 | return False | ||
209 | 182 | return True | ||
212 | 183 | 185 | ||
213 | 184 | def A_publish(self, force_publishing): | 186 | def A_publish(self, force_publishing): |
214 | 185 | """First step in publishing: actual package publishing. | 187 | """First step in publishing: actual package publishing. |
215 | @@ -281,7 +283,10 @@ | |||
216 | 281 | def C_doFTPArchive(self, is_careful): | 283 | def C_doFTPArchive(self, is_careful): |
217 | 282 | """Does the ftp-archive step: generates Sources and Packages.""" | 284 | """Does the ftp-archive step: generates Sources and Packages.""" |
218 | 283 | self.log.debug("* Step C: Set apt-ftparchive up and run it") | 285 | self.log.debug("* Step C: Set apt-ftparchive up and run it") |
220 | 284 | self.apt_handler.run(is_careful) | 286 | apt_handler = FTPArchiveHandler(self.log, self._config, |
221 | 287 | self._diskpool, self.distro, | ||
222 | 288 | self) | ||
223 | 289 | apt_handler.run(is_careful) | ||
224 | 285 | 290 | ||
225 | 286 | def C_writeIndexes(self, is_careful): | 291 | def C_writeIndexes(self, is_careful): |
226 | 287 | """Write Index files (Packages & Sources) using LP information. | 292 | """Write Index files (Packages & Sources) using LP information. |
227 | @@ -297,6 +302,9 @@ | |||
228 | 297 | (distroseries.name, pocket.name)) | 302 | (distroseries.name, pocket.name)) |
229 | 298 | continue | 303 | continue |
230 | 299 | self.checkDirtySuiteBeforePublishing(distroseries, pocket) | 304 | self.checkDirtySuiteBeforePublishing(distroseries, pocket) |
231 | 305 | |||
232 | 306 | self.release_files_needed.add((distroseries.name, pocket)) | ||
233 | 307 | |||
234 | 300 | # Retrieve components from the publisher config because | 308 | # Retrieve components from the publisher config because |
235 | 301 | # it gets overridden in getPubConfig to set the | 309 | # it gets overridden in getPubConfig to set the |
236 | 302 | # correct components for the archive being used. | 310 | # correct components for the archive being used. |
237 | @@ -323,7 +331,7 @@ | |||
238 | 323 | (distroseries.name, pocket.name)) | 331 | (distroseries.name, pocket.name)) |
239 | 324 | continue | 332 | continue |
240 | 325 | self.checkDirtySuiteBeforePublishing(distroseries, pocket) | 333 | self.checkDirtySuiteBeforePublishing(distroseries, pocket) |
242 | 326 | self._writeDistroSeries(distroseries, pocket) | 334 | self._writeSuite(distroseries, pocket) |
243 | 327 | 335 | ||
244 | 328 | def _writeComponentIndexes(self, distroseries, pocket, component): | 336 | def _writeComponentIndexes(self, distroseries, pocket, component): |
245 | 329 | """Write Index files for single distroseries + pocket + component. | 337 | """Write Index files for single distroseries + pocket + component. |
246 | @@ -358,11 +366,6 @@ | |||
247 | 358 | 366 | ||
248 | 359 | arch_path = 'binary-%s' % arch.architecturetag | 367 | arch_path = 'binary-%s' % arch.architecturetag |
249 | 360 | 368 | ||
250 | 361 | # XXX wgrant 2010-10-06 bug=655690: Using FTPArchiveHandler | ||
251 | 362 | # for NMAF is wrong. | ||
252 | 363 | self.apt_handler.requestReleaseFile( | ||
253 | 364 | suite_name, component.name, arch_path) | ||
254 | 365 | |||
255 | 366 | self.log.debug("Generating Packages for %s" % arch_path) | 369 | self.log.debug("Generating Packages for %s" % arch_path) |
256 | 367 | 370 | ||
257 | 368 | package_index_root = os.path.join( | 371 | package_index_root = os.path.join( |
258 | @@ -394,11 +397,6 @@ | |||
259 | 394 | package_index.close() | 397 | package_index.close() |
260 | 395 | di_index.close() | 398 | di_index.close() |
261 | 396 | 399 | ||
262 | 397 | # XXX wgrant 2010-10-06 bug=655690: Using FTPArchiveHandler | ||
263 | 398 | # is wrong here too. | ||
264 | 399 | self.apt_handler.requestReleaseFile( | ||
265 | 400 | suite_name, component.name, 'source') | ||
266 | 401 | |||
267 | 402 | def cannotModifySuite(self, distroseries, pocket): | 400 | def cannotModifySuite(self, distroseries, pocket): |
268 | 403 | """Return True if the distroseries is stable and pocket is release.""" | 401 | """Return True if the distroseries is stable and pocket is release.""" |
269 | 404 | return (not distroseries.isUnstable() and | 402 | return (not distroseries.isUnstable() and |
270 | @@ -447,34 +445,28 @@ | |||
271 | 447 | return self.distro.displayname | 445 | return self.distro.displayname |
272 | 448 | return "LP-PPA-%s" % get_ppa_reference(self.archive) | 446 | return "LP-PPA-%s" % get_ppa_reference(self.archive) |
273 | 449 | 447 | ||
276 | 450 | def _writeDistroSeries(self, distroseries, pocket): | 448 | def _writeSuite(self, distroseries, pocket): |
277 | 451 | """Write out the Release files for the provided distroseries.""" | 449 | """Write out the Release files for the provided suite.""" |
278 | 452 | # XXX: kiko 2006-08-24: Untested method. | 450 | # XXX: kiko 2006-08-24: Untested method. |
279 | 453 | 451 | ||
280 | 454 | # As we generate file lists for apt-ftparchive we record which | 452 | # As we generate file lists for apt-ftparchive we record which |
281 | 455 | # distroseriess and so on we need to generate Release files for. | 453 | # distroseriess and so on we need to generate Release files for. |
282 | 456 | # We store this in release_files_needed and consume the information | 454 | # We store this in release_files_needed and consume the information |
283 | 457 | # when writeReleaseFiles is called. | 455 | # when writeReleaseFiles is called. |
287 | 458 | full_name = distroseries.name + pocketsuffix[pocket] | 456 | if (distroseries.name, pocket) not in self.release_files_needed: |
285 | 459 | release_files_needed = self.apt_handler.release_files_needed | ||
286 | 460 | if full_name not in release_files_needed: | ||
288 | 461 | # If we don't need to generate a release for this release | 457 | # If we don't need to generate a release for this release |
289 | 462 | # and pocket, don't! | 458 | # and pocket, don't! |
290 | 463 | return | 459 | return |
291 | 464 | 460 | ||
294 | 465 | all_components = set() | 461 | all_components = self._config.componentsForSeries(distroseries.name) |
295 | 466 | all_architectures = set() | 462 | all_architectures = self._config.archTagsForSeries(distroseries.name) |
296 | 467 | all_files = set() | 463 | all_files = set() |
304 | 468 | release_files_needed_items = release_files_needed[full_name].items() | 464 | for component in all_components: |
305 | 469 | for component, architectures in release_files_needed_items: | 465 | self._writeSuiteSource( |
306 | 470 | all_components.add(component) | 466 | distroseries, pocket, component, all_files) |
307 | 471 | for architecture in architectures: | 467 | for architecture in all_architectures: |
308 | 472 | # XXX malcc 2006-09-20: We don't like the way we build this | 468 | self._writeSuiteArch( |
302 | 473 | # all_architectures list. Make this better code. | ||
303 | 474 | clean_architecture = self._writeDistroArchSeries( | ||
309 | 475 | distroseries, pocket, component, architecture, all_files) | 469 | distroseries, pocket, component, architecture, all_files) |
310 | 476 | if clean_architecture != "source": | ||
311 | 477 | all_architectures.add(clean_architecture) | ||
312 | 478 | 470 | ||
313 | 479 | drsummary = "%s %s " % (self.distro.displayname, | 471 | drsummary = "%s %s " % (self.distro.displayname, |
314 | 480 | distroseries.displayname) | 472 | distroseries.displayname) |
315 | @@ -483,6 +475,7 @@ | |||
316 | 483 | else: | 475 | else: |
317 | 484 | drsummary += pocket.name.capitalize() | 476 | drsummary += pocket.name.capitalize() |
318 | 485 | 477 | ||
319 | 478 | full_name = distroseries.getSuite(pocket) | ||
320 | 486 | release_file = Release() | 479 | release_file = Release() |
321 | 487 | release_file["Origin"] = self._getOrigin() | 480 | release_file["Origin"] = self._getOrigin() |
322 | 488 | release_file["Label"] = self._getLabel() | 481 | release_file["Label"] = self._getLabel() |
323 | @@ -530,60 +523,61 @@ | |||
324 | 530 | archive_signer = IArchiveSigningKey(self.archive) | 523 | archive_signer = IArchiveSigningKey(self.archive) |
325 | 531 | archive_signer.signRepository(full_name) | 524 | archive_signer.signRepository(full_name) |
326 | 532 | 525 | ||
330 | 533 | def _writeDistroArchSeries(self, distroseries, pocket, component, | 526 | def _writeSuiteArchOrSource(self, distroseries, pocket, component, |
331 | 534 | architecture, all_files): | 527 | file_stub, arch_name, arch_path, |
332 | 535 | """Write out a Release file for a DAR.""" | 528 | all_series_files): |
333 | 529 | """Write out a Release file for an architecture or source.""" | ||
334 | 536 | # XXX kiko 2006-08-24: Untested method. | 530 | # XXX kiko 2006-08-24: Untested method. |
335 | 537 | 531 | ||
339 | 538 | full_name = distroseries.name + pocketsuffix[pocket] | 532 | suite = distroseries.getSuite(pocket) |
337 | 539 | index_suffixes = ('', '.gz', '.bz2') | ||
338 | 540 | |||
340 | 541 | self.log.debug("Writing Release file for %s/%s/%s" % ( | 533 | self.log.debug("Writing Release file for %s/%s/%s" % ( |
360 | 542 | full_name, component, architecture)) | 534 | suite, component, arch_path)) |
342 | 543 | |||
343 | 544 | if architecture != "source": | ||
344 | 545 | # Strip "binary-" off the front of the architecture | ||
345 | 546 | clean_architecture = architecture[7:] | ||
346 | 547 | file_stub = "Packages" | ||
347 | 548 | |||
348 | 549 | # Only the primary and PPA archives have debian-installer. | ||
349 | 550 | if self.archive.purpose != ArchivePurpose.PARTNER: | ||
350 | 551 | # Set up the debian-installer paths for main_archive. | ||
351 | 552 | # d-i paths are nested inside the component. | ||
352 | 553 | di_path = os.path.join( | ||
353 | 554 | component, "debian-installer", architecture) | ||
354 | 555 | di_file_stub = os.path.join(di_path, file_stub) | ||
355 | 556 | for suffix in index_suffixes: | ||
356 | 557 | all_files.add(di_file_stub + suffix) | ||
357 | 558 | else: | ||
358 | 559 | file_stub = "Sources" | ||
359 | 560 | clean_architecture = architecture | ||
361 | 561 | 535 | ||
362 | 562 | # Now, grab the actual (non-di) files inside each of | 536 | # Now, grab the actual (non-di) files inside each of |
363 | 563 | # the suite's architectures | 537 | # the suite's architectures |
370 | 564 | file_stub = os.path.join(component, architecture, file_stub) | 538 | file_stub = os.path.join(component, arch_path, file_stub) |
371 | 565 | 539 | ||
372 | 566 | for suffix in index_suffixes: | 540 | all_series_files.update(get_suffixed_indices(file_stub)) |
373 | 567 | all_files.add(file_stub + suffix) | 541 | all_series_files.add(os.path.join(component, arch_path, "Release")) |
368 | 568 | |||
369 | 569 | all_files.add(os.path.join(component, architecture, "Release")) | ||
374 | 570 | 542 | ||
375 | 571 | release_file = Release() | 543 | release_file = Release() |
377 | 572 | release_file["Archive"] = full_name | 544 | release_file["Archive"] = suite |
378 | 573 | release_file["Version"] = distroseries.version | 545 | release_file["Version"] = distroseries.version |
379 | 574 | release_file["Component"] = component | 546 | release_file["Component"] = component |
380 | 575 | release_file["Origin"] = self._getOrigin() | 547 | release_file["Origin"] = self._getOrigin() |
381 | 576 | release_file["Label"] = self._getLabel() | 548 | release_file["Label"] = self._getLabel() |
383 | 577 | release_file["Architecture"] = clean_architecture | 549 | release_file["Architecture"] = arch_name |
384 | 578 | 550 | ||
387 | 579 | f = open(os.path.join(self._config.distsroot, full_name, | 551 | f = open(os.path.join(self._config.distsroot, suite, |
388 | 580 | component, architecture, "Release"), "w") | 552 | component, arch_path, "Release"), "w") |
389 | 581 | try: | 553 | try: |
390 | 582 | release_file.dump(f, "utf-8") | 554 | release_file.dump(f, "utf-8") |
391 | 583 | finally: | 555 | finally: |
392 | 584 | f.close() | 556 | f.close() |
393 | 585 | 557 | ||
395 | 586 | return clean_architecture | 558 | def _writeSuiteSource(self, distroseries, pocket, component, |
396 | 559 | all_series_files): | ||
397 | 560 | """Write out a Release file for a suite's sources.""" | ||
398 | 561 | self._writeSuiteArchOrSource( | ||
399 | 562 | distroseries, pocket, component, 'Sources', 'source', 'source', | ||
400 | 563 | all_series_files) | ||
401 | 564 | |||
402 | 565 | def _writeSuiteArch(self, distroseries, pocket, component, | ||
403 | 566 | arch_name, all_series_files): | ||
404 | 567 | """Write out a Release file for an architecture in a suite.""" | ||
405 | 568 | file_stub = 'Packages' | ||
406 | 569 | arch_path = 'binary-' + arch_name | ||
407 | 570 | # Only the primary and PPA archives have debian-installer. | ||
408 | 571 | if self.archive.purpose != ArchivePurpose.PARTNER: | ||
409 | 572 | # Set up the debian-installer paths for main_archive. | ||
410 | 573 | # d-i paths are nested inside the component. | ||
411 | 574 | di_path = os.path.join( | ||
412 | 575 | component, "debian-installer", arch_path) | ||
413 | 576 | di_file_stub = os.path.join(di_path, file_stub) | ||
414 | 577 | all_series_files.update(get_suffixed_indices(di_file_stub)) | ||
415 | 578 | self._writeSuiteArchOrSource( | ||
416 | 579 | distroseries, pocket, component, 'Packages', arch_name, arch_path, | ||
417 | 580 | all_series_files) | ||
418 | 587 | 581 | ||
419 | 588 | def _readIndexFileContents(self, distroseries_name, file_name): | 582 | def _readIndexFileContents(self, distroseries_name, file_name): |
420 | 589 | """Read an index files' contents. | 583 | """Read an index files' contents. |
421 | 590 | 584 | ||
422 | === modified file 'lib/lp/archivepublisher/tests/test_publisher.py' | |||
423 | --- lib/lp/archivepublisher/tests/test_publisher.py 2010-10-15 11:41:16 +0000 | |||
424 | +++ lib/lp/archivepublisher/tests/test_publisher.py 2010-10-15 11:41:18 +0000 | |||
425 | @@ -639,13 +639,10 @@ | |||
426 | 639 | ''], | 639 | ''], |
427 | 640 | index_contents) | 640 | index_contents) |
428 | 641 | 641 | ||
429 | 642 | # Check if apt_handler.release_files_needed has the right requests. | ||
430 | 643 | # 'source' & 'binary-i386' Release files should be regenerated | ||
431 | 644 | # for all breezy-autotest components. Note that 'debian-installer' | ||
432 | 645 | # indexes do not need Release files. | ||
433 | 646 | |||
434 | 647 | # We always regenerate all Releases file for a given suite. | 642 | # We always regenerate all Releases file for a given suite. |
436 | 648 | self.checkAllRequestedReleaseFiles(archive_publisher) | 643 | self.assertTrue( |
437 | 644 | ('breezy-autotest', PackagePublishingPocket.RELEASE) in | ||
438 | 645 | archive_publisher.release_files_needed) | ||
439 | 649 | 646 | ||
440 | 650 | # remove PPA root | 647 | # remove PPA root |
441 | 651 | shutil.rmtree(config.personalpackagearchive.root) | 648 | shutil.rmtree(config.personalpackagearchive.root) |
442 | @@ -769,45 +766,6 @@ | |||
443 | 769 | # are marked as dirty. | 766 | # are marked as dirty. |
444 | 770 | self.checkDirtyPockets(publisher, expected=allowed_suites) | 767 | self.checkDirtyPockets(publisher, expected=allowed_suites) |
445 | 771 | 768 | ||
446 | 772 | def assertReleaseFileRequested(self, publisher, suite_name, | ||
447 | 773 | component_name, archs): | ||
448 | 774 | """Assert the given context will have it's Release file regenerated. | ||
449 | 775 | |||
450 | 776 | Check if a request for the given context is correctly stored in: | ||
451 | 777 | publisher.apt_handler.release_files_needed | ||
452 | 778 | """ | ||
453 | 779 | suite = publisher.apt_handler.release_files_needed.get(suite_name) | ||
454 | 780 | self.assertTrue( | ||
455 | 781 | suite is not None, 'Suite %s not requested' % suite_name) | ||
456 | 782 | self.assertTrue( | ||
457 | 783 | component_name in suite, | ||
458 | 784 | 'Component %s/%s not requested' % (suite_name, component_name)) | ||
459 | 785 | self.assertEquals(archs, suite[component_name]) | ||
460 | 786 | |||
461 | 787 | def checkAllRequestedReleaseFiles(self, publisher, | ||
462 | 788 | architecturetags=('hppa', 'i386')): | ||
463 | 789 | """Check if all expected Release files are going to be regenerated. | ||
464 | 790 | |||
465 | 791 | 'source', 'binary-i386' and 'binary-hppa' Release Files should be | ||
466 | 792 | requested for regeneration in all breezy-autotest components. | ||
467 | 793 | """ | ||
468 | 794 | available_components = sorted([ | ||
469 | 795 | c.name for c in self.breezy_autotest.components]) | ||
470 | 796 | self.assertEqual(available_components, | ||
471 | 797 | ['main', 'multiverse', 'restricted', 'universe']) | ||
472 | 798 | |||
473 | 799 | available_archs = ['binary-%s' % arch for arch in architecturetags] | ||
474 | 800 | |||
475 | 801 | # XXX cprov 20071210: Include the artificial component 'source' as a | ||
476 | 802 | # location to check for generated indexes. Ideally we should | ||
477 | 803 | # encapsulate this task in publishing.py and this common method | ||
478 | 804 | # in tests as well. | ||
479 | 805 | all_archs = set(available_archs) | ||
480 | 806 | all_archs.add('source') | ||
481 | 807 | for component in available_components: | ||
482 | 808 | self.assertReleaseFileRequested( | ||
483 | 809 | publisher, 'breezy-autotest', component, all_archs) | ||
484 | 810 | |||
485 | 811 | def _getReleaseFileOrigin(self, contents): | 769 | def _getReleaseFileOrigin(self, contents): |
486 | 812 | origin_header = 'Origin: ' | 770 | origin_header = 'Origin: ' |
487 | 813 | [origin_line] = [ | 771 | [origin_line] = [ |
488 | @@ -831,8 +789,9 @@ | |||
489 | 831 | publisher.A_publish(False) | 789 | publisher.A_publish(False) |
490 | 832 | publisher.C_doFTPArchive(False) | 790 | publisher.C_doFTPArchive(False) |
491 | 833 | 791 | ||
494 | 834 | # We always regenerate all Releases file for a given suite. | 792 | self.assertTrue( |
495 | 835 | self.checkAllRequestedReleaseFiles(publisher) | 793 | ('breezy-autotest', PackagePublishingPocket.RELEASE) in |
496 | 794 | publisher.release_files_needed) | ||
497 | 836 | 795 | ||
498 | 837 | publisher.D_writeReleaseFiles(False) | 796 | publisher.D_writeReleaseFiles(False) |
499 | 838 | 797 | ||
500 | @@ -1109,8 +1068,7 @@ | |||
501 | 1109 | """ | 1068 | """ |
502 | 1110 | 1069 | ||
503 | 1111 | self.assertTrue( | 1070 | self.assertTrue( |
506 | 1112 | series.getSuite(pocket) in | 1071 | (series.name, pocket) in publisher.release_files_needed) |
505 | 1113 | publisher.apt_handler.release_files_needed) | ||
507 | 1114 | 1072 | ||
508 | 1115 | arch_template = os.path.join( | 1073 | arch_template = os.path.join( |
509 | 1116 | publisher._config.distsroot, series.getSuite(pocket), '%s/%s') | 1074 | publisher._config.distsroot, series.getSuite(pocket), '%s/%s') |