Consume the build output of part 1 in part 2

I have been trying to build a snap, using snapcraft on Ubuntu 16.04 GNOME.

My source, is from a branch on a github repository. Hence, I thus far have managed

    plugin: nil
    source-type: git
    source-branch: locallts
    build-packages: [git,libsecret-1-0,libsecret-common,libsecret-1-dev,fakeroot, libx11-dev, libxkbfile-dev,gcc-5,g++-5]
    prepare: |

within prepare , and in , I am installing all the npm packages my build would need.

This build process, would create a .deb archive, inside

parts |
                | repo.deb

How do I now, add another part to my snapcraft.yaml part structure,

that can have the source pointing to the output of snappy-repo?

For snaps that use npm you may want to use the nodejs plugin

You need have the contents you want to consume staged but not necessarily primed if they are only useful for the building of the dependent part, to be either staged or primed they need to end up in the part’s install directory, given there is no similar make install rule run here (plugin: nil) you will need to do a few extra manual steps, here is an illustrative example

        plugin: nil
        build-packages: [...]
        prepare: |
            install debian/repo.deb $SNAPCRAFT_PART_INSTALL/repo.deb
            - -repo.deb
        prepare: |
            dpkg-deb -x $SNAPCRAFT_STAGE/repo.deb
        after: [snappy-repo]


  • install under snappy-repo just makes sure that repo.deb ends up in the top level stage dir in the project
  • repo-user is configured to run after snappy-repo
  • the prepare entry in repo-user unpacks repo.deb from the stage director
  • the prime entry in snappy-repo makes sure the deb does not make it to the snap (in case that is your intention) as it avoids priming it.

This just works excellently! thanks @sergiusens!

Yeah I do not want the debian package to go into the snap.

I with the above , have managed to

  • pull the latest changes from a git repository,
  • build a debian package with node
  • unpack the debain archive from part 1 in part2

just what I needed.

Now I gotta read about what to do with the dumped unpacked .deb package

1 Like