Merge ~morphis/snappy-hwe-snaps/+git/wifi-ap:no-external-go-deps into ~snappy-hwe-team/snappy-hwe-snaps/+git/wifi-ap:master

Proposed by Simon Fels
Status: Merged
Approved by: Simon Fels
Approved revision: 4c17db7dc0251813de463c913e608d87269d729a
Merged at revision: ecdfb3741b0a2a849ca0b689cf3c946e31fd9b31
Proposed branch: ~morphis/snappy-hwe-snaps/+git/wifi-ap:no-external-go-deps
Merge into: ~snappy-hwe-team/snappy-hwe-snaps/+git/wifi-ap:master
Diff against target: 73 lines (+50/-0)
2 files modified
parts/plugins/x-go.py (+44/-0)
snapcraft.yaml (+6/-0)
Reviewer Review Type Date Requested Status
Konrad Zapałowicz (community) Approve
Alfonso Sanchez-Beato Approve
System Enablement Bot continuous-integration Approve
Review via email: mp+306448@code.launchpad.net

Description of the change

Access go dependencies via existing debian packages

As our CI is building in an environment where access to external
services like github is not allowed we have to build with what we
get through the Ubuntu package archive. The packages we're using
here are used by the snapd debian package too so we're not basing
off something which isn't maintained.

This change will be also proposed upstream to have this available
as a general feature in snapcraft.

To post a comment you must log in.
Revision history for this message
Jim Hodapp (jhodapp) wrote :

I'm curious for some more context. What exactly was being done to get the Go dependencies before this patch? I don't fully understand why this is required and why this is a big improvement.

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :

PASSED: Continuous integration, rev:578acb5af0c89ca751f29a580dec536c928a10be
https://jenkins.canonical.com/system-enablement/job/generic-build-snap/90/
Executed test runs:

Click here to trigger a rebuild:
https://jenkins.canonical.com/system-enablement/job/generic-build-snap/90/rebuild

review: Approve (continuous-integration)
Revision history for this message
Simon Fels (morphis) wrote :

@Jim: With Go you normally fetch all dependencies in source code form from a git repository like on github.com. This is not possible in our CI builds or even .deb builds on launchpad. Therefor Ubuntu provides necessary Go dependencies packaged in the archive which install all source code to /usr/share/gocode which then can be use as part of your GOPATH environment and avoids fetching the source code from a remote git repository.

Revision history for this message
System Enablement Bot (system-enablement-ci-bot) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote :

LGTM

review: Approve
Revision history for this message
Konrad Zapałowicz (kzapalowicz) wrote :

Cool

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/parts/plugins/x-go.py b/parts/plugins/x-go.py
0new file mode 1006440new file mode 100644
index 0000000..2211de7
--- /dev/null
+++ b/parts/plugins/x-go.py
@@ -0,0 +1,44 @@
1# -*- Mode:Python; indent-tabs-mode:nil; tab-width:4 -*-
2#
3# Copyright (C) 2015, 2016 Canonical Ltd
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License version 3 as
7# published by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17import os
18
19import snapcraft
20import snapcraft.plugins.go
21
22DEBIAN_GOCODE_SRC_PATH = "/usr/share/gocode/src"
23
24class GoPlugin(snapcraft.plugins.go.GoPlugin):
25 def pull(self):
26 # Skip the pull step from GoPlugin here as it would repeat 90% of what
27 # we're doing here and will only conflict.
28 snapcraft.BasePlugin.pull(self)
29 os.makedirs(self._gopath_src, exist_ok=True)
30
31 if self.options.source:
32 go_package = self._get_local_go_package()
33 go_package_path = os.path.join(self._gopath_src, go_package)
34 if os.path.islink(go_package_path):
35 os.unlink(go_package_path)
36 os.makedirs(os.path.dirname(go_package_path), exist_ok=True)
37 os.symlink(self.sourcedir, go_package_path)
38 # We can't just add the gocode directory to GOPATH as go
39 # doesn't like this. Instead we're symlinking the necessary
40 # subdirectories from the gocode directory into our already
41 # existing GOPATH.
42 for dir in os.listdir(DEBIAN_GOCODE_SRC_PATH):
43 os.symlink(os.path.join(DEBIAN_GOCODE_SRC_PATH, dir),
44 os.path.join(self._gopath_src, dir))
diff --git a/snapcraft.yaml b/snapcraft.yaml
index 479b348..955fdfb 100644
--- a/snapcraft.yaml
+++ b/snapcraft.yaml
@@ -62,12 +62,18 @@ parts:
62 source: cmd/client62 source: cmd/client
63 snap:63 snap:
64 - bin64 - bin
65 build-packages:
66 - golang-go-flags-dev
67 - golang-github-gorilla-mux-dev
6568
66 management-service:69 management-service:
67 plugin: go70 plugin: go
68 source: cmd/service71 source: cmd/service
69 snap:72 snap:
70 - bin73 - bin
74 build-packages:
75 - golang-go-flags-dev
76 - golang-github-gorilla-mux-dev
7177
72 dnsmasq:78 dnsmasq:
73 plugin: make79 plugin: make

Subscribers

People subscribed via source and target branches

to all changes: