← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:soss-source-url-deb into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:soss-source-url-deb into launchpad:master.

Commit message:
Add soss.source_url property to Debian binaries in Artifactory

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #1999821 in Launchpad itself: "soss.source_url is missing for published deb files"
  https://bugs.launchpad.net/launchpad/+bug/1999821

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

We agreed this in https://docs.google.com/spreadsheets/d/15Xkdi-CRu2NiQfLoclP5PKW63Zw6syiuao8VJG7zxvw some time ago in order to make it easier to build automation around Artifactory, but I managed to forget about it.  Fortunately it's relatively straightforward, since .dsc file names are predictable given the source name and version.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:soss-source-url-deb into launchpad:master.
diff --git a/lib/lp/archivepublisher/artifactory.py b/lib/lp/archivepublisher/artifactory.py
index 2d16d99..95ad5c4 100644
--- a/lib/lp/archivepublisher/artifactory.py
+++ b/lib/lp/archivepublisher/artifactory.py
@@ -22,6 +22,7 @@ from packaging import utils as packaging_utils
 from zope.security.proxy import isinstance as zope_isinstance
 
 from lp.archivepublisher.diskpool import FileAddActionEnum, poolify
+from lp.archiveuploader.utils import re_no_epoch
 from lp.registry.interfaces.sourcepackage import SourcePackageFileType
 from lp.services.config import config
 from lp.services.librarian.utils import copy_and_close
@@ -263,6 +264,21 @@ class ArtifactoryPoolEntry:
                         "/usr/share/doc/%s/copyright"
                         % publications[0].binary_package_name
                     ]
+                    # Point to the corresponding .dsc, so that binaries
+                    # uniformly have a property referring to their source
+                    # code.  We don't have the .dsc conveniently in hand
+                    # here without a cumbersome database walk, but
+                    # fortunately it has a predictable file name.
+                    properties["soss.source_url"] = [
+                        (
+                            self.rootpath
+                            / poolify(self.source_name)
+                            / "{}_{}.dsc".format(
+                                self.source_name,
+                                re_no_epoch.sub("", self.source_version),
+                            )
+                        ).as_posix()
+                    ]
             else:
                 properties["launchpad.channel"] = sorted(
                     {
diff --git a/lib/lp/archivepublisher/tests/test_artifactory.py b/lib/lp/archivepublisher/tests/test_artifactory.py
index da1a31a..cc86e74 100644
--- a/lib/lp/archivepublisher/tests/test_artifactory.py
+++ b/lib/lp/archivepublisher/tests/test_artifactory.py
@@ -623,6 +623,10 @@ class TestArtifactoryPoolFromLibrarian(TestCaseWithFactory):
                 "deb.component": ["main"],
                 "deb.architecture": [processor.name],
                 "soss.license": ["/usr/share/doc/foo/copyright"],
+                "soss.source_url": [
+                    "https://foo.example.com/artifactory/repository/";
+                    "pool/f/foo/foo_1.0.dsc"
+                ],
                 "soss.type": ["binary"],
             },
             path.properties,
@@ -695,6 +699,10 @@ class TestArtifactoryPoolFromLibrarian(TestCaseWithFactory):
                     sorted(das.architecturetag for das in dases)
                 ),
                 "soss.license": ["/usr/share/doc/foo/copyright"],
+                "soss.source_url": [
+                    "https://foo.example.com/artifactory/repository/";
+                    "pool/f/foo/foo_1.0.dsc"
+                ],
                 "soss.type": ["binary"],
             },
             path.properties,
@@ -1435,6 +1443,10 @@ class TestArtifactoryPoolFromLibrarian(TestCaseWithFactory):
                 "deb.architecture": [das.architecturetag],
                 "deb.version": ["1.0"],
                 "soss.license": ["/usr/share/doc/foo/copyright"],
+                "soss.source_url": [
+                    "https://foo.example.com/artifactory/repository/";
+                    "pool/f/foo/foo_1.0.dsc"
+                ],
                 "soss.type": ["binary"],
             },
             path.properties,