← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:package-copier-non-debian into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:package-copier-non-debian into launchpad:master.

Commit message:
Fix failure to copy non-Debian-format packages

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #2022095 in Launchpad itself: "Launchpad fails to copy packages in non-deb PPAs"
  https://bugs.launchpad.net/launchpad/+bug/2022095

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/448263

Source packages in non-Debian formats (e.g. CI builds) don't have a `dsc_format`.  Skip the check for whether the source package format is supported by the target series in that case.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:package-copier-non-debian into launchpad:master.
diff --git a/lib/lp/soyuz/scripts/packagecopier.py b/lib/lp/soyuz/scripts/packagecopier.py
index a09270a..eb8ac61 100644
--- a/lib/lp/soyuz/scripts/packagecopier.py
+++ b/lib/lp/soyuz/scripts/packagecopier.py
@@ -498,15 +498,16 @@ class CopyChecker:
                 )
             )
 
-        format = SourcePackageFormat.getTermByToken(
-            source.sourcepackagerelease.dsc_format
-        ).value
+        if source.sourcepackagerelease.dsc_format is not None:
+            format = SourcePackageFormat.getTermByToken(
+                source.sourcepackagerelease.dsc_format
+            ).value
 
-        if not series.isSourcePackageFormatPermitted(format):
-            raise CannotCopy(
-                "Source format '%s' not supported by target series %s."
-                % (source.sourcepackagerelease.dsc_format, series.name)
-            )
+            if not series.isSourcePackageFormatPermitted(format):
+                raise CannotCopy(
+                    "Source format '%s' not supported by target series %s."
+                    % (source.sourcepackagerelease.dsc_format, series.name)
+                )
 
         # Deny copies of source publications containing files with an
         # expiration date set.
diff --git a/lib/lp/soyuz/scripts/tests/test_copypackage.py b/lib/lp/soyuz/scripts/tests/test_copypackage.py
index 5e867fa..491f1b5 100644
--- a/lib/lp/soyuz/scripts/tests/test_copypackage.py
+++ b/lib/lp/soyuz/scripts/tests/test_copypackage.py
@@ -21,6 +21,7 @@ from lp.buildmaster.enums import BuildStatus
 from lp.buildmaster.interfaces.processor import IProcessorSet
 from lp.registry.interfaces.distribution import IDistributionSet
 from lp.registry.interfaces.pocket import PackagePublishingPocket
+from lp.registry.interfaces.sourcepackage import SourcePackageType
 from lp.services.database.constants import UTC_NOW
 from lp.services.database.sqlbase import flush_database_caches
 from lp.soyuz.adapters.overrides import SourceOverride
@@ -1221,6 +1222,30 @@ class CopyCheckerTestCase(TestCaseWithFactory):
             ),
         )
 
+    def test_checkCopy_non_debian(self):
+        build = self.factory.makeCIBuild()
+        distroseries = self.factory.makeDistroSeries()
+        archive = self.factory.makeArchive(
+            distribution=distroseries.distribution
+        )
+        spn = self.factory.makeSourcePackageName()
+        spr = build.createSourcePackageRelease(
+            distroseries,
+            spn,
+            "1.0",
+            creator=build.git_repository.owner,
+            archive=archive,
+        )
+        spph = self.factory.makeSourcePackagePublishingHistory(
+            sourcepackagerelease=spr, format=SourcePackageType.CI_BUILD
+        )
+        copy_checker = CopyChecker(archive, include_binaries=False)
+        self.assertIsNone(
+            copy_checker.checkCopy(
+                spph, distroseries, spph.pocket, check_permissions=False
+            )
+        )
+
 
 class BaseDoCopyTests:
     layer = LaunchpadZopelessLayer