fetch2/git: Ensure gitsrcname is not too long

Message ID 20220531094535.9841-1-jan.brzezanski@gmail.com
State New
Headers show
Series fetch2/git: Ensure gitsrcname is not too long | expand

Commit Message

Jan Brzezanski May 31, 2022, 9:45 a.m. UTC
If SRC_URI is pointing to local repository, it can happen that
the path will be over 255 characters. When transformed into filename,
bitbake will fail/hang on e.g. trying to create lockfile based on this
name.

Thus we make sure to truncate this string to last 230 characters
(arbitrary number) when it exceeds this limit.

Signed-off-by: Jan Brzezanski <jan.brzezanski@gmail.com>
Signed-off-by: Tomasz Dziendzielski <tomasz.dziendzielski@gmail.com>
---
 lib/bb/fetch2/git.py | 2 ++
 1 file changed, 2 insertions(+)

Comments

Richard Purdie June 4, 2022, 11:24 a.m. UTC | #1
On Tue, 2022-05-31 at 11:45 +0200, Jan Brzezanski wrote:
> If SRC_URI is pointing to local repository, it can happen that
> the path will be over 255 characters. When transformed into filename,
> bitbake will fail/hang on e.g. trying to create lockfile based on this
> name.
> 
> Thus we make sure to truncate this string to last 230 characters
> (arbitrary number) when it exceeds this limit.
> 
> Signed-off-by: Jan Brzezanski <jan.brzezanski@gmail.com>
> Signed-off-by: Tomasz Dziendzielski <tomasz.dziendzielski@gmail.com>
> ---
>  lib/bb/fetch2/git.py | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py
> index 23f8c0da..77bd9be3 100644
> --- a/lib/bb/fetch2/git.py
> +++ b/lib/bb/fetch2/git.py
> @@ -259,6 +259,8 @@ class Git(FetchMethod):
>                  ud.revisions[name] = self.latest_revision(ud, d, name)
>  
>          gitsrcname = '%s%s' % (ud.host.replace(':', '.'), ud.path.replace('/', '.').replace('*', '.').replace(' ','_'))
> +        if len(gitsrcname) > 230:
> +            gitsrcname = gitsrcname[-230:]
>          if gitsrcname.startswith('.'):
>              gitsrcname = gitsrcname[1:]
>  

Which release of the project is this with? I ask since there is this
code:

https://git.yoctoproject.org/poky/commit/bitbake/lib/bb/utils.py?id=09e826cfb021731c1b139046665d2d9fa24baa88
https://git.yoctoproject.org/poky/commit/bitbake/lib/bb/utils.py?id=273b124bf6acd77b074fde2421be331721a68c11

Are you saying that isn't working?

Cheers,

Richard

Patch

diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py
index 23f8c0da..77bd9be3 100644
--- a/lib/bb/fetch2/git.py
+++ b/lib/bb/fetch2/git.py
@@ -259,6 +259,8 @@  class Git(FetchMethod):
                 ud.revisions[name] = self.latest_revision(ud, d, name)
 
         gitsrcname = '%s%s' % (ud.host.replace(':', '.'), ud.path.replace('/', '.').replace('*', '.').replace(' ','_'))
+        if len(gitsrcname) > 230:
+            gitsrcname = gitsrcname[-230:]
         if gitsrcname.startswith('.'):
             gitsrcname = gitsrcname[1:]