Using organize to move a folder to a child folder fails due to recursion

Bug #1668555 reported by James Henstridge
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Snapcraft
New
Undecided
Unassigned

Bug Description

I created a part in my snapcraft.yaml file with the following directive:

    plugin: dump
    source: src
    organize:
      .: lib/python3.6/site-packages

The intention being to move all the source files to a subdirectory. However, in the process of reorganising the installed files, it was also trying to move lib/python3.6/site-packages under lib/python3.6/site-packages, and doing so recursively until it errors out when the file name gets too long.

I could avoid the problem by changing the directive to the following, which I guess avoided the problem because the glob was expanded before trying to reorganise the tree.

    organize:
      '*': lib/python3.6/site-packages/

Revision history for this message
Jon Edvardsson (jonedv) wrote :

I've just hit this bug when snapping a project. Part1 works fine, but part2 fails with RecursionError.

    parts:
      part1:
        plugin: dump
        source: src
        organize:
          lib: lib2

      part2:
        plugin: dump
        source: src
        organize:
          lib: lib/lib

When investigating this I came a cross another odd behavior: the organize section seems to be applied in the stage step and not in the install step.

    $ snapcraft clean && snapcraft build part1
    Cleaning up priming area
    Cleaning up staging area
    Cleaning up parts directory
    Preparing to pull part1
    Pulling part1
    Preparing to build part1
    Building part1
    $ find parts stage -type f
    parts/part1/src/lib/hello.txt
    parts/part1/state/pull
    parts/part1/state/build
    parts/part1/build/lib/hello.txt
    parts/part1/install/lib/hello.txt

Note the directory install/lib. I would expect it to be install/lib2 after build.

    $ snapcraft clean && snapcraft stage part1
    Cleaning up priming area
    Cleaning up staging area
    Cleaning up parts directory
    Preparing to pull part1
    Pulling part1
    Preparing to build part1
    Building part1
    Staging part1
    $ find parts stage -type f
    parts/part1/src/lib/hello.txt
    parts/part1/state/pull
    parts/part1/state/build
    parts/part1/state/stage
    parts/part1/build/lib/hello.txt
    parts/part1/install/lib2/hello.txt
    stage/lib2/hello.txt

Now, after staging the install dir has been renamed to install/lib2. This can't be right that stage modifies what is produced when building parts. However, the effect is that stage/lib2 comes out ok.

When staging part2 snapcraft fails with a RecursionError.

    $ snapcraft clean && snapcraft stage part2
    Cleaning up priming area
    Cleaning up staging area
    Cleaning up parts directory
    Preparing to pull part2
    Pulling part2
    Preparing to build part2
    Building part2
    Staging part2
    Traceback (most recent call last):
      File "/usr/bin/snapcraft", line 9, in <module>
        load_entry_point('snapcraft==2.34', 'console_scripts', 'snapcraft')()
      File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 542, in load_entry_point
        return get_distribution(dist).load_entry_point(group, name)
      File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2569, in load_entry_point
        return ep.load()
      File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2229, in load
        return self.resolve()
      File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2235, in resolve
    ... trace removed ...
      File "/usr/lib/python3.5/os.py", line 416, in walk
        new_path = join(top, dirname)
      File "/usr/lib/python3.5/posixpath.py", line 76, in join
        sep = _get_sep(a)
    RecursionError: maximum recursion depth exceeded

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.