mirror of
https://git.yoctoproject.org/poky
synced 2026-05-30 12:29:55 +00:00
classes/lib/scripts: Use bb.utils.rename() instead of os.rename()
Incremental build in Docker fails with: OSError: [Errno 18] Invalid cross-device link when source and destination are on different overlay filesystems. Rather than adding fallback code to every call site, use a new wrapper in bitbake which detects this case and falls back to shutil.move which is slower but will handtle the overlay docker filesystems correctly. [YOCTO #14301] (From OE-Core rev: 656a65b2b84e7d529b89cf5de7eb838f902d84a2) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
974441aeda
commit
b71375304f
@@ -875,7 +875,7 @@ python buildhistory_eventhandler() {
|
||||
entries = [ x for x in os.listdir(rootdir) if not x.startswith('.') ]
|
||||
bb.utils.mkdirhier(olddir)
|
||||
for entry in entries:
|
||||
os.rename(os.path.join(rootdir, entry),
|
||||
bb.utils.rename(os.path.join(rootdir, entry),
|
||||
os.path.join(olddir, entry))
|
||||
elif isinstance(e, bb.event.BuildCompleted):
|
||||
if reset:
|
||||
|
||||
@@ -1049,7 +1049,7 @@ python fixup_perms () {
|
||||
# Create path to move directory to, move it, and then setup the symlink
|
||||
bb.utils.mkdirhier(os.path.dirname(target))
|
||||
#bb.note("Fixup Perms: Rename %s -> %s" % (dir, ptarget))
|
||||
os.rename(origin, target)
|
||||
bb.utils.rename(origin, target)
|
||||
#bb.note("Fixup Perms: Link %s -> %s" % (dir, link))
|
||||
os.symlink(link, origin)
|
||||
|
||||
@@ -1967,7 +1967,7 @@ python package_do_shlibs() {
|
||||
|
||||
for (old, new) in renames:
|
||||
bb.note("Renaming %s to %s" % (old, new))
|
||||
os.rename(old, new)
|
||||
bb.utils.rename(old, new)
|
||||
pkgfiles[pkg].remove(old)
|
||||
|
||||
shlibs_file = os.path.join(shlibswork_dir, pkg + ".list")
|
||||
|
||||
@@ -165,7 +165,7 @@ def create_filtered_tasklist(d, sdkbasepath, tasklistfile, conf_initpath):
|
||||
shutil.rmtree(temp_sdkbasepath)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
os.rename(sdkbasepath, temp_sdkbasepath)
|
||||
bb.utils.rename(sdkbasepath, temp_sdkbasepath)
|
||||
cmdprefix = '. %s .; ' % conf_initpath
|
||||
logfile = d.getVar('WORKDIR') + '/tasklist_bb_log.txt'
|
||||
try:
|
||||
@@ -175,7 +175,7 @@ def create_filtered_tasklist(d, sdkbasepath, tasklistfile, conf_initpath):
|
||||
if 'attempted to execute unexpectedly and should have been setscened' in e.stdout:
|
||||
msg += '\n----------\n\nNOTE: "attempted to execute unexpectedly and should have been setscened" errors indicate this may be caused by missing sstate artifacts that were likely produced in earlier builds, but have been subsequently deleted for some reason.\n'
|
||||
bb.fatal(msg)
|
||||
os.rename(temp_sdkbasepath, sdkbasepath)
|
||||
bb.utils.rename(temp_sdkbasepath, sdkbasepath)
|
||||
# Clean out residue of running bitbake, which check_sstate_task_list()
|
||||
# will effectively do
|
||||
clean_esdk_builddir(d, sdkbasepath)
|
||||
|
||||
@@ -66,7 +66,7 @@ python do_deploy_source_date_epoch_setscene () {
|
||||
if os.path.exists(sde_file):
|
||||
target = d.getVar('SDE_FILE')
|
||||
bb.debug(1, "Moving setscene SDE file %s -> %s" % (sde_file, target))
|
||||
os.rename(sde_file, target)
|
||||
bb.utils.rename(sde_file, target)
|
||||
else:
|
||||
bb.debug(1, "%s not found!" % sde_file)
|
||||
}
|
||||
|
||||
@@ -401,7 +401,7 @@ def sstate_installpkgdir(ss, d):
|
||||
|
||||
for state in ss['dirs']:
|
||||
prepdir(state[1])
|
||||
os.rename(sstateinst + state[0], state[1])
|
||||
bb.utils.rename(sstateinst + state[0], state[1])
|
||||
sstate_install(ss, d)
|
||||
|
||||
for plain in ss['plaindirs']:
|
||||
@@ -413,7 +413,7 @@ def sstate_installpkgdir(ss, d):
|
||||
dest = plain
|
||||
bb.utils.mkdirhier(src)
|
||||
prepdir(dest)
|
||||
os.rename(src, dest)
|
||||
bb.utils.rename(src, dest)
|
||||
|
||||
return True
|
||||
|
||||
@@ -664,7 +664,7 @@ def sstate_package(ss, d):
|
||||
continue
|
||||
bb.error("sstate found an absolute path symlink %s pointing at %s. Please replace this with a relative link." % (srcpath, link))
|
||||
bb.debug(2, "Preparing tree %s for packaging at %s" % (state[1], sstatebuild + state[0]))
|
||||
os.rename(state[1], sstatebuild + state[0])
|
||||
bb.utils.rename(state[1], sstatebuild + state[0])
|
||||
|
||||
workdir = d.getVar('WORKDIR')
|
||||
sharedworkdir = os.path.join(d.getVar('TMPDIR'), "work-shared")
|
||||
@@ -674,7 +674,7 @@ def sstate_package(ss, d):
|
||||
pdir = plain.replace(sharedworkdir, sstatebuild)
|
||||
bb.utils.mkdirhier(plain)
|
||||
bb.utils.mkdirhier(pdir)
|
||||
os.rename(plain, pdir)
|
||||
bb.utils.rename(plain, pdir)
|
||||
|
||||
d.setVar('SSTATE_BUILDDIR', sstatebuild)
|
||||
d.setVar('SSTATE_INSTDIR', sstatebuild)
|
||||
|
||||
@@ -184,7 +184,7 @@ python apply_update_alternative_renames () {
|
||||
link_rename.append((alt_target, alt_target_rename))
|
||||
else:
|
||||
bb.note('%s: Rename %s -> %s' % (pn, alt_target, alt_target_rename))
|
||||
os.rename(src, dest)
|
||||
bb.utils.rename(src, dest)
|
||||
update_files(alt_target, alt_target_rename, pkg, d)
|
||||
else:
|
||||
bb.warn("%s: alternative target (%s or %s) does not exist, skipping..." % (pn, alt_target, alt_target_rename))
|
||||
@@ -201,7 +201,7 @@ python apply_update_alternative_renames () {
|
||||
if os.path.lexists(link_target):
|
||||
# Ok, the link_target exists, we can rename
|
||||
bb.note('%s: Rename (link) %s -> %s' % (pn, alt_target, alt_target_rename))
|
||||
os.rename(src, dest)
|
||||
bb.utils.rename(src, dest)
|
||||
else:
|
||||
# Try to resolve the broken link to link.${BPN}
|
||||
link_maybe = '%s.%s' % (os.readlink(src), pn)
|
||||
|
||||
Reference in New Issue
Block a user