[yocto] Badly formatted subpath for git SRC_URI deletes portions of hard drive.

Paul Eggleton paul.eggleton at linux.intel.com
Thu Apr 16 08:58:10 PDT 2015


On Thursday 16 April 2015 15:11:44 Anders Darander wrote:
> * Paul Eggleton <paul.eggleton at linux.intel.com> [150416 14:57]:
> > Hi John,
> > 
> > On Thursday 16 April 2015 11:52:48 John Ernberg wrote:
> > > After restoring everything I re-created the recipe, this time I also
> > > saved a copy of the recipe at a safe location.
> > > At the end of the path given to subpath I had added a '/' as it was not
> > > specified what the format of the path should be. I figured I would see
> > > an error if the path was wrong, and technically I did.
> > > Essentially the SRC_URI looked like this:
> > > SRC_URI = "git://git@<server+repo>;protocol=ssh;subpath=path/"
> > > 
> > > Running the recipe resulted in do_fetch (or do_unpack) failing again and
> > > complaining about missing files. This time the deletion was on a much
> > > greater scale, it had deleted so much of my home-dir that my user
> > > account was rendered entirely useless. The fastest way to recover this
> > > time was re-installing the machine.
> 
> It's most likely a call to bb.utils.prunedir(destdir), with destdir
> being set to '/'...
> 
> > Very sorry about this :(
> 
> Yeah, too bad...
> 
> > Looking at the code I can see at least two problems we need to fix
> > relating to this issue. It seems that having '/' either at the start or
> > the end of the value was unexpected and would trigger undesirable
> > behaviour.
> 
> The issue with having '/' at the end ought to be solved by adding
> .rstrip('/') like:
> ----------------------------
> diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py
> index 44fc271..0fd9bee 100644
> --- a/bitbake/lib/bb/fetch2/git.py
> +++ b/bitbake/lib/bb/fetch2/git.py
> @@ -246,7 +246,7 @@ class Git(FetchMethod):
>          subdir = ud.parm.get("subpath", "")
>          if subdir != "":
>              readpathspec = ":%s" % (subdir)
> -            def_destsuffix = "%s/" % os.path.basename(subdir)
> +            def_destsuffix = "%s/" %
> os.path.basename(subdir.rstrip('/'))
>          else:
>              readpathspec = ""
>              def_destsuffix = "git/"
> ---------------------------
> 
> Probably, the first issue could be solved by replacing subdir with
> subdir.strip('/') on the line above that.
> 
> Though I might be missing something...
> 
> I've only looked for a moment on the patch above, which at least seems
> to create correct path's when inspecting the output.

That looks like a reasonable solution to me, thanks.

FYI I've created the following bug to track this issue:

  https://bugzilla.yoctoproject.org/show_bug.cgi?id=7620

I'll send a fix ASAP probably based on the above.

Cheers,
Paul


-- 

Paul Eggleton
Intel Open Source Technology Centre



More information about the yocto mailing list