[1/2] base.bbclass: Enable the addition of epoch in an apt SRC_URI's version.

Message ID 20250108155703.10376-1-amy.fong.3142@gmail.com
State Accepted, archived
Headers show
Series [1/2] base.bbclass: Enable the addition of epoch in an apt SRC_URI's version. | expand

Commit Message

Amy Fong Jan. 8, 2025, 3:57 p.m. UTC
From: Amy Fong <amy.fong@siemens.com>

If the epoch is added in an apt's package version, there will be an
exception thrown as base.bbclass tries to parse the entry as a URI
(it complains about an invalid port). (man deb-version)

   e.g. SRC_URI = "apt://cryptsetup=2:2.6.1-4~deb12u2

Fix: remove apt:// entries in URI validation list.

Signed-off-by: Amy Fong <amy.fong@siemens.com>
---
 meta/classes/base.bbclass | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Jan Kiszka Jan. 8, 2025, 8:57 p.m. UTC | #1
On 08.01.25 16:57, Amy Fong wrote:
> From: Amy Fong <amy.fong@siemens.com>
> 
> If the epoch is added in an apt's package version, there will be an
> exception thrown as base.bbclass tries to parse the entry as a URI
> (it complains about an invalid port). (man deb-version)
> 
>    e.g. SRC_URI = "apt://cryptsetup=2:2.6.1-4~deb12u2
> 
> Fix: remove apt:// entries in URI validation list.
> 
> Signed-off-by: Amy Fong <amy.fong@siemens.com>
> ---
>  meta/classes/base.bbclass | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
> index b8825bd3..7d4ab49f 100644
> --- a/meta/classes/base.bbclass
> +++ b/meta/classes/base.bbclass
> @@ -123,9 +123,10 @@ python() {
>      needsrcrev = False
>      srcuri = d.getVar('SRC_URI')
>      for uri_string in srcuri.split():
> -        uri = bb.fetch.URI(uri_string)
> -        if uri.scheme in ("svn", "git", "gitsm", "hg", "p4", "repo"):
> -            needsrcrev = True
> +        if not uri_string.startswith("apt://"):
> +            uri = bb.fetch.URI(uri_string)
> +            if uri.scheme in ("svn", "git", "gitsm", "hg", "p4", "repo"):
> +                needsrcrev = True
>  
>      if needsrcrev:
>          d.setVar("SRCPV", "${@bb.fetch2.get_srcrev(d)}")

Looks good to me.

Jan
Uladzimir Bely Jan. 16, 2025, 7:03 a.m. UTC | #2
On Wed, 2025-01-08 at 10:57 -0500, Amy Fong wrote:
> From: Amy Fong <amy.fong@siemens.com>
> 
> If the epoch is added in an apt's package version, there will be an
> exception thrown as base.bbclass tries to parse the entry as a URI
> (it complains about an invalid port). (man deb-version)
> 
>    e.g. SRC_URI = "apt://cryptsetup=2:2.6.1-4~deb12u2
> 
> Fix: remove apt:// entries in URI validation list.
> 
> Signed-off-by: Amy Fong <amy.fong@siemens.com>
> ---
>  meta/classes/base.bbclass | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
> index b8825bd3..7d4ab49f 100644
> --- a/meta/classes/base.bbclass
> +++ b/meta/classes/base.bbclass
> @@ -123,9 +123,10 @@ python() {
>      needsrcrev = False
>      srcuri = d.getVar('SRC_URI')
>      for uri_string in srcuri.split():
> -        uri = bb.fetch.URI(uri_string)
> -        if uri.scheme in ("svn", "git", "gitsm", "hg", "p4",
> "repo"):
> -            needsrcrev = True
> +        if not uri_string.startswith("apt://"):
> +            uri = bb.fetch.URI(uri_string)
> +            if uri.scheme in ("svn", "git", "gitsm", "hg", "p4",
> "repo"):
> +                needsrcrev = True
>  
>      if needsrcrev:
>          d.setVar("SRCPV", "${@bb.fetch2.get_srcrev(d)}")
> -- 
> 2.39.5
> 

Patch 1 applied to next, thanks.

Patch

diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index b8825bd3..7d4ab49f 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -123,9 +123,10 @@  python() {
     needsrcrev = False
     srcuri = d.getVar('SRC_URI')
     for uri_string in srcuri.split():
-        uri = bb.fetch.URI(uri_string)
-        if uri.scheme in ("svn", "git", "gitsm", "hg", "p4", "repo"):
-            needsrcrev = True
+        if not uri_string.startswith("apt://"):
+            uri = bb.fetch.URI(uri_string)
+            if uri.scheme in ("svn", "git", "gitsm", "hg", "p4", "repo"):
+                needsrcrev = True
 
     if needsrcrev:
         d.setVar("SRCPV", "${@bb.fetch2.get_srcrev(d)}")