Patchwork [bitbake-devel,1/1,RFC] fetch2/git.py: fix the filename too long error

login
register
mail settings
Submitter Robert Yang
Date Nov. 8, 2013, 4:31 p.m.
Message ID <589acd189b9af4ebb3e13845de0cba3035db37e0.1383927399.git.liezhi.yang@windriver.com>
Download mbox | patch
Permalink /patch/61321/
State New
Headers show

Comments

Robert Yang - Nov. 8, 2013, 4:31 p.m.
When we use the PREMIRROR/MIRROR from the local disk, and if it is in a
deep directory, for example, when len(path) > 255 (The NAME_MAX), we
will get the "filename too long error".

This is becuase we use ud.path.replace('/', '.') to change the path to
the filename. We seldom see such a long url, but it is easy to produce
it on the local machine.

Another problem is that:

file:///local/path

will be converted into .local.path whichi is a hidden file by default.

Don't convert the name when ud.proto == "file" will fix the problem.

PS:
- This is only for git, other fetchers also have the similar problem,
  will send the patch for others if this is fine.

- Another solution might be: use the md5sum(path) as part of the
  filename, I'm not sure whether it is worth.

[YOCTO #5389]

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
 bitbake/lib/bb/fetch2/git.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Patch

diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py
index 6175e4c..53fd2f5 100644
--- a/bitbake/lib/bb/fetch2/git.py
+++ b/bitbake/lib/bb/fetch2/git.py
@@ -127,7 +127,10 @@  class Git(FetchMethod):
                     ud.branches[name] = ud.revisions[name]
                 ud.revisions[name] = self.latest_revision(ud.url, ud, d, name)
 
-        gitsrcname = '%s%s' % (ud.host.replace(':','.'), ud.path.replace('/', '.').replace('*', '.'))
+        if ud.proto == "file":
+            gitsrcname = '%s%s' % ("file...", os.path.basename(ud.path))
+        else:
+            gitsrcname = '%s%s' % (ud.host.replace(':','.'), ud.path.replace('/', '.').replace('*', '.'))
         # for rebaseable git repo, it is necessary to keep mirror tar ball
         # per revision, so that even the revision disappears from the
         # upstream repo in the future, the mirror will remain intact and still