How to copy just one file using the dump plugin?

Previously I did this using the copy plugin, but that is deprecated:

  copy:
    plugin: copy
    files:
      data-dir-wrapper: bin/data-dir-wrapper

I tried to do the same thing with the dump plugin:

  wrapper:
    plugin: dump
    source: .
    organize:
      data-dir-wrapper: bin/data-dir-wrapper

However this results in every file from source being copied into the snap, which is not what I want.

The documentation for dump says:

In the cases where dumping the content needs some mangling or organizing one would take advantage of the core functionalities available to plugins such as: filesets, stage, snap and organize.

I tried adding a stage: section:

  wrapper:
    plugin: dump
    source: .
    stage:
      - data-dir-wrapper
    organize:
      data-dir-wrapper: bin/data-dir-wrapper

But then snapcraft says:

[Errno 2] No such file or directory: ‘/home/al/Source/sigrok-snap-test/parts/wrapper/install/data-dir-wrapper’

1 Like

Hello!

Your stage runs after organize, so it should be:

stage:
  - bin/data-dir-wrapper

This was reported in this bug #1638622

1 Like

Got it. It also needs to be prime: not stage: otherwise it doesn’t end up in the snap.

If you have stage without prime, it should be the same as if you have stage and prime with the same values.

Maybe there’s a bug in there…

My bad it does actually work with stage:

:relieved: phew Thanks for checking that.

@elopio on a similar kind of issue, I am trying to stage an output of build

where actually should I use filesets?

plugin: nodejs
    node-engine: 6.11.2
    source: ./src/
    build-packages:[...]      
    build: |
        sh run.sh
   filesets: 
	   app: [archive/*]
    stage:
        - $app

when build runs, it creates a directory build/archive

but the above yaml , does not put archive/* into stage

1 Like