All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Perale via buildroot <buildroot@buildroot.org>
To: buildroot@buildroot.org
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	Thomas Perale <thomas.perale@mind.be>,
	Christian Stewart <christian@aperture.us>,
	Arnout Vandecappelle <arnout@rnout.be>
Subject: [Buildroot] [PATCH 1/7] package/pkg-generic.mk: add PURL package variable
Date: Tue, 15 Apr 2025 21:55:34 +0200	[thread overview]
Message-ID: <20250415195547.199428-2-thomas.perale@mind.be> (raw)
In-Reply-To: <20250415195547.199428-1-thomas.perale@mind.be>

PURL stands for 'package URL', it's a specification that standardize
how packages are identified and located.

PURL is used to reference the same package across different package
manager, tracking tools, API and databases.

A purl is a URL composed of seven components:

  scheme:type/namespace/name@version?qualifiers#subpath

  - scheme: always 'pkg' (required)
  - type: package manager used to install the package, download origin,
      type of package (required)
  - namespace: name prefix, type specific additional information, it can be
      the package author or scope (optional)
  - name: package name (required)
  - version: package version (optional)
  - qualifiers: extra information, could be OS or architecture (optional)
  - subpath: extra subpath relative to package root (optional)

A PURL for the purl-spec repository looks like this:

  pkg:github/package-url/purl-spec@346589846130317464b677bc4eab30bf5040183a

It contains information like the provenance (github), organization
(package-url), name (purl-spec) and version (34658984...).

This patch only introduces a subset of components but can be extended in
the future.

Similarly to the CPE variables, this patch introduces a set of PURL variable:
  - <pkg>_PURL_VALID: Whether the PURL generated for the given <pkg> is
    valid. If set to 'yes' the `<pkg>_PURL` will be defined.
    Similarly to the `<pkg>_CPE_ID_VALID` variable, this will be
    set to 'yes' if one of the following variable is defined.
  - <pkg>_PURL_TYPE: The package type or origin (default to 'generic').
  - <pkg>_PURL_NAMESPACE: The package namespace (optional).
  - <pkg>_PURL_NAME: The package name (default to `<pkg>_RAWNAME`).

If one of those variables is defined the `<pkg>_PURL` variable will be
generated as follows:

  <pkg>_PURL = pkg:$$(<pkg>_PURL_NAMESPACE)/$$(<pkg>_PURL_TYPE)/$$(<pkg>_PURL_NAME)@$$(<pkg>_VERSION)

For more information, see https://github.com/package-url/purl-spec

Signed-off-by: Thomas Perale <thomas.perale@mind.be>
---
 package/pkg-generic.mk | 53 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
index f22b6e981a..1e68f48f7c 100644
--- a/package/pkg-generic.mk
+++ b/package/pkg-generic.mk
@@ -745,6 +745,59 @@ ifeq ($$($(2)_CPE_ID_VALID),YES)
  $(2)_CPE_ID = $$($(2)_CPE_ID_PREFIX):$$($(2)_CPE_ID_VENDOR):$$($(2)_CPE_ID_PRODUCT):$$($(2)_CPE_ID_VERSION):$$($(2)_CPE_ID_UPDATE):*:*:*:*:*:*
 endif # ifeq ($$($(2)_CPE_ID_VALID),YES)
 
+# If any of the <pkg>_PURL_* variables are set, we assume the PURL
+# information is valid for this package.
+ifneq ($$($(2)_PURL_TYPE)$$($(2)_PURL_NAME)$$($(2)_PURL_NAMESPACE),)
+$(2)_PURL_VALID = YES
+endif
+
+# When we're a host package, make sure to use the variables of the
+# corresponding target package, if any.
+ifneq ($$($(3)_PURL_TYPE)$$($(3)_PURL_NAME)$$($(3)_PURL_NAMESPACE),)
+$(2)_PURL_VALID = YES
+endif
+
+# If the PURL is valid for the target package so it is for the host
+# package
+ifndef $(2)_PURL_VALID
+ ifdef $(3)_PURL_VALID
+   $(2)_PURL_VALID = $$($(3)_PURL_VALID)
+ endif
+endif
+
+ifeq ($$($(2)_PURL_VALID),YES)
+  # The package PURL type or provider.
+  # ex. pypi, npm, gem, ...
+  ifndef $(2)_PURL_TYPE
+   ifdef $(3)_PURL_TYPE
+    $(2)_PURL_TYPE = $$($(3)_PURL_TYPE)
+   else
+    $(2)_PURL_TYPE = generic
+   endif
+  endif
+
+  # The package PURL optional namespace
+  ifndef $(2)_PURL_NAMESPACE
+   ifdef $(3)_PURL_NAMESPACE
+    $(2)_PURL_NAMESPACE = $$($(3)_PURL_NAMESPACE)
+   endif
+  endif
+
+  # The package PURL name
+  # default to $(2)_RAWNAME
+  ifndef $(2)_PURL_NAME
+   ifdef $(3)_PURL_NAME
+    $(2)_PURL_NAME = $$($(3)_PURL_NAME)
+   else
+    $(2)_PURL_NAME = $$($(2)_RAWNAME)
+   endif
+  endif
+
+  # A PURL is created based on the $(2)_PURL_* variable values.
+  # see https://github.com/package-url/purl-spec
+  $(2)_PURL = pkg:$$($(2)_PURL_TYPE)/$$(if $$($(2)_PURL_NAMESPACE),$$($(2)_PURL_NAMESPACE)/)$$($(2)_PURL_NAME)$$(if $$($(2)_VERSION),@$$($(2)_VERSION))
+endif # ifeq ($$($(2)_PURL_VALID),YES)
+
 # When a target package is a toolchain dependency set this variable to
 # 'NO' so the 'toolchain' dependency is not added to prevent a circular
 # dependency.
-- 
2.49.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

  reply	other threads:[~2025-04-15 19:56 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-15 19:55 [Buildroot] [PATCH 0/7] Add PURL support Thomas Perale via buildroot
2025-04-15 19:55 ` Thomas Perale via buildroot [this message]
2025-04-15 19:55 ` [Buildroot] [PATCH 2/7] package/pkg-download: add 'owner' macro Thomas Perale via buildroot
2025-04-15 19:55 ` [Buildroot] [PATCH 2/7] package/pkg-download: add repository macro Thomas Perale via buildroot
2025-04-15 19:55 ` [Buildroot] [PATCH 3/7] package/pkg-golang: support PURL generation Thomas Perale via buildroot
2025-04-15 19:55 ` [Buildroot] [PATCH 4/7] package/pkg-cargo: " Thomas Perale via buildroot
2025-04-15 19:55 ` [Buildroot] [PATCH 5/7] package/pkg-perl: " Thomas Perale via buildroot
2025-04-15 19:55 ` [Buildroot] [PATCH 6/7] package/pkg-python: " Thomas Perale via buildroot
2025-04-15 19:55 ` [Buildroot] [PATCH 7/7] package/pkg-utils: add PURL to show-info output Thomas Perale via buildroot
2025-04-16 19:07 ` [Buildroot] [PATCH 0/7] Add PURL support Peter Korsgaard
2025-04-16 19:19   ` Arnout Vandecappelle via buildroot
     [not found]     ` <4b029329-2258-428d-80c9-315dbd6335be@essensium.com>
2025-04-16 19:58       ` Thomas Petazzoni via buildroot
2025-04-16 20:06         ` Thomas Perale via buildroot
2025-04-16 20:40           ` Thomas Petazzoni via buildroot
2025-04-16 20:49             ` Thomas Perale via buildroot
2025-04-18 10:39               ` Thomas Petazzoni via buildroot
2025-04-21 20:19                 ` Thomas Perale via buildroot
2025-04-22 12:53                   ` Thomas Petazzoni via buildroot
2025-04-22 14:00                     ` Peter Korsgaard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250415195547.199428-2-thomas.perale@mind.be \
    --to=buildroot@buildroot.org \
    --cc=arnout@rnout.be \
    --cc=christian@aperture.us \
    --cc=thomas.perale@mind.be \
    --cc=thomas.petazzoni@bootlin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.