diff mbox series

[wrynose,2.18,4/6] fetch/wget: Handle long filenames correctly

Message ID 65f17fdeeebfc0213cf2c809d08f7c4129fbe355.1790495161.git.yoann.congal@smile.fr
State RFC, archived
Delegated to: Yoann Congal
Headers show
Series [wrynose,2.18,1/6] runqueue: Fix pending_hash_index not including taskname | expand

Commit Message

Yoann Congal Sept. 27, 2026, 7:46 a.m. UTC
From: Richard Purdie <richard.purdie@linuxfoundation.org>

Long filenames, which may happen through sstate, were being handled incorrectly
as they could exceed max path lengths when '.tmp' was added.

Handle those cases by using slightly shorter filenames if that happens for the
intermediate tmp file.

[YOCTO #16293]

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit da1fcdf15c647a2a718ae921e261a76e451b442a)
Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
---
 lib/bb/fetch2/wget.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/lib/bb/fetch2/wget.py b/lib/bb/fetch2/wget.py
index c292dfe7e..58f1a86e7 100644
--- a/lib/bb/fetch2/wget.py
+++ b/lib/bb/fetch2/wget.py
@@ -105,7 +105,10 @@  class Wget(FetchMethod):
         fetchcmd = self.basecmd
 
         dldir = os.path.realpath(d.getVar("DL_DIR"))
-        localpath = os.path.join(dldir, ud.localfile) + ".tmp"
+        # Where we ultimately want the file
+        finalpath = os.path.join(dldir, ud.localfile)
+        # A temp location while processing, keeping in mind max path lengths
+        localpath = finalpath[:250] + ".tmp"
         bb.utils.mkdirhier(os.path.dirname(localpath))
         fetchcmd += " --output-document=%s" % shlex.quote(localpath)
 
@@ -142,7 +145,7 @@  class Wget(FetchMethod):
 
         # Remove the ".tmp" and move the file into position atomically
         # Our lock prevents multiple writers but mirroring code may grab incomplete files
-        os.rename(localpath, localpath[:-4])
+        os.rename(localpath, finalpath)
 
         return True