All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Denys Dmytriyenko" <denis@denix.org>
To: Devendra Tewari <devendra.tewari@gmail.com>
Cc: Konrad Weihmann <kweihmann@outlook.com>,
	openembedded-core@lists.openembedded.org
Subject: Re: [OE-core] [PATCH] Use shutil.move when os.rename fails
Date: Tue, 30 Mar 2021 17:59:41 -0400	[thread overview]
Message-ID: <20210330215941.GD23013@denix.org> (raw)
In-Reply-To: <70419FA6-9CA2-4B42-B4A2-6CC264DE163E@gmail.com>

The link is for a 10-year old bug, probably not what you wanted.
Also, if a patch fixes existing bug in bugzilla, it needs to reference it in 
commit message as well - [YOCTO#1234567]


On Mon, Mar 29, 2021 at 12:37:45PM -0300, Devendra Tewari wrote:
> Also, this is due to https://bugzilla.yoctoproject.org/show_bug.cgi?id=1430.
> 
> > On 29 Mar 2021, at 12:35, Devendra Tewari <devendra.tewari@gmail.com> wrote:
> > 
> > Sure.
> > 
> > Would the following commit message be sufficient?
> > 
> >    Use shutil.move when os.rename fails
> > 
> >    Incremental build in Docker fails with
> > 
> >    OSError: [Errno 18] Invalid cross-device link
> > 
> >    When source and destination are on different overlay filesystems.
> > 
> >    This change handles the error with os.rename and retries with shutil.move.
> > 
> > Thanks,
> > Devendra
> > 
> >> On 29 Mar 2021, at 12:23, Konrad Weihmann <kweihmann@outlook.com> wrote:
> >> 
> >> Yes please quote a bit from the python manpage [1] - I certainly see the difference (and the edge cases where os.rename might fail), but that should be documented as part of the commit message
> >> 
> >> [1] https://docs.python.org/3/library/shutil.html#shutil.move
> >> 
> >> On 29.03.21 17:21, Bruce Ashfield wrote:
> >>> 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
> >>> <devendra.tewari@gmail.com> 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
> >>>> 
> >>>> 
> >>>> 
> >>>> 
> >>> 
> > 
> 

  reply	other threads:[~2021-03-30 21:59 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-29 15:14 [PATCH] Use shutil.move when os.rename fails devendra.tewari
2021-03-29 15:21 ` [OE-core] " Bruce Ashfield
2021-03-29 15:23   ` Konrad Weihmann
2021-03-29 15:35     ` Devendra Tewari
2021-03-29 15:37       ` Devendra Tewari
2021-03-30 21:59         ` Denys Dmytriyenko [this message]
2021-03-30 22:38           ` Devendra Tewari
2021-04-01 19:14             ` Devendra Tewari
2021-03-29 20:38 ` Richard Purdie
2021-03-29 22:45   ` Devendra Tewari
2021-03-29 23:00     ` Andre McCurdy
2021-03-29 23:07       ` Devendra Tewari
2021-03-29 23:10         ` Andre McCurdy
2021-03-29 23:13           ` Devendra Tewari
2021-03-30 10:16             ` Devendra Tewari
2021-03-30 11:10       ` Richard Purdie
2021-03-30 11:55         ` Devendra Tewari
2021-04-19 18:43           ` Devendra Tewari
2021-04-21  5:21             ` Khem Raj
2021-04-21 14:43               ` Devendra Tewari
2021-04-21 15:15                 ` Khem Raj
2021-04-21 18:10                 ` Richard Purdie
2021-04-21 19:15                   ` Devendra Tewari
2021-04-21 19:21                     ` Richard Purdie
2021-04-21 21:08                       ` Devendra Tewari
2021-04-27 11:57                         ` Devendra Tewari
2021-04-27 14:59                           ` Devendra Tewari
2021-04-27 22:39                             ` Richard Purdie
2021-04-27 22:44                               ` Devendra Tewari
2021-04-27 22:53                                 ` Devendra Tewari
2021-04-28 10:00                                   ` Devendra Tewari
2021-04-28 21:42                                     ` Richard Purdie
2021-04-28 23:02                                       ` Devendra Tewari
     [not found]                                       ` <90B42906-44DE-4D61-8210-669DC25BBD3F@gmail.com>
2022-08-22 12:25                                         ` Devendra Tewari

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210330215941.GD23013@denix.org \
    --to=denis@denix.org \
    --cc=devendra.tewari@gmail.com \
    --cc=kweihmann@outlook.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.