Merge lp:~laney/ubuntu-archive-publishing/more-options into lp:ubuntu-archive-publishing

Proposed by Iain Lane
Status: Merged
Merged at revision: 116
Proposed branch: lp:~laney/ubuntu-archive-publishing/more-options
Merge into: lp:ubuntu-archive-publishing
Diff against target: 156 lines (+39/-20)
2 files modified
lib/scripts/generate_extra_overrides.py (+31/-14)
tests/test_generate_extra_overrides.py (+8/-6)
To merge this branch: bzr merge lp:~laney/ubuntu-archive-publishing/more-options
Reviewer Review Type Date Requested Status
Colin Watson Approve
Ubuntu Package Archive Administrators Pending
Review via email: mp+402697@code.launchpad.net

Description of the change

Add some options to make it easier to run generate-extra-overrides locally

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/scripts/generate_extra_overrides.py'
--- lib/scripts/generate_extra_overrides.py 2020-02-06 12:21:14 +0000
+++ lib/scripts/generate_extra_overrides.py 2021-05-13 12:48:40 +0000
@@ -103,6 +103,15 @@
103 self.parser.add_option(103 self.parser.add_option(
104 "-s", "--series", dest="series", action="append",104 "-s", "--series", dest="series", action="append",
105 help="Series to operate on (may be given multiple times).")105 help="Series to operate on (may be given multiple times).")
106 self.parser.add_option(
107 "-a", "--arch", dest="architectures", action="append",
108 help="Arches to operate on (may be given multiple times).")
109 self.parser.add_option(
110 "-g", "--germinate-root", dest="germinate_root",
111 help="Location to write germinate output to.")
112 self.parser.add_option(
113 "-m", "--misc-root", dest="misc_root",
114 help="Location to write miscellaneous output to.")
106115
107 @property116 @property
108 def name(self):117 def name(self):
@@ -140,18 +149,20 @@
140 # the distribution's archives in the ARCHIVEROOTS environment149 # the distribution's archives in the ARCHIVEROOTS environment
141 # variable, joined by spaces. We only care about the first archive.150 # variable, joined by spaces. We only care about the first archive.
142 self.archiveroot = os.environ["ARCHIVEROOTS"].split()[0]151 self.archiveroot = os.environ["ARCHIVEROOTS"].split()[0]
143 self.germinateroot = self.archiveroot + "-germinate"152 if not self.options.germinate_root:
144 self.miscroot = self.archiveroot + "-misc"153 self.options.germinate_root = self.archiveroot + "-germinate"
154 if not self.options.misc_root:
155 self.options.misc_root = self.archiveroot + "-misc"
145156
146 def setUpDirs(self):157 def setUpDirs(self):
147 """Create output directories if they did not already exist."""158 """Create output directories if they did not already exist."""
148 if not file_exists(self.germinateroot):159 if not file_exists(self.options.germinate_root):
149 self.logger.debug(160 self.logger.debug(
150 "Creating germinate root %s.", self.germinateroot)161 "Creating germinate root %s.", self.options.germinate_root)
151 os.makedirs(self.germinateroot)162 os.makedirs(self.options.germinate_root)
152 if not file_exists(self.miscroot):163 if not file_exists(self.options.misc_root):
153 self.logger.debug("Creating misc root %s.", self.miscroot)164 self.logger.debug("Creating misc root %s.", self.options.misc_root)
154 os.makedirs(self.miscroot)165 os.makedirs(self.options.misc_root)
155166
156 def addLogHandler(self):167 def addLogHandler(self):
157 """Send germinate's log output to a separate file."""168 """Send germinate's log output to a separate file."""
@@ -160,7 +171,8 @@
160171
161 self.germinate_logger = logging.getLogger("germinate")172 self.germinate_logger = logging.getLogger("germinate")
162 self.germinate_logger.setLevel(logging.INFO)173 self.germinate_logger.setLevel(logging.INFO)
163 self.log_file = os.path.join(self.germinateroot, "germinate.output")174 self.log_file = os.path.join(self.options.germinate_root,
175 "germinate.output")
164 self.log_handler = logging.FileHandler(self.log_file, mode="w")176 self.log_handler = logging.FileHandler(self.log_file, mode="w")
165 self.log_handler.setFormatter(GerminateFormatter())177 self.log_handler.setFormatter(GerminateFormatter())
166 self.germinate_logger.addHandler(self.log_handler)178 self.germinate_logger.addHandler(self.log_handler)
@@ -212,7 +224,7 @@
212224
213 def composeOutputPath(self, flavour, series_name, arch, base):225 def composeOutputPath(self, flavour, series_name, arch, base):
214 return os.path.join(226 return os.path.join(
215 self.germinateroot,227 self.options.germinate_root,
216 "%s_%s_%s_%s" % (base, flavour, series_name, arch))228 "%s_%s_%s_%s" % (base, flavour, series_name, arch))
217229
218 def recordOutput(self, path, seed_outputs):230 def recordOutput(self, path, seed_outputs):
@@ -387,7 +399,8 @@
387 Any per-seed outputs not in seed_outputs are considered stale.399 Any per-seed outputs not in seed_outputs are considered stale.
388 """400 """
389 all_outputs = glob.glob(401 all_outputs = glob.glob(
390 os.path.join(self.germinateroot, "*_*_%s_*" % series_name))402 os.path.join(self.options.germinate_root,
403 "*_*_%s_*" % series_name))
391 for output in all_outputs:404 for output in all_outputs:
392 if os.path.basename(output) not in seed_outputs:405 if os.path.basename(output) not in seed_outputs:
393 os.remove(output)406 os.remove(output)
@@ -415,7 +428,8 @@
415428
416 seed_outputs = set()429 seed_outputs = set()
417 override_path = os.path.join(430 override_path = os.path.join(
418 self.miscroot, "more-extra.override.%s.main" % series_name)431 self.options.misc_root,
432 "more-extra.override.%s.main" % series_name)
419 with AtomicFile(override_path) as override_file:433 with AtomicFile(override_path) as override_file:
420 for pid, reader in procs:434 for pid, reader in procs:
421 log_records, overrides, arch_seed_outputs = pickle.load(435 log_records, overrides, arch_seed_outputs = pickle.load(
@@ -435,8 +449,11 @@
435 for series in self.series:449 for series in self.series:
436 series_name = series.name450 series_name = series.name
437 components = self.getComponents(series)451 components = self.getComponents(series)
438 architectures = sorted(452 if not self.options.architectures:
439 arch.architecture_tag for arch in series.architectures)453 architectures = sorted(
454 arch.architecture_tag for arch in series.architectures)
455 else:
456 architectures = self.options.architectures
440457
441 self.generateExtraOverrides(458 self.generateExtraOverrides(
442 series_name, components, architectures, self.args,459 series_name, components, architectures, self.args,
443460
=== modified file 'tests/test_generate_extra_overrides.py'
--- tests/test_generate_extra_overrides.py 2014-06-30 01:11:46 +0000
+++ tests/test_generate_extra_overrides.py 2021-05-13 12:48:40 +0000
@@ -453,7 +453,7 @@
453 flavour, self.distroseries[0].name, arch, base)453 flavour, self.distroseries[0].name, arch, base)
454 self.assertEqual(454 self.assertEqual(
455 "%s/%s_%s_%s_%s" % (455 "%s/%s_%s_%s_%s" % (
456 self.script.germinateroot, base, flavour,456 self.script.options.germinate_root, base, flavour,
457 self.distroseries[0].name, arch),457 self.distroseries[0].name, arch),
458 output)458 output)
459459
@@ -693,7 +693,7 @@
693 seed_old_file = "old_flavour_%s_i386" % series_name693 seed_old_file = "old_flavour_%s_i386" % series_name
694 seed_new_file = "new_flavour_%s_i386" % series_name694 seed_new_file = "new_flavour_%s_i386" % series_name
695 other_file = "other-file"695 other_file = "other-file"
696 output = partial(os.path.join, self.script.germinateroot)696 output = partial(os.path.join, self.script.options.germinate_root)
697 for base in (seed_old_file, seed_new_file, other_file):697 for base in (seed_old_file, seed_new_file, other_file):
698 write_file(output(base), "")698 write_file(output(base), "")
699 self.script.removeStaleOutputs(series_name, set([seed_new_file]))699 self.script.removeStaleOutputs(series_name, set([seed_new_file]))
@@ -716,10 +716,10 @@
716716
717 self.script.process(seed_bases=["file://%s" % self.seeddir])717 self.script.process(seed_bases=["file://%s" % self.seeddir])
718 self.assertFalse(os.path.exists(os.path.join(718 self.assertFalse(os.path.exists(os.path.join(
719 self.script.miscroot,719 self.script.options.misc_root,
720 "more-extra.override.%s.main" % self.distroseries[0].name)))720 "more-extra.override.%s.main" % self.distroseries[0].name)))
721 self.assertTrue(os.path.exists(os.path.join(721 self.assertTrue(os.path.exists(os.path.join(
722 self.script.miscroot,722 self.script.options.misc_root,
723 "more-extra.override.%s.main" % self.distroseries[1].name)))723 "more-extra.override.%s.main" % self.distroseries[1].name)))
724724
725 def test_process_removes_only_stale_files(self):725 def test_process_removes_only_stale_files(self):
@@ -784,7 +784,8 @@
784784
785 self.script.process(seed_bases=["file://%s" % self.seeddir])785 self.script.process(seed_bases=["file://%s" % self.seeddir])
786 override_path = os.path.join(786 override_path = os.path.join(
787 self.script.miscroot, "more-extra.override.%s.main" % series_name)787 self.script.options.misc_root,
788 "more-extra.override.%s.main" % series_name)
788 expected_overrides = [789 expected_overrides = [
789 "%s/%s Task %s" % (package, das_one.architecture_tag, seed),790 "%s/%s Task %s" % (package, das_one.architecture_tag, seed),
790 "%s/%s Task %s" % (package, das_two.architecture_tag, seed),791 "%s/%s Task %s" % (package, das_two.architecture_tag, seed),
@@ -792,7 +793,8 @@
792 self.assertCountEqual(793 self.assertCountEqual(
793 expected_overrides, file_contents(override_path).splitlines())794 expected_overrides, file_contents(override_path).splitlines())
794795
795 log_file = os.path.join(self.script.germinateroot, "germinate.output")796 log_file = os.path.join(self.script.options.germinate_root,
797 "germinate.output")
796 self.assertIn("Downloading file://", file_contents(log_file))798 self.assertIn("Downloading file://", file_contents(log_file))
797799
798 def test_run_script_help(self):800 def test_run_script_help(self):

Subscribers

People subscribed via source and target branches