Merge lp:~mvo/launchpad/add-cnf-metadata-to-release-file into lp:launchpad

Proposed by Michael Vogt
Status: Merged
Merged at revision: 18906
Proposed branch: lp:~mvo/launchpad/add-cnf-metadata-to-release-file
Merge into: lp:launchpad
Diff against target: 62 lines (+41/-0)
2 files modified
lib/lp/archivepublisher/publishing.py (+11/-0)
lib/lp/archivepublisher/tests/test_publisher.py (+30/-0)
To merge this branch: bzr merge lp:~mvo/launchpad/add-cnf-metadata-to-release-file
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+343161@code.launchpad.net

Commit message

Add command-not-found metadata in the archive to the Release file.

Description of the change

This tiny MP adds code to launchpad to add command-not-found metadata in the archive to the Release file so that this metadata can be fetched via `apt update`. Getting the metadata to this dir will require an extra MP for ubuntu-archive-publishing.

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) wrote :

Looks good to me apart from these comments, so let me know when you've fixed them and I can land this.

review: Approve
Revision history for this message
Colin Watson (cjwatson) :
Revision history for this message
Michael Vogt (mvo) wrote :

Thanks for the review! I updated the code now.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/archivepublisher/publishing.py'
--- lib/lp/archivepublisher/publishing.py 2019-02-20 16:13:20 +0000
+++ lib/lp/archivepublisher/publishing.py 2019-03-15 17:32:59 +0000
@@ -1218,6 +1218,17 @@
1218 except OSError as e:1218 except OSError as e:
1219 if e.errno != errno.ENOENT:1219 if e.errno != errno.ENOENT:
1220 raise1220 raise
1221 cnf_dir = os.path.join(suite_dir, component, "cnf")
1222 try:
1223 for cnf_file in os.listdir(cnf_dir):
1224 if cnf_file.startswith("Commands-"):
1225 cnf_path = os.path.join(
1226 component, "cnf", cnf_file)
1227 extra_files.add(remove_suffix(cnf_path))
1228 extra_files.add(cnf_path)
1229 except OSError as e:
1230 if e.errno != errno.ENOENT:
1231 raise
1221 for architecture in all_architectures:1232 for architecture in all_architectures:
1222 for contents_path in get_suffixed_indices(1233 for contents_path in get_suffixed_indices(
1223 'Contents-' + architecture):1234 'Contents-' + architecture):
12241235
=== modified file 'lib/lp/archivepublisher/tests/test_publisher.py'
--- lib/lp/archivepublisher/tests/test_publisher.py 2019-02-20 16:13:20 +0000
+++ lib/lp/archivepublisher/tests/test_publisher.py 2019-03-15 17:32:59 +0000
@@ -2190,6 +2190,36 @@
2190 self.assertReleaseContentsMatch(2190 self.assertReleaseContentsMatch(
2191 release, os.path.join('main', 'dep11', name), f.read())2191 release, os.path.join('main', 'dep11', name), f.read())
21922192
2193 def testReleaseFileForCommandNotFound(self):
2194 # Test Release file writing for command-not-found metadata.
2195 publisher = Publisher(
2196 self.logger, self.config, self.disk_pool,
2197 self.ubuntutest.main_archive)
2198
2199 # Put some cnf metadata files in place, and force the publisher
2200 # to republish that suite.
2201 series_path = os.path.join(self.config.distsroot, 'breezy-autotest')
2202 cnf_path = os.path.join(series_path, 'main', 'cnf')
2203 cnf_names = ('Commands-amd64.xz', 'Commands-i386.xz')
2204 os.makedirs(cnf_path)
2205 for name in cnf_names:
2206 with gzip.GzipFile(os.path.join(cnf_path, name), 'wb') as f:
2207 f.write(name)
2208 publisher.markPocketDirty(
2209 self.ubuntutest.getSeries('breezy-autotest'),
2210 PackagePublishingPocket.RELEASE)
2211
2212 publisher.A_publish(False)
2213 publisher.C_doFTPArchive(False)
2214 publisher.D_writeReleaseFiles(False)
2215
2216 # The metadata files are listed correctly in Release.
2217 release = self.parseRelease(os.path.join(series_path, 'Release'))
2218 for name in cnf_names:
2219 with open(os.path.join(cnf_path, name), 'rb') as f:
2220 self.assertReleaseContentsMatch(
2221 release, os.path.join('main', 'cnf', name), f.read())
2222
2193 def testReleaseFileTimestamps(self):2223 def testReleaseFileTimestamps(self):
2194 # The timestamps of Release and all its core entries match.2224 # The timestamps of Release and all its core entries match.
2195 publisher = Publisher(2225 publisher = Publisher(