Skip to contentSkip to conversation

fetch2/git: Ensure gitsrcname is not too long

PATCH In review Jan Brzezanski 2 participants 2 messages May 31, 2022 – Jun 4, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fetch2/git: Ensure gitsrcname is not too long

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.

---
 lib/bb/fetch2/git.py | 2 ++
 1 file changed, 2 insertions(+)
lib/bb/fetch2/git.py +2 -0
index 23f8c0da..77bd9be3 100644
@@ -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:]
 
Signature · 1 line
2.30.0
#1 lore raw
Quoted 19 lines · Jan Brzezanski

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.

---
 lib/bb/fetch2/git.py | 2 ++
 1 file changed, 2 insertions(+)
lib/bb/fetch2/git.py +0 -0
index 23f8c0da..77bd9be3 100644

lib/bb/fetch2/git.py class Git(FetchMethod): · line 266

Quoted 8 lines
lib/bb/fetch2/git.py +2 -0
@@ -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