Provide visible yaml settings or document organize plugin behavior for directory merging
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Snapcraft |
New
|
Undecided
|
Unassigned |
Bug Description
Hi,
I was working on a change for snap-libvirt and encountered a behavior which is not apparent on the first sight.
https:/
Originally '*' has been used in the organize plugin which lead to an error due to the fact that the directory structure used by both parts (libvirt and qemu) is similar:
"path ./ already exists"
This error is cryptic unless you look at the source code of snapcraft:
def _organize:
https:/
calls def _organize_
https:/
Now this function has 3 code paths:
def _organize_
for key in sorted(fileset, key=lambda x: ['*' in x, x]):
src = os.path.
dst = os.path.
sources = iglob(src, recursive=True)
for src in sources:
if os.path.isdir(src) and '*' not in key: # <---- first
# TODO create alternate organization location to avoid
# deletions.
elif os.path.
else: # <----- third
The third code path is what gets picked in case there is a '*' in the key and the destination in not a file.
shutil.move is the call that gave 'path ./ already exists' error which I learned by grepping cpython source code:
def move function
https:/
Now, looking at an alternative code path (the first one) which calls link_or_copy_tree I see:
def link_or_
"""Copy a source tree into a destination, hard-linking if possile.
:param str source_tree: Source directory to be copied.
:param str destination_tree: Destination directory. If this directory
The destination_tree argument gives a very good description in terms of what is going to happen but it is "hidden" in the source code which forces a regular snapcrafter to do some grepping.
Avoiding '*' helped me to select the right code path but it would be nice to have more visibility for that (either in a form of a knob in snapcraft.yaml or in the docs).
Thanks!
description: | updated |