← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad/sign-parts-archive-root into lp:launchpad

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/sign-parts-archive-root into lp:launchpad.

Commit message:
Pass ARCHIVEROOT to sign.d scripts.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/sign-parts-archive-root/+merge/342286

This is needed for the implementation in lp:ubuntu-archive-publishing to find its GnuPG home directory.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/sign-parts-archive-root into lp:launchpad.
=== modified file 'lib/lp/archivepublisher/archivesigningkey.py'
--- lib/lp/archivepublisher/archivesigningkey.py	2018-03-27 23:02:02 +0000
+++ lib/lp/archivepublisher/archivesigningkey.py	2018-03-28 09:43:49 +0000
@@ -106,6 +106,7 @@
             elif find_run_parts_dir(
                     self.archive.distribution.name, "sign.d") is not None:
                 env = {
+                    "ARCHIVEROOT": self.pubconf.archiveroot,
                     "INPUT_PATH": input_path,
                     "OUTPUT_PATH": output_path,
                     "MODE": mode.name.lower(),

=== modified file 'lib/lp/archivepublisher/tests/test_archivesigningkey.py'
--- lib/lp/archivepublisher/tests/test_archivesigningkey.py	2018-03-27 23:02:02 +0000
+++ lib/lp/archivepublisher/tests/test_archivesigningkey.py	2018-03-28 09:43:49 +0000
@@ -116,7 +116,8 @@
                 "10-sign"), "w") as sign_script:
             sign_script.write(dedent("""\
                 #! /bin/sh
-                echo "$MODE signature of $INPUT_PATH ($DISTRIBUTION/$SUITE)" \\
+                echo "$MODE signature of $INPUT_PATH" \\
+                     "($ARCHIVEROOT, $DISTRIBUTION/$SUITE)" \\
                     >"$OUTPUT_PATH"
                 """))
             os.fchmod(sign_script.fileno(), 0o755)
@@ -133,13 +134,15 @@
         self.assertThat(
             os.path.join(suite_dir, "Release.gpg"),
             FileContains(
-                "detached signature of %s (%s/%s)\n" %
-                (release_path, self.distro.name, self.suite)))
+                "detached signature of %s (%s, %s/%s)\n" %
+                (release_path, self.archive_root, self.distro.name,
+                 self.suite)))
         self.assertThat(
             os.path.join(suite_dir, "InRelease"),
             FileContains(
-                "clear signature of %s (%s/%s)\n" %
-                (release_path, self.distro.name, self.suite)))
+                "clear signature of %s (%s, %s/%s)\n" %
+                (release_path, self.archive_root, self.distro.name,
+                 self.suite)))
 
     def test_signRepository_honours_pubconf(self):
         pubconf = getPubConfig(self.archive)
@@ -156,13 +159,15 @@
         self.assertThat(
             os.path.join(suite_dir, "Release.gpg"),
             FileContains(
-                "detached signature of %s (%s/%s)\n" %
-                (release_path, self.distro.name, self.suite)))
+                "detached signature of %s (%s, %s/%s)\n" %
+                (release_path, self.archive_root, self.distro.name,
+                 self.suite)))
         self.assertThat(
             os.path.join(suite_dir, "InRelease"),
             FileContains(
-                "clear signature of %s (%s/%s)\n" %
-                (release_path, self.distro.name, self.suite)))
+                "clear signature of %s (%s, %s/%s)\n" %
+                (release_path, self.archive_root, self.distro.name,
+                 self.suite)))
 
     def test_signFile_runs_parts(self):
         filename = os.path.join(self.archive_root, "signme")
@@ -175,5 +180,5 @@
         self.assertThat(
             "%s.gpg" % filename,
             FileContains(
-                "detached signature of %s (%s/%s)\n" %
-                (filename, self.distro.name, self.suite)))
+                "detached signature of %s (%s, %s/%s)\n" %
+                (filename, self.archive_root, self.distro.name, self.suite)))

=== modified file 'lib/lp/archivepublisher/tests/test_customupload.py'
--- lib/lp/archivepublisher/tests/test_customupload.py	2018-03-26 06:51:44 +0000
+++ lib/lp/archivepublisher/tests/test_customupload.py	2018-03-28 09:43:49 +0000
@@ -275,8 +275,8 @@
 
     def test_sign_with_external_run_parts(self):
         self.enableRunParts(distribution_name=self.distro.name)
-        filename = os.path.join(
-            getPubConfig(self.archive).archiveroot, "file")
+        archiveroot = getPubConfig(self.archive).archiveroot
+        filename = os.path.join(archiveroot, "file")
         write_file(filename, "contents")
         self.assertIsNone(self.archive.signing_key)
         run_parts_fixture = self.useFixture(MonkeyPatch(
@@ -286,6 +286,7 @@
         args, kwargs = run_parts_fixture.new_value.calls[0]
         self.assertEqual((self.distro.name, "sign.d"), args)
         self.assertThat(kwargs["env"], MatchesDict({
+            "ARCHIVEROOT": Equals(archiveroot),
             "INPUT_PATH": Equals(filename),
             "OUTPUT_PATH": Equals("%s.gpg" % filename),
             "MODE": Equals("detached"),

=== modified file 'lib/lp/archivepublisher/tests/test_publisher.py'
--- lib/lp/archivepublisher/tests/test_publisher.py	2018-03-27 23:02:02 +0000
+++ lib/lp/archivepublisher/tests/test_publisher.py	2018-03-28 09:43:49 +0000
@@ -3095,7 +3095,8 @@
         with open(os.path.join(sign_directory, '10-sign'), 'w') as sign_script:
             sign_script.write(dedent("""\
                 #! /bin/sh
-                echo "$MODE signature of $INPUT_PATH ($DISTRIBUTION/$SUITE)" \\
+                echo "$MODE signature of $INPUT_PATH" \\
+                     "($ARCHIVEROOT, $DISTRIBUTION/$SUITE)" \\
                     >"$OUTPUT_PATH"
                 """))
             os.fchmod(sign_script.fileno(), 0o755)
@@ -3114,13 +3115,17 @@
         self.assertThat(
             self.release_file_signature_path,
             FileContains(
-                "detached signature of %s.new (%s/breezy-autotest)\n" %
-                (self.release_file_path, cprov.archive.distribution.name)))
+                "detached signature of %s.new (%s, %s/breezy-autotest)\n" %
+                (self.release_file_path,
+                 self.archive_publisher._config.archiveroot,
+                 cprov.archive.distribution.name)))
         self.assertThat(
             self.inline_release_file_path,
             FileContains(
-                "clear signature of %s.new (%s/breezy-autotest)\n" %
-                (self.release_file_path, cprov.archive.distribution.name)))
+                "clear signature of %s.new (%s, %s/breezy-autotest)\n" %
+                (self.release_file_path,
+                 self.archive_publisher._config.archiveroot,
+                 cprov.archive.distribution.name)))
 
         # The publisher synchronises the various Release file timestamps.
         self.assertEqual(1, self.archive_publisher._syncTimestamps.call_count)

=== modified file 'lib/lp/archivepublisher/tests/test_signing.py'
--- lib/lp/archivepublisher/tests/test_signing.py	2018-03-26 06:51:44 +0000
+++ lib/lp/archivepublisher/tests/test_signing.py	2018-03-28 09:43:49 +0000
@@ -961,6 +961,8 @@
         args, kwargs = run_parts_fixture.new_value.calls[-1]
         self.assertEqual((self.distro.name, "sign.d"), args)
         self.assertThat(kwargs["env"], MatchesDict({
+            "ARCHIVEROOT": Equals(
+                os.path.join(self.temp_dir, self.distro.name)),
             "INPUT_PATH": Equals(sha256file),
             "OUTPUT_PATH": Equals("%s.gpg" % sha256file),
             "MODE": Equals("detached"),


Follow ups