← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~wgrant/launchpad/maybe-publish-debug-symbols-respeck into lp:launchpad

 

William Grant has proposed merging lp:~wgrant/launchpad/maybe-publish-debug-symbols-respeck into lp:launchpad.

Commit message:
Only publish ddebs to disk when publish_debug_symbols is true.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~wgrant/launchpad/maybe-publish-debug-symbols-respeck/+merge/163846

Only publish ddebs to the pool when Archive.publish_debug_symbols is true. They'll still show up in PPA indices until the next branch splits them out into a separate disableable subcomponent.

Enabling the flag after ddeb publication has already been skipped can result in indices referencing non-existent files, but it's a restricted and little-used flag so that shouldn't be a big issue. deathrow handles missing files fine.
-- 
https://code.launchpad.net/~wgrant/launchpad/maybe-publish-debug-symbols-respeck/+merge/163846
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/maybe-publish-debug-symbols-respeck into lp:launchpad.
=== modified file 'lib/lp/soyuz/model/publishing.py'
--- lib/lp/soyuz/model/publishing.py	2013-05-14 06:30:37 +0000
+++ lib/lp/soyuz/model/publishing.py	2013-05-15 06:01:31 +0000
@@ -988,6 +988,15 @@
         """See `IBinaryPackagePublishingHistory`."""
         return self.archive.getPackageDownloadTotal(self.binarypackagerelease)
 
+    def publish(self, diskpool, log):
+        """See `IPublishing`."""
+        if (self.binarypackagerelease.binpackageformat ==
+                BinaryPackageFormat.DDEB
+            and not self.archive.publish_debug_symbols):
+            self.setPublished()
+        else:
+            super(BinaryPackagePublishingHistory, self).publish(diskpool, log)
+
     def buildIndexStanzaFields(self):
         """See `IPublishing`."""
         bpr = self.binarypackagerelease

=== modified file 'lib/lp/soyuz/tests/test_publishing.py'
--- lib/lp/soyuz/tests/test_publishing.py	2013-05-14 10:44:35 +0000
+++ lib/lp/soyuz/tests/test_publishing.py	2013-05-15 06:01:31 +0000
@@ -668,6 +668,33 @@
         pool_path = "%s/main/f/foo/foo-bin_666_all.deb" % self.pool_dir
         self.assertEqual(open(pool_path).read().strip(), 'Hello world')
 
+    def test_publish_ddeb_when_disabled_is_noop(self):
+        # Publishing a DDEB publication when
+        # Archive.publish_debug_symbols is false just sets PUBLISHED,
+        # without a file in the pool.
+        pubs = self.getPubBinaries(
+            binaryname='dbg', filecontent='Hello world', with_debug=True)
+
+        def publish_everything():
+            existence_map = {}
+            for pub in pubs:
+                pub.publish(self.disk_pool, self.logger)
+                self.assertEqual(PackagePublishingStatus.PUBLISHED, pub.status)
+                filename = pub.files[0].libraryfilealias.filename
+                path = "%s/main/d/dbg/%s" % (self.pool_dir, filename)
+                existence_map[filename] = os.path.exists(path)
+            return existence_map
+
+        self.assertEqual(
+            {u'dbg_666_all.deb': True, u'dbg-dbgsym_666_all.ddeb': False},
+            publish_everything())
+
+        pubs[0].archive.publish_debug_symbols = True
+
+        self.assertEqual(
+            {u'dbg_666_all.deb': True, u'dbg-dbgsym_666_all.ddeb': True},
+            publish_everything())
+
     def testPublishingOverwriteFileInPool(self):
         """Test if publishOne refuses to overwrite a file in pool.