1

I'm pulling a project off github that has multiple src folders for different instances (for different target architectures) in subfolders. It builds with make when run in the instance subfolder you want.

How do I get snapcraft to run make in the correct directory (I can't only pull down that directory as there are common src files at the top level too)

Current yaml:

parts:
    base:
        plugin: make
            source: git://github.com/myproject.git
3

Good question.

While you won't be able to do architecture detection within the YAML, you can tell the plugins to use a subdirectory of the source rather than the root. So as long as you're okay changing that subdirectory by hand depending on the architecture for which you're building, you're good.

Let's assume the layout of the project you're cloning looks like this:

/:
    subdir1:
        Makefile
    subdir2:
        Makefile

Let's also assume that you're only interested in building subdir1. Here's a snippet from snapcraft help sources:

  • source-subdir:

    (string)

    A source directory within a repository or tarfile to enter and build from.

So you can Snapcraft what you want with YAML like this:

parts:
    base:
        plugin: make
        source: git://github.com/myproject.git
        source-type: git
        source-subdir: subdir1

That will cause make/make install to be run from subdir1. Note that this applies to any plugin that supports the source options.

EDIT:

Indeed, as sergiusens points out in the comments, snapcraft help make is useful to read, and points out another potential answer here:

parts:
    base:
        plugin: make
        source: git://github.com/myproject.git
        source-type: git
        makefile: subdir1/Makefile

That causes make/make install to be called with -f subdir1/Makefile

| improve this answer | |
  • How about also mentioning the -f syntax and snapcraft help make? – sergiusens Feb 5 '16 at 19:06
  • Thanks! Now make runs but it appears that both options still run it from an external directory - I get errors like Makefile:2: ../py/mkenvironment.mk: No such file or directory – r4space Feb 12 '16 at 23:45
  • @r4space you probably hit bug #1549676, which has been fixed in 1.1.0 and will be released soon for 2.x – Kyle Mar 1 '16 at 12:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.