summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDevendra Tewari <devendra.tewari@gmail.com>2021-04-19 11:23:58 -0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-05-06 11:16:23 +0100
commitb71375304f393db62e0894af66e9a60bb9a5c8cc (patch)
treeac14a351c1c6cd0ba2679c18a4de92c71dee0e7f
parent974441aeda1a2e601865743e945e0332c115ef76 (diff)
downloadpoky-b71375304f393db62e0894af66e9a60bb9a5c8cc.tar.gz
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>
-rw-r--r--meta/classes/buildhistory.bbclass2
-rw-r--r--meta/classes/package.bbclass4
-rw-r--r--meta/classes/populate_sdk_ext.bbclass4
-rw-r--r--meta/classes/reproducible_build.bbclass2
-rw-r--r--meta/classes/sstate.bbclass8
-rw-r--r--meta/classes/update-alternatives.bbclass4
-rw-r--r--meta/lib/oe/package_manager/deb/__init__.py6
-rw-r--r--meta/lib/oe/package_manager/ipk/__init__.py2
-rw-r--r--meta/lib/oe/rootfs.py6
-rw-r--r--meta/lib/oeqa/selftest/cases/wic.py6
-rwxr-xr-xscripts/combo-layer2
-rw-r--r--scripts/lib/devtool/standard.py8
-rw-r--r--scripts/lib/devtool/upgrade.py3
-rw-r--r--scripts/lib/wic/plugins/imager/direct.py2
14 files changed, 30 insertions, 29 deletions
diff --git a/meta/classes/buildhistory.bbclass b/meta/classes/buildhistory.bbclass
index 49af61c9c5..059de36a5d 100644
--- a/meta/classes/buildhistory.bbclass
+++ b/meta/classes/buildhistory.bbclass
@@ -875,7 +875,7 @@ python buildhistory_eventhandler() {
875 entries = [ x for x in os.listdir(rootdir) if not x.startswith('.') ] 875 entries = [ x for x in os.listdir(rootdir) if not x.startswith('.') ]
876 bb.utils.mkdirhier(olddir) 876 bb.utils.mkdirhier(olddir)
877 for entry in entries: 877 for entry in entries:
878 os.rename(os.path.join(rootdir, entry), 878 bb.utils.rename(os.path.join(rootdir, entry),
879 os.path.join(olddir, entry)) 879 os.path.join(olddir, entry))
880 elif isinstance(e, bb.event.BuildCompleted): 880 elif isinstance(e, bb.event.BuildCompleted):
881 if reset: 881 if reset:
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
index e3f0a7060b..cf30f33f3d 100644
--- a/meta/classes/package.bbclass
+++ b/meta/classes/package.bbclass
@@ -1049,7 +1049,7 @@ python fixup_perms () {
1049 # Create path to move directory to, move it, and then setup the symlink 1049 # Create path to move directory to, move it, and then setup the symlink
1050 bb.utils.mkdirhier(os.path.dirname(target)) 1050 bb.utils.mkdirhier(os.path.dirname(target))
1051 #bb.note("Fixup Perms: Rename %s -> %s" % (dir, ptarget)) 1051 #bb.note("Fixup Perms: Rename %s -> %s" % (dir, ptarget))
1052 os.rename(origin, target) 1052 bb.utils.rename(origin, target)
1053 #bb.note("Fixup Perms: Link %s -> %s" % (dir, link)) 1053 #bb.note("Fixup Perms: Link %s -> %s" % (dir, link))
1054 os.symlink(link, origin) 1054 os.symlink(link, origin)
1055 1055
@@ -1967,7 +1967,7 @@ python package_do_shlibs() {
1967 1967
1968 for (old, new) in renames: 1968 for (old, new) in renames:
1969 bb.note("Renaming %s to %s" % (old, new)) 1969 bb.note("Renaming %s to %s" % (old, new))
1970 os.rename(old, new) 1970 bb.utils.rename(old, new)
1971 pkgfiles[pkg].remove(old) 1971 pkgfiles[pkg].remove(old)
1972 1972
1973 shlibs_file = os.path.join(shlibswork_dir, pkg + ".list") 1973 shlibs_file = os.path.join(shlibswork_dir, pkg + ".list")
diff --git a/meta/classes/populate_sdk_ext.bbclass b/meta/classes/populate_sdk_ext.bbclass
index 84232ed9f5..fe840d9cfb 100644
--- a/meta/classes/populate_sdk_ext.bbclass
+++ b/meta/classes/populate_sdk_ext.bbclass
@@ -165,7 +165,7 @@ def create_filtered_tasklist(d, sdkbasepath, tasklistfile, conf_initpath):
165 shutil.rmtree(temp_sdkbasepath) 165 shutil.rmtree(temp_sdkbasepath)
166 except FileNotFoundError: 166 except FileNotFoundError:
167 pass 167 pass
168 os.rename(sdkbasepath, temp_sdkbasepath) 168 bb.utils.rename(sdkbasepath, temp_sdkbasepath)
169 cmdprefix = '. %s .; ' % conf_initpath 169 cmdprefix = '. %s .; ' % conf_initpath
170 logfile = d.getVar('WORKDIR') + '/tasklist_bb_log.txt' 170 logfile = d.getVar('WORKDIR') + '/tasklist_bb_log.txt'
171 try: 171 try:
@@ -175,7 +175,7 @@ def create_filtered_tasklist(d, sdkbasepath, tasklistfile, conf_initpath):
175 if 'attempted to execute unexpectedly and should have been setscened' in e.stdout: 175 if 'attempted to execute unexpectedly and should have been setscened' in e.stdout:
176 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' 176 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'
177 bb.fatal(msg) 177 bb.fatal(msg)
178 os.rename(temp_sdkbasepath, sdkbasepath) 178 bb.utils.rename(temp_sdkbasepath, sdkbasepath)
179 # Clean out residue of running bitbake, which check_sstate_task_list() 179 # Clean out residue of running bitbake, which check_sstate_task_list()
180 # will effectively do 180 # will effectively do
181 clean_esdk_builddir(d, sdkbasepath) 181 clean_esdk_builddir(d, sdkbasepath)
diff --git a/meta/classes/reproducible_build.bbclass b/meta/classes/reproducible_build.bbclass
index 9337d791e8..ea643f2860 100644
--- a/meta/classes/reproducible_build.bbclass
+++ b/meta/classes/reproducible_build.bbclass
@@ -66,7 +66,7 @@ python do_deploy_source_date_epoch_setscene () {
66 if os.path.exists(sde_file): 66 if os.path.exists(sde_file):
67 target = d.getVar('SDE_FILE') 67 target = d.getVar('SDE_FILE')
68 bb.debug(1, "Moving setscene SDE file %s -> %s" % (sde_file, target)) 68 bb.debug(1, "Moving setscene SDE file %s -> %s" % (sde_file, target))
69 os.rename(sde_file, target) 69 bb.utils.rename(sde_file, target)
70 else: 70 else:
71 bb.debug(1, "%s not found!" % sde_file) 71 bb.debug(1, "%s not found!" % sde_file)
72} 72}
diff --git a/meta/classes/sstate.bbclass b/meta/classes/sstate.bbclass
index 8e8efd18d5..b1c608dcb1 100644
--- a/meta/classes/sstate.bbclass
+++ b/meta/classes/sstate.bbclass
@@ -401,7 +401,7 @@ def sstate_installpkgdir(ss, d):
401 401
402 for state in ss['dirs']: 402 for state in ss['dirs']:
403 prepdir(state[1]) 403 prepdir(state[1])
404 os.rename(sstateinst + state[0], state[1]) 404 bb.utils.rename(sstateinst + state[0], state[1])
405 sstate_install(ss, d) 405 sstate_install(ss, d)
406 406
407 for plain in ss['plaindirs']: 407 for plain in ss['plaindirs']:
@@ -413,7 +413,7 @@ def sstate_installpkgdir(ss, d):
413 dest = plain 413 dest = plain
414 bb.utils.mkdirhier(src) 414 bb.utils.mkdirhier(src)
415 prepdir(dest) 415 prepdir(dest)
416 os.rename(src, dest) 416 bb.utils.rename(src, dest)
417 417
418 return True 418 return True
419 419
@@ -664,7 +664,7 @@ def sstate_package(ss, d):
664 continue 664 continue
665 bb.error("sstate found an absolute path symlink %s pointing at %s. Please replace this with a relative link." % (srcpath, link)) 665 bb.error("sstate found an absolute path symlink %s pointing at %s. Please replace this with a relative link." % (srcpath, link))
666 bb.debug(2, "Preparing tree %s for packaging at %s" % (state[1], sstatebuild + state[0])) 666 bb.debug(2, "Preparing tree %s for packaging at %s" % (state[1], sstatebuild + state[0]))
667 os.rename(state[1], sstatebuild + state[0]) 667 bb.utils.rename(state[1], sstatebuild + state[0])
668 668
669 workdir = d.getVar('WORKDIR') 669 workdir = d.getVar('WORKDIR')
670 sharedworkdir = os.path.join(d.getVar('TMPDIR'), "work-shared") 670 sharedworkdir = os.path.join(d.getVar('TMPDIR'), "work-shared")
@@ -674,7 +674,7 @@ def sstate_package(ss, d):
674 pdir = plain.replace(sharedworkdir, sstatebuild) 674 pdir = plain.replace(sharedworkdir, sstatebuild)
675 bb.utils.mkdirhier(plain) 675 bb.utils.mkdirhier(plain)
676 bb.utils.mkdirhier(pdir) 676 bb.utils.mkdirhier(pdir)
677 os.rename(plain, pdir) 677 bb.utils.rename(plain, pdir)
678 678
679 d.setVar('SSTATE_BUILDDIR', sstatebuild) 679 d.setVar('SSTATE_BUILDDIR', sstatebuild)
680 d.setVar('SSTATE_INSTDIR', sstatebuild) 680 d.setVar('SSTATE_INSTDIR', sstatebuild)
diff --git a/meta/classes/update-alternatives.bbclass b/meta/classes/update-alternatives.bbclass
index 8c2b66e7f1..000e4d5664 100644
--- a/meta/classes/update-alternatives.bbclass
+++ b/meta/classes/update-alternatives.bbclass
@@ -184,7 +184,7 @@ python apply_update_alternative_renames () {
184 link_rename.append((alt_target, alt_target_rename)) 184 link_rename.append((alt_target, alt_target_rename))
185 else: 185 else:
186 bb.note('%s: Rename %s -> %s' % (pn, alt_target, alt_target_rename)) 186 bb.note('%s: Rename %s -> %s' % (pn, alt_target, alt_target_rename))
187 os.rename(src, dest) 187 bb.utils.rename(src, dest)
188 update_files(alt_target, alt_target_rename, pkg, d) 188 update_files(alt_target, alt_target_rename, pkg, d)
189 else: 189 else:
190 bb.warn("%s: alternative target (%s or %s) does not exist, skipping..." % (pn, alt_target, alt_target_rename)) 190 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 () {
201 if os.path.lexists(link_target): 201 if os.path.lexists(link_target):
202 # Ok, the link_target exists, we can rename 202 # Ok, the link_target exists, we can rename
203 bb.note('%s: Rename (link) %s -> %s' % (pn, alt_target, alt_target_rename)) 203 bb.note('%s: Rename (link) %s -> %s' % (pn, alt_target, alt_target_rename))
204 os.rename(src, dest) 204 bb.utils.rename(src, dest)
205 else: 205 else:
206 # Try to resolve the broken link to link.${BPN} 206 # Try to resolve the broken link to link.${BPN}
207 link_maybe = '%s.%s' % (os.readlink(src), pn) 207 link_maybe = '%s.%s' % (os.readlink(src), pn)
diff --git a/meta/lib/oe/package_manager/deb/__init__.py b/meta/lib/oe/package_manager/deb/__init__.py
index 2ee68fefb1..a4b6b6f647 100644
--- a/meta/lib/oe/package_manager/deb/__init__.py
+++ b/meta/lib/oe/package_manager/deb/__init__.py
@@ -214,7 +214,7 @@ class DpkgPM(OpkgDpkgPM):
214 214
215 tmp_sf.write(status) 215 tmp_sf.write(status)
216 216
217 os.rename(status_file + ".tmp", status_file) 217 bb.utils.rename(status_file + ".tmp", status_file)
218 218
219 def run_pre_post_installs(self, package_name=None): 219 def run_pre_post_installs(self, package_name=None):
220 """ 220 """
@@ -299,13 +299,13 @@ class DpkgPM(OpkgDpkgPM):
299 for dir in dirs: 299 for dir in dirs:
300 new_dir = re.sub(r"\.dpkg-new", "", dir) 300 new_dir = re.sub(r"\.dpkg-new", "", dir)
301 if dir != new_dir: 301 if dir != new_dir:
302 os.rename(os.path.join(root, dir), 302 bb.utils.rename(os.path.join(root, dir),
303 os.path.join(root, new_dir)) 303 os.path.join(root, new_dir))
304 304
305 for file in files: 305 for file in files:
306 new_file = re.sub(r"\.dpkg-new", "", file) 306 new_file = re.sub(r"\.dpkg-new", "", file)
307 if file != new_file: 307 if file != new_file:
308 os.rename(os.path.join(root, file), 308 bb.utils.rename(os.path.join(root, file),
309 os.path.join(root, new_file)) 309 os.path.join(root, new_file))
310 310
311 311
diff --git a/meta/lib/oe/package_manager/ipk/__init__.py b/meta/lib/oe/package_manager/ipk/__init__.py
index da488c1c7f..4cd3963111 100644
--- a/meta/lib/oe/package_manager/ipk/__init__.py
+++ b/meta/lib/oe/package_manager/ipk/__init__.py
@@ -213,7 +213,7 @@ class OpkgPM(OpkgDpkgPM):
213 213
214 tmp_sf.write(status) 214 tmp_sf.write(status)
215 215
216 os.rename(status_file + ".tmp", status_file) 216 bb.utils.rename(status_file + ".tmp", status_file)
217 217
218 def _create_custom_config(self): 218 def _create_custom_config(self):
219 bb.note("Building from feeds activated!") 219 bb.note("Building from feeds activated!")
diff --git a/meta/lib/oe/rootfs.py b/meta/lib/oe/rootfs.py
index d634adda4e..4b48cdbb65 100644
--- a/meta/lib/oe/rootfs.py
+++ b/meta/lib/oe/rootfs.py
@@ -114,7 +114,7 @@ class Rootfs(object, metaclass=ABCMeta):
114 shutil.rmtree(self.image_rootfs + '-orig') 114 shutil.rmtree(self.image_rootfs + '-orig')
115 except: 115 except:
116 pass 116 pass
117 os.rename(self.image_rootfs, self.image_rootfs + '-orig') 117 bb.utils.rename(self.image_rootfs, self.image_rootfs + '-orig')
118 118
119 bb.note(" Creating debug rootfs...") 119 bb.note(" Creating debug rootfs...")
120 bb.utils.mkdirhier(self.image_rootfs) 120 bb.utils.mkdirhier(self.image_rootfs)
@@ -165,10 +165,10 @@ class Rootfs(object, metaclass=ABCMeta):
165 shutil.rmtree(self.image_rootfs + '-dbg') 165 shutil.rmtree(self.image_rootfs + '-dbg')
166 except: 166 except:
167 pass 167 pass
168 os.rename(self.image_rootfs, self.image_rootfs + '-dbg') 168 bb.utils.rename(self.image_rootfs, self.image_rootfs + '-dbg')
169 169
170 bb.note(" Restoreing original rootfs...") 170 bb.note(" Restoreing original rootfs...")
171 os.rename(self.image_rootfs + '-orig', self.image_rootfs) 171 bb.utils.rename(self.image_rootfs + '-orig', self.image_rootfs)
172 172
173 def _exec_shell_cmd(self, cmd): 173 def _exec_shell_cmd(self, cmd):
174 fakerootcmd = self.d.getVar('FAKEROOT') 174 fakerootcmd = self.d.getVar('FAKEROOT')
diff --git a/meta/lib/oeqa/selftest/cases/wic.py b/meta/lib/oeqa/selftest/cases/wic.py
index fa81584a8c..a11e2d0781 100644
--- a/meta/lib/oeqa/selftest/cases/wic.py
+++ b/meta/lib/oeqa/selftest/cases/wic.py
@@ -1306,8 +1306,8 @@ class Wic2(WicTestCase):
1306 result = runCmd("%s/usr/sbin/sfdisk -F %s" % (sysroot, new_image_path)) 1306 result = runCmd("%s/usr/sbin/sfdisk -F %s" % (sysroot, new_image_path))
1307 self.assertTrue("0 B, 0 bytes, 0 sectors" in result.output) 1307 self.assertTrue("0 B, 0 bytes, 0 sectors" in result.output)
1308 1308
1309 os.rename(image_path, image_path + '.bak') 1309 bb.utils.rename(image_path, image_path + '.bak')
1310 os.rename(new_image_path, image_path) 1310 bb.utils.rename(new_image_path, image_path)
1311 1311
1312 # Check if it boots in qemu 1312 # Check if it boots in qemu
1313 with runqemu('core-image-minimal', ssh=False) as qemu: 1313 with runqemu('core-image-minimal', ssh=False) as qemu:
@@ -1318,7 +1318,7 @@ class Wic2(WicTestCase):
1318 if os.path.exists(new_image_path): 1318 if os.path.exists(new_image_path):
1319 os.unlink(new_image_path) 1319 os.unlink(new_image_path)
1320 if os.path.exists(image_path + '.bak'): 1320 if os.path.exists(image_path + '.bak'):
1321 os.rename(image_path + '.bak', image_path) 1321 bb.utils.rename(image_path + '.bak', image_path)
1322 1322
1323 def test_wic_ls_ext(self): 1323 def test_wic_ls_ext(self):
1324 """Test listing content of the ext partition using 'wic ls'""" 1324 """Test listing content of the ext partition using 'wic ls'"""
diff --git a/scripts/combo-layer b/scripts/combo-layer
index a634dd69d2..045de65642 100755
--- a/scripts/combo-layer
+++ b/scripts/combo-layer
@@ -508,7 +508,7 @@ def check_patch(patchfile):
508 f.close() 508 f.close()
509 if of: 509 if of:
510 of.close() 510 of.close()
511 os.rename(patchfile + '.tmp', patchfile) 511 bb.utils.rename(patchfile + '.tmp', patchfile)
512 512
513def drop_to_shell(workdir=None): 513def drop_to_shell(workdir=None):
514 if not sys.stdin.isatty(): 514 if not sys.stdin.isatty():
diff --git a/scripts/lib/devtool/standard.py b/scripts/lib/devtool/standard.py
index f364a45283..5eba2191d9 100644
--- a/scripts/lib/devtool/standard.py
+++ b/scripts/lib/devtool/standard.py
@@ -746,7 +746,7 @@ def _check_preserve(config, recipename):
746 os.remove(removefile) 746 os.remove(removefile)
747 else: 747 else:
748 tf.write(line) 748 tf.write(line)
749 os.rename(newfile, origfile) 749 bb.utils.rename(newfile, origfile)
750 750
751def get_staging_kver(srcdir): 751def get_staging_kver(srcdir):
752 # Kernel version from work-shared 752 # Kernel version from work-shared
@@ -1094,10 +1094,10 @@ def rename(args, config, basepath, workspace):
1094 1094
1095 # Rename bbappend 1095 # Rename bbappend
1096 logger.info('Renaming %s to %s' % (append, newappend)) 1096 logger.info('Renaming %s to %s' % (append, newappend))
1097 os.rename(append, newappend) 1097 bb.utils.rename(append, newappend)
1098 # Rename recipe file 1098 # Rename recipe file
1099 logger.info('Renaming %s to %s' % (recipefile, newfile)) 1099 logger.info('Renaming %s to %s' % (recipefile, newfile))
1100 os.rename(recipefile, newfile) 1100 bb.utils.rename(recipefile, newfile)
1101 1101
1102 # Rename source tree if it's the default path 1102 # Rename source tree if it's the default path
1103 appendmd5 = None 1103 appendmd5 = None
@@ -1333,7 +1333,7 @@ def _export_patches(srctree, rd, start_rev, destdir, changed_revs=None):
1333 if match_name: 1333 if match_name:
1334 # Rename patch files 1334 # Rename patch files
1335 if new_patch != match_name: 1335 if new_patch != match_name:
1336 os.rename(os.path.join(destdir, new_patch), 1336 bb.utils.rename(os.path.join(destdir, new_patch),
1337 os.path.join(destdir, match_name)) 1337 os.path.join(destdir, match_name))
1338 # Need to pop it off the list now before checking changed_revs 1338 # Need to pop it off the list now before checking changed_revs
1339 oldpath = existing_patches.pop(old_patch) 1339 oldpath = existing_patches.pop(old_patch)
diff --git a/scripts/lib/devtool/upgrade.py b/scripts/lib/devtool/upgrade.py
index 5a057e95f5..24e3700ece 100644
--- a/scripts/lib/devtool/upgrade.py
+++ b/scripts/lib/devtool/upgrade.py
@@ -71,7 +71,8 @@ def _rename_recipe_dirs(oldpv, newpv, path):
71 if oldfile.find(oldpv) != -1: 71 if oldfile.find(oldpv) != -1:
72 newfile = oldfile.replace(oldpv, newpv) 72 newfile = oldfile.replace(oldpv, newpv)
73 if oldfile != newfile: 73 if oldfile != newfile:
74 os.rename(os.path.join(path, oldfile), os.path.join(path, newfile)) 74 bb.utils.rename(os.path.join(path, oldfile),
75 os.path.join(path, newfile))
75 76
76def _rename_recipe_file(oldrecipe, bpn, oldpv, newpv, path): 77def _rename_recipe_file(oldrecipe, bpn, oldpv, newpv, path):
77 oldrecipe = os.path.basename(oldrecipe) 78 oldrecipe = os.path.basename(oldrecipe)
diff --git a/scripts/lib/wic/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py
index ea709e8c54..96168aadb4 100644
--- a/scripts/lib/wic/plugins/imager/direct.py
+++ b/scripts/lib/wic/plugins/imager/direct.py
@@ -616,5 +616,5 @@ class PartitionedImage():
616 part.start + part.size_sec - 1, part.size_sec) 616 part.start + part.size_sec - 1, part.size_sec)
617 617
618 partimage = self.path + '.p%d' % part.num 618 partimage = self.path + '.p%d' % part.num
619 os.rename(source, partimage) 619 bb.utils.rename(source, partimage)
620 self.partimages.append(partimage) 620 self.partimages.append(partimage)