Can you document the cases that os.rename() is failing ? And also why
would we expect the shutil.move() to work in those cases ?

If a change like this cases issues in the future, we need that extra
information in the commit head for proper triage.

Bruce

On Mon, Mar 29, 2021 at 11:16 AM Devendra Tewari
<[email protected]> wrote:
>
> ---
>  meta/classes/sstate.bbclass | 26 ++++++++++++++++++++++----
>  1 file changed, 22 insertions(+), 4 deletions(-)
>
> diff --git a/meta/classes/sstate.bbclass b/meta/classes/sstate.bbclass
> index f579168162..f94aa96d70 100644
> --- a/meta/classes/sstate.bbclass
> +++ b/meta/classes/sstate.bbclass
> @@ -384,6 +384,7 @@ def sstate_installpkg(ss, d):
>  def sstate_installpkgdir(ss, d):
>      import oe.path
>      import subprocess
> +    import shutil
>
>      sstateinst = d.getVar("SSTATE_INSTDIR")
>      d.setVar('SSTATE_FIXMEDIR', ss['fixmedir'])
> @@ -401,7 +402,11 @@ def sstate_installpkgdir(ss, d):
>
>      for state in ss['dirs']:
>          prepdir(state[1])
> -        os.rename(sstateinst + state[0], state[1])
> +        try:
> +            os.rename(sstateinst + state[0], state[1])
> +            break
> +        except OSError:
> +            shutil.move(sstateinst + state[0], state[1])
>      sstate_install(ss, d)
>
>      for plain in ss['plaindirs']:
> @@ -413,7 +418,11 @@ def sstate_installpkgdir(ss, d):
>          dest = plain
>          bb.utils.mkdirhier(src)
>          prepdir(dest)
> -        os.rename(src, dest)
> +        try:
> +            os.rename(src, dest)
> +            break
> +        except OSError:
> +            shutil.move(src, dest)
>
>      return True
>
> @@ -638,6 +647,7 @@ python sstate_hardcode_path () {
>
>  def sstate_package(ss, d):
>      import oe.path
> +    import shutil
>
>      tmpdir = d.getVar('TMPDIR')
>
> @@ -664,7 +674,11 @@ 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])
> +        try:
> +            os.rename(state[1], sstatebuild + state[0])
> +            break
> +        except OSError:
> +            shutil.move(state[1], sstatebuild + state[0])
>
>      workdir = d.getVar('WORKDIR')
>      sharedworkdir = os.path.join(d.getVar('TMPDIR'), "work-shared")
> @@ -674,7 +688,11 @@ def sstate_package(ss, d):
>              pdir = plain.replace(sharedworkdir, sstatebuild)
>          bb.utils.mkdirhier(plain)
>          bb.utils.mkdirhier(pdir)
> -        os.rename(plain, pdir)
> +        try:
> +            os.rename(plain, pdir)
> +            break
> +        except OSError:
> +            shutil.move(plain, pdir)
>
>      d.setVar('SSTATE_BUILDDIR', sstatebuild)
>      d.setVar('SSTATE_INSTDIR', sstatebuild)
> --
> 2.29.2
>
>
> 
>


-- 
- Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end
- "Use the force Harry" - Gandalf, Star Trek II
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#150050): 
https://lists.openembedded.org/g/openembedded-core/message/150050
Mute This Topic: https://lists.openembedded.org/mt/81698791/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to