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

Subscribers

People subscribed via source and target branches

to all changes: