Merge lp:~wgrant/launchpad/bug-1565861 into lp:launchpad

Proposed by William Grant
Status: Merged
Merged at revision: 17984
Proposed branch: lp:~wgrant/launchpad/bug-1565861
Merge into: lp:launchpad
Diff against target: 92 lines (+31/-7)
2 files modified
lib/lp/archivepublisher/model/ftparchive.py (+17/-7)
lib/lp/archivepublisher/tests/test_ftparchive.py (+14/-0)
To merge this branch: bzr merge lp:~wgrant/launchpad/bug-1565861
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+290945@code.launchpad.net

Commit message

Fix apt-ftparchive integration to not delete non-English Translation-*.

Description of the change

Fix apt-ftparchive integration to not delete non-English Translation-*.

r17923 changed FTPArchiveHandler.generateConfigForPocket to ensure that
the index directories were all empty -- including i18n. But i18n also
includes files extracted from DDTP custom uploads, so we can't delete
everything. Instead, just delete Translation-en and its compressed
variants.

NMAF is unaffected, as disabled compressed variants are deleted by
RepositoryIndexFile instead.

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/archivepublisher/model/ftparchive.py'
2--- lib/lp/archivepublisher/model/ftparchive.py 2016-03-17 14:47:14 +0000
3+++ lib/lp/archivepublisher/model/ftparchive.py 2016-04-05 03:44:26 +0000
4@@ -3,6 +3,7 @@
5
6 from collections import defaultdict
7 import os
8+import re
9 from StringIO import StringIO
10 import time
11
12@@ -50,11 +51,15 @@
13 return (os.path.basename(filename).split("_"))[0]
14
15
16-def make_empty_dir(path):
17- """Ensure that the path exists and is an empty directory."""
18+def make_clean_dir(path, clean_pattern=".*"):
19+ """Ensure that the path exists and is an empty directory.
20+
21+ :param clean_pattern: a regex of filenames to remove from the directory.
22+ If omitted, all files are removed.
23+ """
24 if os.path.isdir(path):
25 for name in os.listdir(path):
26- if name == "by-hash":
27+ if name == "by-hash" or not re.match(clean_pattern, name):
28 # Ignore existing by-hash directories; they will be cleaned
29 # up to match the rest of the directory tree later.
30 continue
31@@ -772,13 +777,18 @@
32 for comp in comps:
33 component_path = os.path.join(
34 self._config.distsroot, suite, comp)
35- make_empty_dir(os.path.join(component_path, "source"))
36+ make_clean_dir(os.path.join(component_path, "source"))
37 if not distroseries.include_long_descriptions:
38- make_empty_dir(os.path.join(component_path, "i18n"))
39+ # apt-ftparchive only generates the English
40+ # translations; DDTP custom uploads might have put other
41+ # files here that we want to keep.
42+ make_clean_dir(
43+ os.path.join(component_path, "i18n"),
44+ r'Translation-en(\..*)?$')
45 for arch in archs:
46- make_empty_dir(os.path.join(component_path, "binary-" + arch))
47+ make_clean_dir(os.path.join(component_path, "binary-" + arch))
48 for subcomp in self.publisher.subcomponents:
49- make_empty_dir(os.path.join(
50+ make_clean_dir(os.path.join(
51 component_path, subcomp, "binary-" + arch))
52
53 def writeAptConfig(self, apt_config, suite, comps, archs,
54
55=== modified file 'lib/lp/archivepublisher/tests/test_ftparchive.py'
56--- lib/lp/archivepublisher/tests/test_ftparchive.py 2016-02-09 01:18:37 +0000
57+++ lib/lp/archivepublisher/tests/test_ftparchive.py 2016-04-05 03:44:26 +0000
58@@ -555,6 +555,12 @@
59 os.makedirs(os.path.join(comp_dir, "uefi"))
60 with open(os.path.join(comp_dir, "uefi", "stuff"), "w"):
61 pass
62+ os.makedirs(os.path.join(comp_dir, "i18n"))
63+ for name in ("Translation-de", "Translation-de.gz", "Translation-en",
64+ "Translation-en.Z"):
65+ with open(os.path.join(comp_dir, "i18n", name), "w"):
66+ pass
67+ self._distribution["hoary-test"].include_long_descriptions = False
68
69 # Run the publisher once with gzip and bzip2 compressors.
70 apt_conf = fa.generateConfig(fullpublish=True)
71@@ -572,6 +578,10 @@
72 self.assertContentEqual(
73 ["Sources.gz", "Sources.bz2"],
74 os.listdir(os.path.join(comp_dir, "source")))
75+ self.assertContentEqual(
76+ ["Translation-de", "Translation-de.gz", "Translation-en.gz",
77+ "Translation-en.bz2"],
78+ os.listdir(os.path.join(comp_dir, "i18n")))
79
80 # Try again, this time with gzip and xz compressors. There are no
81 # bzip2 leftovers, but other files are left untouched.
82@@ -593,6 +603,10 @@
83 ["Sources.gz", "Sources.xz"],
84 os.listdir(os.path.join(comp_dir, "source")))
85 self.assertEqual(["stuff"], os.listdir(os.path.join(comp_dir, "uefi")))
86+ self.assertContentEqual(
87+ ["Translation-de", "Translation-de.gz", "Translation-en.gz",
88+ "Translation-en.xz"],
89+ os.listdir(os.path.join(comp_dir, "i18n")))
90
91 def test_cleanCaches_noop_if_recent(self):
92 # cleanCaches does nothing if it was run recently.