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

Proposed by Michael Vogt on 2018-04-13
Status: Needs review
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
Launchpad code reviewers 2018-04-13 Pending
Review via email: mp+343161@code.launchpad.net

Commit message

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.

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.

Unmerged revisions

18610. By Michael Vogt on 2018-04-13

archivepublisher: add support for cnf metadata adding

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/archivepublisher/publishing.py'
2--- lib/lp/archivepublisher/publishing.py 2018-03-27 23:26:12 +0000
3+++ lib/lp/archivepublisher/publishing.py 2018-04-13 15:19:18 +0000
4@@ -1212,6 +1212,17 @@
5 except OSError as e:
6 if e.errno != errno.ENOENT:
7 raise
8+ cnf_dir = os.path.join(suite_dir, component, "cnf")
9+ try:
10+ for cnf_file in os.listdir(cnf_dir):
11+ if dep11_file.startswith("Commands-"):
12+ cnf_path = os.path.join(
13+ component, "cnf", cnf_file)
14+ extra_files.add(remove_suffix(cnf_path))
15+ extra_files.add(cnf_path)
16+ except OSError as e:
17+ if e.errno != errno.ENOENT:
18+ raise
19 for architecture in all_architectures:
20 for contents_path in get_suffixed_indices(
21 'Contents-' + architecture):
22
23=== modified file 'lib/lp/archivepublisher/tests/test_publisher.py'
24--- lib/lp/archivepublisher/tests/test_publisher.py 2018-04-05 11:32:50 +0000
25+++ lib/lp/archivepublisher/tests/test_publisher.py 2018-04-13 15:19:18 +0000
26@@ -2189,6 +2189,36 @@
27 self.assertReleaseContentsMatch(
28 release, os.path.join('main', 'dep11', name), f.read())
29
30+ def testReleaseFileForCommandNotFound(self):
31+ # Test Release file writing for command-not-found metadata.
32+ publisher = Publisher(
33+ self.logger, self.config, self.disk_pool,
34+ self.ubuntutest.main_archive)
35+
36+ # Put some cnf metadata files in place, and force the publisher
37+ # to republish that suite.
38+ series_path = os.path.join(self.config.distsroot, 'breezy-autotest')
39+ cnf_path = os.path.join(series_path, 'main', 'cnf')
40+ cnf_names = ('Commands-amd64.gz', 'Commands-i386.gz')
41+ os.makedirs(cnf_path)
42+ for name in cnf_names:
43+ with gzip.GzipFile(os.path.join(cnf_path, name), 'wb') as f:
44+ f.write(name)
45+ publisher.markPocketDirty(
46+ self.ubuntutest.getSeries('breezy-autotest'),
47+ PackagePublishingPocket.RELEASE)
48+
49+ publisher.A_publish(False)
50+ publisher.C_doFTPArchive(False)
51+ publisher.D_writeReleaseFiles(False)
52+
53+ # The metadata files are listed correctly in Release.
54+ release = self.parseRelease(os.path.join(series_path, 'Release'))
55+ for name in cnf_names:
56+ with open(os.path.join(cnf_path, name), 'rb') as f:
57+ self.assertReleaseContentsMatch(
58+ release, os.path.join('main', 'cnf', name), f.read())
59+
60 def testReleaseFileTimestamps(self):
61 # The timestamps of Release and all its core entries match.
62 publisher = Publisher(