[Buildroot] [PATCH 2/7] package/pkg-download: add repository macro

Thomas Perale thomas.perale at mind.be
Tue Apr 15 19:55:36 UTC 2025


This patch introduces the 'repository' macro that retrieve the repository
part of an URL.

This macro works for repositories that share the URL scheme of website
such as Github or Gitlab:

```
https://{github|gitlab}.com/<owner>/<name>
```

The macro will retrieve the '{github|gitlab}.com/<owner>/<name>' part of
the url.
This macro will works as well for the `<pkg>_SITE` variable made with
the `github` & `gitlab` macros.

For example with the 'mender' package version '3.5.3'. The `MENDER_SITE`
variable value is the following.

```
MENDER_SITE=https://github.com/mendersoftware/mender/archive/3.5.3
```

Calling the 'repository' macro will retrieve the following.

```
$(call repository,$(MENDER_SITE)) # github.com/mendersoftware/mender
```

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

diff --git a/package/pkg-download.mk b/package/pkg-download.mk
index cf5959ea95..4a2561cf86 100644
--- a/package/pkg-download.mk
+++ b/package/pkg-download.mk
@@ -49,6 +49,9 @@ notdomain = $(patsubst $(call domain,$(1),$(2))$(call domainseparator,$(2))%,%,$
 #
 # default domainseparator is /, specify alternative value as first argument
 domainseparator = $(if $(1),$(1),/)
+# Retrieve the repository from an url
+# repository: {github,gitlab}.com/<owner>/<name>
+repository = $(call domain,$(1))/$(word 1,$(subst /, ,$(call notdomain,$(1))))/$(word 2,$(subst /, ,$(call notdomain,$(1))))
 
 # github(user,package,version): returns site of GitHub repository
 github = https://github.com/$(1)/$(2)/archive/$(3)
-- 
2.49.0



More information about the buildroot mailing list