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
=== modified file 'lib/lp/archivepublisher/model/ftparchive.py'
--- lib/lp/archivepublisher/model/ftparchive.py 2016-03-17 14:47:14 +0000
+++ lib/lp/archivepublisher/model/ftparchive.py 2016-04-05 03:44:26 +0000
@@ -3,6 +3,7 @@
33
4from collections import defaultdict4from collections import defaultdict
5import os5import os
6import re
6from StringIO import StringIO7from StringIO import StringIO
7import time8import time
89
@@ -50,11 +51,15 @@
50 return (os.path.basename(filename).split("_"))[0]51 return (os.path.basename(filename).split("_"))[0]
5152
5253
53def make_empty_dir(path):54def make_clean_dir(path, clean_pattern=".*"):
54 """Ensure that the path exists and is an empty directory."""55 """Ensure that the path exists and is an empty directory.
56
57 :param clean_pattern: a regex of filenames to remove from the directory.
58 If omitted, all files are removed.
59 """
55 if os.path.isdir(path):60 if os.path.isdir(path):
56 for name in os.listdir(path):61 for name in os.listdir(path):
57 if name == "by-hash":62 if name == "by-hash" or not re.match(clean_pattern, name):
58 # Ignore existing by-hash directories; they will be cleaned63 # Ignore existing by-hash directories; they will be cleaned
59 # up to match the rest of the directory tree later.64 # up to match the rest of the directory tree later.
60 continue65 continue
@@ -772,13 +777,18 @@
772 for comp in comps:777 for comp in comps:
773 component_path = os.path.join(778 component_path = os.path.join(
774 self._config.distsroot, suite, comp)779 self._config.distsroot, suite, comp)
775 make_empty_dir(os.path.join(component_path, "source"))780 make_clean_dir(os.path.join(component_path, "source"))
776 if not distroseries.include_long_descriptions:781 if not distroseries.include_long_descriptions:
777 make_empty_dir(os.path.join(component_path, "i18n"))782 # apt-ftparchive only generates the English
783 # translations; DDTP custom uploads might have put other
784 # files here that we want to keep.
785 make_clean_dir(
786 os.path.join(component_path, "i18n"),
787 r'Translation-en(\..*)?$')
778 for arch in archs:788 for arch in archs:
779 make_empty_dir(os.path.join(component_path, "binary-" + arch))789 make_clean_dir(os.path.join(component_path, "binary-" + arch))
780 for subcomp in self.publisher.subcomponents:790 for subcomp in self.publisher.subcomponents:
781 make_empty_dir(os.path.join(791 make_clean_dir(os.path.join(
782 component_path, subcomp, "binary-" + arch))792 component_path, subcomp, "binary-" + arch))
783793
784 def writeAptConfig(self, apt_config, suite, comps, archs,794 def writeAptConfig(self, apt_config, suite, comps, archs,
785795
=== modified file 'lib/lp/archivepublisher/tests/test_ftparchive.py'
--- lib/lp/archivepublisher/tests/test_ftparchive.py 2016-02-09 01:18:37 +0000
+++ lib/lp/archivepublisher/tests/test_ftparchive.py 2016-04-05 03:44:26 +0000
@@ -555,6 +555,12 @@
555 os.makedirs(os.path.join(comp_dir, "uefi"))555 os.makedirs(os.path.join(comp_dir, "uefi"))
556 with open(os.path.join(comp_dir, "uefi", "stuff"), "w"):556 with open(os.path.join(comp_dir, "uefi", "stuff"), "w"):
557 pass557 pass
558 os.makedirs(os.path.join(comp_dir, "i18n"))
559 for name in ("Translation-de", "Translation-de.gz", "Translation-en",
560 "Translation-en.Z"):
561 with open(os.path.join(comp_dir, "i18n", name), "w"):
562 pass
563 self._distribution["hoary-test"].include_long_descriptions = False
558564
559 # Run the publisher once with gzip and bzip2 compressors.565 # Run the publisher once with gzip and bzip2 compressors.
560 apt_conf = fa.generateConfig(fullpublish=True)566 apt_conf = fa.generateConfig(fullpublish=True)
@@ -572,6 +578,10 @@
572 self.assertContentEqual(578 self.assertContentEqual(
573 ["Sources.gz", "Sources.bz2"],579 ["Sources.gz", "Sources.bz2"],
574 os.listdir(os.path.join(comp_dir, "source")))580 os.listdir(os.path.join(comp_dir, "source")))
581 self.assertContentEqual(
582 ["Translation-de", "Translation-de.gz", "Translation-en.gz",
583 "Translation-en.bz2"],
584 os.listdir(os.path.join(comp_dir, "i18n")))
575585
576 # Try again, this time with gzip and xz compressors. There are no586 # Try again, this time with gzip and xz compressors. There are no
577 # bzip2 leftovers, but other files are left untouched.587 # bzip2 leftovers, but other files are left untouched.
@@ -593,6 +603,10 @@
593 ["Sources.gz", "Sources.xz"],603 ["Sources.gz", "Sources.xz"],
594 os.listdir(os.path.join(comp_dir, "source")))604 os.listdir(os.path.join(comp_dir, "source")))
595 self.assertEqual(["stuff"], os.listdir(os.path.join(comp_dir, "uefi")))605 self.assertEqual(["stuff"], os.listdir(os.path.join(comp_dir, "uefi")))
606 self.assertContentEqual(
607 ["Translation-de", "Translation-de.gz", "Translation-en.gz",
608 "Translation-en.xz"],
609 os.listdir(os.path.join(comp_dir, "i18n")))
596610
597 def test_cleanCaches_noop_if_recent(self):611 def test_cleanCaches_noop_if_recent(self):
598 # cleanCaches does nothing if it was run recently.612 # cleanCaches does nothing if it was run recently.