Merge lp:~wgrant/launchpad/bug-655614-disabled-arch-indices into lp:launchpad/db-devel

Proposed by William Grant
Status: Merged
Approved by: Julian Edwards
Approved revision: no longer in the source branch.
Merged at revision: 9875
Proposed branch: lp:~wgrant/launchpad/bug-655614-disabled-arch-indices
Merge into: lp:launchpad/db-devel
Diff against target: 211 lines (+100/-23)
4 files modified
lib/lp/archivepublisher/config.py (+3/-2)
lib/lp/archivepublisher/ftparchive.py (+7/-0)
lib/lp/archivepublisher/publishing.py (+10/-7)
lib/lp/archivepublisher/tests/test_publisher.py (+80/-14)
To merge this branch: bzr merge lp:~wgrant/launchpad/bug-655614-disabled-arch-indices
Reviewer Review Type Date Requested Status
Julian Edwards (community) Approve
Review via email: mp+37849@code.launchpad.net

Commit message

Don't publish indices for disabled architectures.

Description of the change

Both the publication methods (NMAF and a-f) still publish indices for disabled architectures every time the pocket is dirtied. This is pointless pollution, as these indices will be empty.

This branch fixes both publishers to not publish any indices for disabled archs, and also to exclude them from the series Release file. It adds tests to confirm that neither publisher writes disabled indices, or even creates directories for them.

The revolting hack in lib/lp/archivepublisher/ftparchive.py is largely stolen from another part of the publisher, and can't be avoided without a substantial refactor.

To post a comment you must log in.
Revision history for this message
Julian Edwards (julian-edwards) :
review: Approve
Revision history for this message
Julian Edwards (julian-edwards) wrote :

I am testing and landing. If it works on on dogfood I'll cherry pick too, thanks for writing this William.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/archivepublisher/config.py'
--- lib/lp/archivepublisher/config.py 2010-08-23 16:51:11 +0000
+++ lib/lp/archivepublisher/config.py 2010-10-07 14:15:57 +0000
@@ -117,8 +117,9 @@
117 }117 }
118118
119 for dar in dr.architectures:119 for dar in dr.architectures:
120 config_segment["archtags"].append(120 if dar.enabled:
121 dar.architecturetag.encode('utf-8'))121 config_segment["archtags"].append(
122 dar.architecturetag.encode('utf-8'))
122123
123 if dr.lucilleconfig:124 if dr.lucilleconfig:
124 strio = StringIO(dr.lucilleconfig.encode('utf-8'))125 strio = StringIO(dr.lucilleconfig.encode('utf-8'))
125126
=== modified file 'lib/lp/archivepublisher/ftparchive.py'
--- lib/lp/archivepublisher/ftparchive.py 2010-08-24 15:29:01 +0000
+++ lib/lp/archivepublisher/ftparchive.py 2010-10-07 14:15:57 +0000
@@ -699,6 +699,13 @@
699 self.log.debug("Writing file lists for %s" % suite)699 self.log.debug("Writing file lists for %s" % suite)
700 for component, architectures in components.items():700 for component, architectures in components.items():
701 for architecture, file_names in architectures.items():701 for architecture, file_names in architectures.items():
702 # XXX wgrant 2010-10-06: There must be a better place to
703 # do this.
704 series, pocket = (
705 self.distro.getDistroSeriesAndPocket(suite))
706 if (architecture != 'source' and
707 not series.getDistroArchSeries(architecture[7:]).enabled):
708 continue
702 self.writeFileList(architecture, file_names,709 self.writeFileList(architecture, file_names,
703 suite, component)710 suite, component)
704711
705712
=== modified file 'lib/lp/archivepublisher/publishing.py'
--- lib/lp/archivepublisher/publishing.py 2010-08-24 15:29:01 +0000
+++ lib/lp/archivepublisher/publishing.py 2010-10-07 14:15:57 +0000
@@ -353,8 +353,16 @@
353 source_index.close()353 source_index.close()
354354
355 for arch in distroseries.architectures:355 for arch in distroseries.architectures:
356 if not arch.enabled:
357 continue
358
356 arch_path = 'binary-%s' % arch.architecturetag359 arch_path = 'binary-%s' % arch.architecturetag
357360
361 # XXX wgrant 2010-10-06 bug=655690: Using FTPArchiveHandler
362 # for NMAF is wrong.
363 self.apt_handler.requestReleaseFile(
364 suite_name, component.name, arch_path)
365
358 self.log.debug("Generating Packages for %s" % arch_path)366 self.log.debug("Generating Packages for %s" % arch_path)
359367
360 package_index_root = os.path.join(368 package_index_root = os.path.join(
@@ -386,15 +394,10 @@
386 package_index.close()394 package_index.close()
387 di_index.close()395 di_index.close()
388396
389 # Inject static requests for Release files into self.apt_handler397 # XXX wgrant 2010-10-06 bug=655690: Using FTPArchiveHandler
390 # in a way which works for NoMoreAptFtpArchive without changing398 # is wrong here too.
391 # much of the rest of the code, specially D_writeReleaseFiles.
392 self.apt_handler.requestReleaseFile(399 self.apt_handler.requestReleaseFile(
393 suite_name, component.name, 'source')400 suite_name, component.name, 'source')
394 for arch in distroseries.architectures:
395 arch_name = "binary-" + arch.architecturetag
396 self.apt_handler.requestReleaseFile(
397 suite_name, component.name, arch_name)
398401
399 def cannotModifySuite(self, distroseries, pocket):402 def cannotModifySuite(self, distroseries, pocket):
400 """Return True if the distroseries is stable and pocket is release."""403 """Return True if the distroseries is stable and pocket is release."""
401404
=== modified file 'lib/lp/archivepublisher/tests/test_publisher.py'
--- lib/lp/archivepublisher/tests/test_publisher.py 2010-08-31 11:11:09 +0000
+++ lib/lp/archivepublisher/tests/test_publisher.py 2010-10-07 14:15:57 +0000
@@ -22,7 +22,10 @@
22from canonical.launchpad.ftests.keys_for_tests import gpgkeysdir22from canonical.launchpad.ftests.keys_for_tests import gpgkeysdir
23from canonical.launchpad.interfaces.gpghandler import IGPGHandler23from canonical.launchpad.interfaces.gpghandler import IGPGHandler
24from canonical.zeca.ftests.harness import ZecaTestSetup24from canonical.zeca.ftests.harness import ZecaTestSetup
25from lp.archivepublisher.config import getPubConfig25from lp.archivepublisher.config import (
26 Config,
27 getPubConfig,
28 )
26from lp.archivepublisher.diskpool import DiskPool29from lp.archivepublisher.diskpool import DiskPool
27from lp.archivepublisher.interfaces.archivesigningkey import (30from lp.archivepublisher.interfaces.archivesigningkey import (
28 IArchiveSigningKey,31 IArchiveSigningKey,
@@ -767,7 +770,7 @@
767 self.checkDirtyPockets(publisher, expected=allowed_suites)770 self.checkDirtyPockets(publisher, expected=allowed_suites)
768771
769 def assertReleaseFileRequested(self, publisher, suite_name,772 def assertReleaseFileRequested(self, publisher, suite_name,
770 component_name, arch_name):773 component_name, archs):
771 """Assert the given context will have it's Release file regenerated.774 """Assert the given context will have it's Release file regenerated.
772775
773 Check if a request for the given context is correctly stored in:776 Check if a request for the given context is correctly stored in:
@@ -779,12 +782,10 @@
779 self.assertTrue(782 self.assertTrue(
780 component_name in suite,783 component_name in suite,
781 'Component %s/%s not requested' % (suite_name, component_name))784 'Component %s/%s not requested' % (suite_name, component_name))
782 self.assertTrue(785 self.assertEquals(archs, suite[component_name])
783 arch_name in suite[component_name],
784 'Arch %s/%s/%s not requested' % (
785 suite_name, component_name, arch_name))
786786
787 def checkAllRequestedReleaseFiles(self, publisher):787 def checkAllRequestedReleaseFiles(self, publisher,
788 architecturetags=('hppa', 'i386')):
788 """Check if all expected Release files are going to be regenerated.789 """Check if all expected Release files are going to be regenerated.
789790
790 'source', 'binary-i386' and 'binary-hppa' Release Files should be791 'source', 'binary-i386' and 'binary-hppa' Release Files should be
@@ -795,19 +796,17 @@
795 self.assertEqual(available_components,796 self.assertEqual(available_components,
796 ['main', 'multiverse', 'restricted', 'universe'])797 ['main', 'multiverse', 'restricted', 'universe'])
797798
798 available_archs = ['binary-%s' % a.architecturetag799 available_archs = ['binary-%s' % arch for arch in architecturetags]
799 for a in self.breezy_autotest.architectures]
800 self.assertEqual(available_archs, ['binary-hppa', 'binary-i386'])
801800
802 # XXX cprov 20071210: Include the artificial component 'source' as a801 # XXX cprov 20071210: Include the artificial component 'source' as a
803 # location to check for generated indexes. Ideally we should802 # location to check for generated indexes. Ideally we should
804 # encapsulate this task in publishing.py and this common method803 # encapsulate this task in publishing.py and this common method
805 # in tests as well.804 # in tests as well.
806 dists = ['source'] + available_archs805 all_archs = set(available_archs)
806 all_archs.add('source')
807 for component in available_components:807 for component in available_components:
808 for dist in dists:808 self.assertReleaseFileRequested(
809 self.assertReleaseFileRequested(809 publisher, 'breezy-autotest', component, all_archs)
810 publisher, 'breezy-autotest', component, dist)
811810
812 def _getReleaseFileOrigin(self, contents):811 def _getReleaseFileOrigin(self, contents):
813 origin_header = 'Origin: '812 origin_header = 'Origin: '
@@ -1082,6 +1081,73 @@
1082 # The Label: field should be set to the archive displayname1081 # The Label: field should be set to the archive displayname
1083 self.assertEqual(release_contents[1], 'Label: Partner archive')1082 self.assertEqual(release_contents[1], 'Label: Partner archive')
10841083
1084 def assertIndicesForArchitectures(self, publisher, present, absent):
1085 """Assert that the correct set of archs has indices.
1086
1087 Checks that the architecture tags in 'present' have Packages and
1088 Release files and are in the series' Release file, and confirms
1089 that those in 'absent' are not.
1090 """
1091
1092 self.checkAllRequestedReleaseFiles(
1093 publisher, architecturetags=present)
1094
1095 arch_template = os.path.join(
1096 publisher._config.distsroot, 'breezy-autotest/main/binary-%s')
1097 release_template = os.path.join(arch_template, 'Release')
1098 packages_template = os.path.join(arch_template, 'Packages')
1099 release_content = open(os.path.join(
1100 publisher._config.distsroot,
1101 'breezy-autotest/Release')).read()
1102
1103 for arch in present:
1104 self.assertTrue(os.path.exists(arch_template % arch))
1105 self.assertTrue(os.path.exists(release_template % arch))
1106 self.assertTrue(os.path.exists(packages_template % arch))
1107 self.assertTrue(arch in release_content)
1108
1109 for arch in absent:
1110 self.assertFalse(os.path.exists(arch_template % arch))
1111 self.assertFalse(arch in release_content)
1112
1113 def testNativeNoIndicesForDisabledArchitectures(self):
1114 """Test that no indices are created for disabled archs."""
1115 self.getPubBinaries()
1116
1117 ds = self.ubuntutest.getSeries('breezy-autotest')
1118 ds.getDistroArchSeries('i386').enabled = False
1119 self.config = Config(self.ubuntutest)
1120
1121 publisher = Publisher(
1122 self.logger, self.config, self.disk_pool,
1123 self.ubuntutest.main_archive)
1124
1125 publisher.A_publish(False)
1126 publisher.C_writeIndexes(False)
1127 publisher.D_writeReleaseFiles(False)
1128
1129 self.assertIndicesForArchitectures(
1130 publisher, present=['hppa'], absent=['i386'])
1131
1132 def testAptFtparchiveNoIndicesForDisabledArchitectures(self):
1133 """Test that no indices are created for disabled archs."""
1134 self.getPubBinaries()
1135
1136 ds = self.ubuntutest.getSeries('breezy-autotest')
1137 ds.getDistroArchSeries('i386').enabled = False
1138 self.config = Config(self.ubuntutest)
1139
1140 publisher = Publisher(
1141 self.logger, self.config, self.disk_pool,
1142 self.ubuntutest.main_archive)
1143
1144 publisher.A_publish(False)
1145 publisher.C_doFTPArchive(False)
1146 publisher.D_writeReleaseFiles(False)
1147
1148 self.assertIndicesForArchitectures(
1149 publisher, present=['hppa'], absent=['i386'])
1150
1085 def testWorldAndGroupReadablePackagesAndSources(self):1151 def testWorldAndGroupReadablePackagesAndSources(self):
1086 """Test Packages.gz and Sources.gz files are world and group readable.1152 """Test Packages.gz and Sources.gz files are world and group readable.
10871153

Subscribers

People subscribed via source and target branches

to status/vote changes: