[PATCH] rpmostreepayload: Avoid shutil.copytree in favor of cp -r to fix symlinks

David Cantrell dcantrell at redhat.com
Wed Dec 3 14:27:52 UTC 2014


On Wed, Dec 03, 2014 at 09:18:15AM -0500, Colin Walters wrote:
> On Wed, Dec 3, 2014, at 08:57 AM, David Cantrell wrote:
> > 
> > shutil.copytree(srcpath, destpath, symlinks=True)
> 
> I mentioned this in the commit message:
> 
> "Since we're shelling out to 'cp' in a case above, might as well do it here."
> 
> The reason for using 'cp' is coreutils has a desired behavior for EFI
> where if the target directory already exists (as a mount point in that
> case), that's not an error.

That is one annoying limitation of the shutil module, especially if the
destination is a mount point.

> Also another rationale from the commit message:
> 
> "This also means that if we hit e.g. ENOSPC we'll enter the error
> handling codepath instead of an uncaught traceback."

You could use copy_tree in distutils which is more like cp(1):

    distutils.dir_util.copy_tree(srcpath, destpath, preserve_symlinks=True)

https://docs.python.org/2/distutils/apiref.html

I have used this once outside of a setup.py and it works fine.  This is
really more of a FWIW rather than insistence on not just running cp.  I'm ok
with that, I just tend to think it's unnecessary.

-- 
David Cantrell <dcantrell at redhat.com>
Manager, Installer Engineering Team
Red Hat, Inc. | Westford, MA | EST5EDT


More information about the anaconda-patches mailing list