go plugin ignores the source-subdir keyword

Bug #1613779 reported by Jon Grimm
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Snapcraft
Confirmed
Undecided
Unassigned

Bug Description

When using 'source', the go plugin assumes source is in the git root dir.

Sample snapcraft.yaml of project that shows this below.

The go plugin attempts to symlink in the source from the local cloned repo, but makes an assumption that the root of the git repo holds the source. In the below case the real source to build is at 'src/cmd/frps' within the git repo.

Here's the symlink created:

jgrimm@jgrimm-ThinkPad-X250:~/snapit/frps/parts/frps/go/src/github.com/fatedier/frp/src/cmd$ ll
total 12
drwxr-xr-x 2 jgrimm lxd 4096 Aug 16 10:24 ./
drwxr-xr-x 3 jgrimm lxd 4096 Aug 16 10:24 ../
lrwxrwxrwx 1 jgrimm lxd 39 Aug 16 10:24 frps -> /home/jgrimm/snapit/frps/parts/frps/src/

Instead that frps link should be to /home/jgrimm/snapit/frps/parts/frps/src/src/cmd/frps/

--- snapcraft.yaml ---
name: frps
version: "0.8"
summary: frps - short text
description: |
  FIXME:
confinement: devmode

apps:
  frps:
    command: bin/frps
    plugs: [network, network-bind]

parts:
  frps:
    plugin: go
    source: https://github.com/fatedier/frp.git
    go-importpath: github.com/fatedier/frp/src/cmd/frps
    build-packages: [git]
---

Tags: plugin sources
Revision history for this message
Sergio Schvezov (sergiusens) wrote :

This is why we have a `source-subdir` keyword. Does this solve the problem?

Changed in snapcraft:
status: New → Incomplete
Revision history for this message
Jon Grimm (jgrimm) wrote :

Ah, hadn't noticed that keyword... but reading the help text doesn't seem like it would help much at least as defined:

- source-subdir: path

    Snapcraft will checkout the repository or unpack the archive referred to
    by the 'source' keyword into parts/<part-name>/src/ but it will only
    copy the specified subdirectory into parts/<part-name>/build/

But I went ahead and tried it, and indeed does not help any. FWIW, also took a quick peek at the go plugin, but it doesn't seem to do anything at all when this option is set.

Changed in snapcraft:
status: Incomplete → New
Revision history for this message
Leo Arias (elopio) wrote :

I think that the problem in your case is this:

can't load package: package github.com/fatedier/frp/test: found packages main (echo_server.go) and test (func_test.go) in /tmp/test/parts/frps/go/src/github.com/fatedier/frp/test

You shouldn't have two packages in the same directory. If

Now, it seems indeed that snapcraft is ignoring the source-subdir in the go plugin, and that would be a possible workaround for this case.

Thanks for your report!

summary: - go plugin: assumes source in root dir
+ go plugin ignores the source-subdir keyword
Changed in snapcraft:
status: New → Confirmed
tags: added: plugin sources
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.