← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~rvb/launchpad/package-copier-noarch-crash into lp:launchpad

 

Raphaël Victor Badin has proposed merging lp:~rvb/launchpad/package-copier-noarch-crash into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #815911 in Launchpad itself: "Copying packages with binaries into a distro can crash the code if the arch is not supported by the destination series."
  https://bugs.launchpad.net/launchpad/+bug/815911

For more details, see:
https://code.launchpad.net/~rvb/launchpad/package-copier-noarch-crash/+merge/69095

When binary packages are copied into a series by the package copier, if the target archive has an override policy and the series does not support the architecture of the package, this can lead to a crash (see bug report).

This branch fixes that by adding a filter to the architectures considered.

= Test =

./bin/test -vvc test_copypackage test_copying_unsupported_arch_with_override

= Q/A =

The fix (done manually) has already been QAed on DF.
-- 
https://code.launchpad.net/~rvb/launchpad/package-copier-noarch-crash/+merge/69095
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rvb/launchpad/package-copier-noarch-crash into lp:launchpad.
=== modified file 'lib/lp/soyuz/model/publishing.py'
--- lib/lp/soyuz/model/publishing.py	2011-07-22 11:12:23 +0000
+++ lib/lp/soyuz/model/publishing.py	2011-07-25 14:36:10 +0000
@@ -1010,7 +1010,7 @@
         #  <DESCRIPTION LN>
         descr_lines = [line.lstrip() for line in bpr.description.splitlines()]
         bin_description = (
-            '%s\n %s'% (bpr.summary, '\n '.join(descr_lines)))
+            '%s\n %s' % (bpr.summary, '\n '.join(descr_lines)))
 
         # Dealing with architecturespecific field.
         # Present 'all' in every archive index for architecture
@@ -1364,6 +1364,8 @@
             overrides = policy.calculateBinaryOverrides(
                 archive, distroseries, pocket, bpn_archtag.keys())
             for override in overrides:
+                if override.distro_arch_series is None:
+                    continue
                 bpph = bpn_archtag[
                     (override.binary_package_name,
                      override.distro_arch_series.architecturetag)]
@@ -1376,6 +1378,8 @@
             with_overrides = dict(
                 (bpph.binarypackagerelease, (bpph.component, bpph.section,
                  bpph.priority)) for bpph in binaries)
+        if not with_overrides:
+            return list()
         return self.publishBinaries(
             archive, distroseries, pocket, with_overrides)
 

=== modified file 'lib/lp/soyuz/scripts/tests/test_copypackage.py'
--- lib/lp/soyuz/scripts/tests/test_copypackage.py	2011-06-13 09:43:22 +0000
+++ lib/lp/soyuz/scripts/tests/test_copypackage.py	2011-07-25 14:36:10 +0000
@@ -84,7 +84,6 @@
     )
 from lp.soyuz.tests.test_publishing import SoyuzTestPublisher
 from lp.testing import (
-    person_logged_in,
     StormStatementRecorder,
     TestCaseWithFactory,
     )
@@ -1348,7 +1347,7 @@
             bin_i386.component, bin_i386, copied_bin_i386)
         self.assertComponentSectionAndPriority(
             bin_hppa.component, bin_hppa, copied_bin_hppa)
-        
+
     def test_existing_publication_no_overrides(self):
         # When we copy source/binaries into a PPA, we don't respect their
         # component and section.
@@ -1485,6 +1484,29 @@
             send_email=False)
         self.assertEquals([], pop_notifications())
 
+    def test_copying_unsupported_arch_with_override(self):
+        # When the copier is passed an unsupported arch with an override
+        # on the destination series, no binary is copied.
+        archive = self.factory.makeArchive(
+            distribution=self.test_publisher.ubuntutest, virtualized=False)
+        source = self.test_publisher.getPubSource(
+            archive=archive, architecturehintlist='all')
+        self.test_publisher.getPubBinaries(pub_source=source)
+
+        # Now make a new distroseries with only one architecture:
+        # 'hppa'.
+        nobby = self.createNobby(('hppa', ))
+
+        # Copy the package with binaries.
+        target_archive = self.factory.makeArchive(
+            purpose=ArchivePurpose.PRIMARY,
+            distribution=self.test_publisher.ubuntutest, virtualized=False)
+        copies = _do_direct_copy(source, target_archive, nobby, source.pocket,
+            include_binaries=True, close_bugs=False, create_dsd_job=False)
+
+        # Only the source package has been copied.
+        self.assertEqual(1, len(copies))
+
 
 class TestDoDelayedCopy(TestCaseWithFactory, BaseDoCopyTests):