Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH] spdx30_tasks: Fix duplicated revision in Git PURLs
@ 2026-08-25 10:44 KAZUYOSHI AKIYAMA (秋山 和慶)
  2026-09-08 14:44 ` Joshua Watt
  0 siblings, 1 reply; 5+ messages in thread
From: KAZUYOSHI AKIYAMA (秋山 和慶) @ 2026-08-25 10:44 UTC (permalink / raw)
  To: openembedded-core@lists.openembedded.org
  Cc: JPEWhacker@gmail.com, stondo@gmail.com

_generate_git_purl() generates invalid PURLs of the form
`pkg:github/<owner>/<repo>@<rev>@<rev>`.
purl-spec only allows a single `@<rev>`.

oe.spdx_common.fetch_data_to_uri() already appends "@<rev>" to the
download location, and urlparse() leaves that suffix in parsed.path.
Therefore, the parsed repository name(`{repo}`) includes `@<rev>`.
So, need to strip the revision suffix before splitting out
the owner(`{owner}`) and the repository name(`{repo}`).

While here, replace str.replace(".git", "") with str.removesuffix() so
repository names that contain ".git" elsewhere are preserved.

Signed-off-by: Kazuyoshi Akiyama <kazuyoshi_akiyama@jp.honda>
---
 meta/lib/oe/spdx30_tasks.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/meta/lib/oe/spdx30_tasks.py b/meta/lib/oe/spdx30_tasks.py
index dac02e3784..b2f208e1f6 100644
--- a/meta/lib/oe/spdx30_tasks.py
+++ b/meta/lib/oe/spdx30_tasks.py
@@ -379,11 +379,14 @@ def _generate_git_purl(d, download_location, srcrev):
 
     for domain, purl_type in git_purl_handlers.items():
         if hostname == domain:
-            path = parsed.path.strip("/")
+            # oe.spdx_common.fetch_data_to_uri() appends "@<rev>" to the
+            # download location, which must not become part of the
+            # repository name
+            path = parsed.path.strip("/").partition("@")[0]
             path_parts = path.split("/")
             if len(path_parts) >= 2:
                 owner = path_parts[0]
-                repo = path_parts[1].replace(".git", "")
+                repo = path_parts[1].removesuffix(".git")
                 return f"{purl_type}/{owner}/{repo}@{srcrev}"
             break
 
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-10-30  7:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-25 10:44 [PATCH] spdx30_tasks: Fix duplicated revision in Git PURLs KAZUYOSHI AKIYAMA (秋山 和慶)
2026-09-08 14:44 ` Joshua Watt
2026-10-30  0:09   ` [OE-core] " KAZUYOSHI AKIYAMA (秋山 和慶)
2026-10-30  7:11     ` Mathieu Dubois-Briand
2026-10-30  7:14       ` KAZUYOSHI AKIYAMA (秋山 和慶)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox