Merge lp:~mvo/snapweb/new-snappy into lp:~snappy-dev/snapweb/trunk

Proposed by Michael Vogt
Status: Approved
Approved by: Sergio Schvezov
Approved revision: 172
Proposed branch: lp:~mvo/snapweb/new-snappy
Merge into: lp:~snappy-dev/snapweb/trunk
Diff against target: 501 lines (+103/-128)
13 files modified
README.md (+20/-5)
avahi/avahi.go (+14/-10)
build.sh (+35/-9)
dependencies.tsv (+4/-2)
oem/oem.go (+5/-4)
pkg/meta/hooks/config (+0/-70)
pkg/meta/package.yaml (+2/-2)
pkg/snappyd (+6/-1)
snappy/common_test.go (+1/-1)
snappy/converge.go (+13/-21)
snappy/converge_test.go (+1/-1)
snappy/handlers.go (+1/-1)
webprogress/meter.go (+1/-1)
To merge this branch: bzr merge lp:~mvo/snapweb/new-snappy
Reviewer Review Type Date Requested Status
Michael Vogt (community) Needs Fixing
Sergio Schvezov Approve
Review via email: mp+277433@code.launchpad.net

Description of the change

Update webdm for new github snappy location and document some missing bits.

This also merges some bits from chipaca.

To post a comment you must log in.
lp:~mvo/snapweb/new-snappy updated
169. By Michael Vogt

README.md: add missing gcc-aarch64-linux-gnu

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

mind merging all of Chipaca's changes?

lp:~mvo/snapweb/new-snappy updated
170. By Michael Vogt

README.md: add missing ubuntu-snappy-cli dependency

171. By Michael Vogt

pkg/meta/package.yaml: use a string for the version

172. By Michael Vogt

merged lp:~chipaca/webdm/mdns-nicer-with-ipv6

Revision history for this message
Michael Vogt (mvo) wrote :

All of those should be merged now.

Revision history for this message
Sergio Schvezov (sergiusens) :
review: Approve
Revision history for this message
Michael Vogt (mvo) wrote :

Well, this is a mess. When I build this package I can not remove any snap from webdm. I get "Error: snappy package not found".

review: Needs Fixing
lp:~mvo/snapweb/new-snappy updated
173. By Michael Vogt

bump version

174. By Michael Vogt

dependencies.tsv: use the latest 15.04 revno for the webdm build

175. By Michael Vogt

improve README.md, 15.10 is the only rev that can build webdm at this point

Revision history for this message
Michael Vogt (mvo) wrote :

Removing works now, I was a bad build (or rather a outdated dependencies.tsv). This works on 15.04 now.

However this will only work with 15.04 because its build with the 15.04 version of snappy and it will try to run sc-seccomp which is no longer available on 16.04. When build against the 16.04 snappy it will break on 15.04 because it expect the apparmor files in a different location.

So to summarize. We need a new webdm that works against the REST API or we need a webdm15.04 and a webdm16.04 in the store.

Revision history for this message
Michael Vogt (mvo) wrote :

Ups, "it was a bad build" of course.

Unmerged revisions

175. By Michael Vogt

improve README.md, 15.10 is the only rev that can build webdm at this point

174. By Michael Vogt

dependencies.tsv: use the latest 15.04 revno for the webdm build

173. By Michael Vogt

bump version

172. By Michael Vogt

merged lp:~chipaca/webdm/mdns-nicer-with-ipv6

171. By Michael Vogt

pkg/meta/package.yaml: use a string for the version

170. By Michael Vogt

README.md: add missing ubuntu-snappy-cli dependency

169. By Michael Vogt

README.md: add missing gcc-aarch64-linux-gnu

168. By Michael Vogt

we also need linux-libc-dev:i386

167. By Michael Vogt

its github.com now

166. By Michael Vogt

libc6-dev-i386 is also needed to build

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'README.md'
2--- README.md 2015-05-07 08:25:48 +0000
3+++ README.md 2015-12-03 08:16:49 +0000
4@@ -2,10 +2,25 @@
5
6 ## Prerequisites
7
8-This assumes you have a working go environment with a GOPATH env var setup
9-and nodejs and npm installed:
10-
11- sudo apt-get install nodejs-legacy npm
12+This assumes you have a working go environment with a GOPATH env var setup.
13+Make sure you have the full multiarch cross build env on 15.10+
14+(15.04 won't be able to build arm64):
15+
16+ sudo dpkg --add-architecture i386
17+ sudo apt update
18+ sudo apt install -y libc6-dev-i386
19+ sudo apt install -y linux-libc-dev linux-libc-dev:i386
20+ sudo apt install -y ubuntu-snappy-cli
21+ sudo apt install -y gcc-arm-linux-gnueabihf
22+ sudo apt install -y gcc-aarch64-linux-gnu
23+
24+Also the full golang with cross-build:
25+
26+ sudo apt install -y golang-go
27+
28+Plus ensure that nodejs and npm are installed:
29+
30+ sudo apt install -y nodejs-legacy npm
31
32 Install global npm modules without sudo:
33
34@@ -42,7 +57,7 @@
35
36 # Installing
37
38-Once you have a click package you can install it onto a remote snappy system
39+Once you have a snap package you can install it onto a remote snappy system
40 by running
41
42 snappy-remote --url ssh://localhost:8022 install [package]
43
44=== modified file 'avahi/avahi.go'
45--- avahi/avahi.go 2015-05-07 23:00:26 +0000
46+++ avahi/avahi.go 2015-12-03 08:16:49 +0000
47@@ -39,18 +39,22 @@
48 )
49
50 const timeoutMinutes = 10
51-const inAddr = `%s.local. 60 IN A %s`
52-const inPtr = `%s.in-addr.arpa. 60 IN PTR %s.local.`
53+const in4Addr = `%s.local. 60 IN A %s`
54+const in6Addr = `%s.local. 60 in AAAA %s`
55
56 var mdnsPublish = mdns.Publish
57
58-func tryPublish(hostname, ip string) {
59- rr := fmt.Sprintf(inAddr, hostname, ip)
60+func tryPublish(hostname string, ip net.IP) {
61+ inAddr := in4Addr
62+ if ip.To4() == nil {
63+ inAddr = in6Addr
64+ }
65+ rr := fmt.Sprintf(inAddr, hostname, ip.String())
66
67 logger.Println("Publishing", rr)
68
69 if err := mdnsPublish(rr); err != nil {
70- logger.Printf(`Unable to publish record "%s": %v`, rr, err)
71+ logger.Printf(`Unable to publish record %q: %v`, rr, err)
72 return
73 }
74 }
75@@ -102,17 +106,17 @@
76 return
77 }
78
79- if strings.ContainsRune(hostname, '.') {
80- hostname = strings.Split(hostname, ".")[0]
81+ if idx := strings.IndexByte(hostname, '.'); idx > -1 {
82+ hostname = hostname[:idx]
83 }
84
85 if hostname == hostnameLocalhost {
86 hostname = hostnameWedbm
87 }
88
89- for _, ip := range addrs {
90- ip := strings.Split(ip.String(), "/")[0]
91- if strings.HasPrefix(ip, "127.") {
92+ for _, addr := range addrs {
93+ ip, _, err := net.ParseCIDR(addr.String())
94+ if ip == nil || err != nil || ip.IsLoopback() {
95 continue
96 }
97
98
99=== modified file 'build.sh'
100--- build.sh 2015-05-26 13:34:13 +0000
101+++ build.sh 2015-12-03 08:16:49 +0000
102@@ -9,14 +9,17 @@
103 arch=$1
104
105 case $arch in
106+ 386)
107+ plat_abi=i386-linux-gnu
108+ ;;
109 amd64)
110 plat_abi=x86_64-linux-gnu
111 ;;
112 arm)
113 plat_abi=arm-linux-gnueabihf
114 ;;
115- armhf)
116- plat_abi=arm-linux-gnueabihf
117+ arm64)
118+ plat_abi=aarch64-linux-gnu
119 ;;
120 *)
121 echo "unknown platform for snappy-magic: $arch remember to file a bug or better yet: fix it :)"
122@@ -28,13 +31,33 @@
123 }
124
125 gobuild() {
126- arch=$1
127-
128- plat_abi=$(get_platform_abi $arch)
129+ local arch=$1
130+ local plat_abi=$(get_platform_abi $arch)
131
132 mkdir -p "bin/$plat_abi"
133 cd "bin/$plat_abi"
134- GOARCH=$arch GOARM=7 CGO_ENABLED=1 CC=${plat_abi}-gcc go build -ldflags "-extld=${plat_abi}-gcc" launchpad.net/webdm/cmd/snappyd
135+
136+ local GOARCH CGO_ENABLED CC GO386 FLAGS
137+
138+ export GOARCH=$arch
139+ export CGO_ENABLED=1
140+
141+ if [ "$arch" = "386" ]; then
142+ # 386 is a special snowflake, etc
143+ # also, the edison doesn't have SSE, which we might care about
144+ export GO386=387
145+ else
146+ export CC=${plat_abi}-gcc
147+ if ! which $CC > /dev/null; then
148+ echo "Could not find $CC. Maybe you need to install gcc-${plat_abi}?"
149+ exit 1
150+ fi
151+
152+ FLAGS="-ldflags -extld=$CC"
153+ fi
154+
155+ go build $FLAGS launchpad.net/webdm/cmd/snappyd
156+
157 cd - > /dev/null
158 }
159
160@@ -55,11 +78,14 @@
161 cp -r www/public www/templates $builddir/www
162 cd $builddir
163
164-sed -i 's/\(architecture: \)UNKNOWN_ARCH/\1[amd64, armhf]/' \
165+sed -i 's/\(architectures: \)UNKNOWN_ARCH/\1[i386, amd64, armhf, arm64]/' \
166 $builddir/meta/package.yaml
167
168-gobuild arm
169-gobuild amd64
170+for arch in 386 amd64 arm arm64; do
171+ echo -n Building for $arch...
172+ gobuild $arch
173+ echo done
174+done
175
176 cd "$orig_pwd"
177
178
179=== modified file 'dependencies.tsv'
180--- dependencies.tsv 2015-05-07 18:53:42 +0000
181+++ dependencies.tsv 2015-12-03 08:16:49 +0000
182@@ -4,9 +4,11 @@
183 github.com/davecheney/mdns git de174d86a3d3e87bfad9cb66cedd0433380b67b0 2014-09-13T23:56:41Z
184 github.com/gorilla/context git 50c25fb3b2b3b3cc724e9b6ac75fb44b3bccd0da 2014-11-26T16:34:05Z
185 github.com/gorilla/mux git e444e69cbd2e2e3e0749a2f3c717cec491552bbf 2014-09-26T15:38:14Z
186-github.com/juju/loggo git 4c7cbce140ca070eeb59a28f4bf9507e511711f9 2015-02-26T05:51:10Z
187+github.com/gosexy/gettext git 98b7b91596d20b96909e6b60d57411547dd9959c 2013-02-21T11:21:43Z
188 github.com/miekg/dns git 5a357a6fc5e85268b929350aa6423e2d56dcc4ff 2015-04-18T05:52:30Z
189 github.com/mvo5/goconfigparser git 26426272dda20cc76aa1fa44286dc743d2972fe8 2015-02-12T09:37:50Z
190+github.com/mvo5/uboot-go git 361f6ebcbb54f389d15dc9faefa000e996ba3e37 2015-07-22T06:53:46Z
191+github.com/ubuntu-core/snappy git 0b7a98c6dbd4d46c0f548806254ac722e72a2158 2015-11-13T09:05:44Z
192 gopkg.in/check.v1 git 64131543e7896d5bcc6bd5a76287eb75ea96c673 2014-10-24T13:38:53Z
193 gopkg.in/yaml.v2 git 49c95bdc21843256fb6c4e0d370a05f24a0bf213 2015-02-24T22:57:58Z
194-launchpad.net/snappy bzr snappy_tarmac-20150507103214-pgd90adryua6v6wi 444
195+launchpad.net/goyaml bzr gustavo@niemeyer.net-20140305200416-7gh64vkcckre5mob 51
196
197=== modified file 'oem/oem.go'
198--- oem/oem.go 2015-05-08 19:21:46 +0000
199+++ oem/oem.go 2015-12-03 08:16:49 +0000
200@@ -22,12 +22,13 @@
201 "io/ioutil"
202 "path/filepath"
203
204- "launchpad.net/snappy/snappy"
205+ "github.com/ubuntu-core/snappy/pkg"
206+ "github.com/ubuntu-core/snappy/snappy"
207
208 "gopkg.in/yaml.v2"
209 )
210
211-// Snap holds the package.yaml for a snappy.SnapTypeOem package.
212+// Snap holds the package.yaml for a pkg.TypeOem package.
213 type Snap struct {
214 Name string `yaml:"name" json:"name"`
215 Vendor string `yaml:"vendor" json:"vendor"`
216@@ -46,7 +47,7 @@
217 // ErrNotFound indicates that there is no oem package.
218 var ErrNotFound = errors.New("no oem package installed")
219
220-// ErrTooMany indicates that there are too many active snappy.SnapTypeOem packages, which
221+// ErrTooMany indicates that there are too many active pkg.TypeOem packages, which
222 // should never happen on a snappy managed system.
223 var ErrTooMany = errors.New("too many oem packages found")
224
225@@ -56,7 +57,7 @@
226
227 // Oem returns an oem package
228 func Oem() (*Snap, error) {
229- oem, err := snappy.ActiveSnapsByType(snappy.SnapTypeOem)
230+ oem, err := snappy.ActiveSnapsByType(pkg.TypeOem)
231 if err != nil {
232 return nil, err
233 } else if len(oem) > 1 {
234
235=== removed directory 'pkg/meta/hooks'
236=== removed file 'pkg/meta/hooks/config'
237--- pkg/meta/hooks/config 2015-02-27 16:35:54 +0000
238+++ pkg/meta/hooks/config 1970-01-01 00:00:00 +0000
239@@ -1,70 +0,0 @@
240-#!/usr/bin/python3
241-"""python3 hook for webdm"""
242-
243-import configparser
244-import os
245-import subprocess
246-import sys
247-import yaml
248-
249-
250-WEBDM_DATA_PATH = os.environ['SNAP_APP_DATA_PATH']
251-WEBDM_VERSION = os.environ['SNAP_VERSION']
252-AVAHI_CONFIG_FILE = os.path.join(WEBDM_DATA_PATH, 'avahi-daemon.conf')
253-
254-def main():
255- """main is the main function"""
256-
257- config_yaml = yaml.load(sys.stdin)
258- if config_yaml:
259- avahi_config = set_config(config_yaml)
260-
261- with open(AVAHI_CONFIG_FILE, 'w') as config:
262- avahi_config.write(config, space_around_delimiters=False)
263-
264- yaml.dump(get_config(), stream=sys.stdout, default_flow_style=False)
265- sys.exit(0)
266-
267-
268-def set_config(config_yaml):
269- """set_config sets a configuration and returns avahi_config"""
270-
271- restart_avahi = False
272-
273- config = config_yaml['config']['webdm']
274-
275- avahi_config = configparser.ConfigParser()
276- avahi_config.read(AVAHI_CONFIG_FILE)
277-
278- if 'avahi-hostname' in config:
279- avahi_config['server']['host-name'] = config['avahi-hostname']
280- restart_avahi = True
281-
282- if restart_avahi:
283- avahi_unit = 'webdm_avahi_%s.service' % WEBDM_VERSION
284- try:
285- subprocess.check_call(['systemctl', 'restart', avahi_unit])
286- except subprocess.CalledProcessError:
287- print("Cannot restart required services to fully apply "
288- "the configuration changes")
289-
290- return avahi_config
291-
292-
293-def get_config():
294- """get_config returns config with the current configuration"""
295-
296- config = {}
297- config['config'] = {}
298- config['config']['webdm'] = {}
299-
300- avahi_config = configparser.ConfigParser()
301- avahi_config.read(AVAHI_CONFIG_FILE)
302-
303- hostname = avahi_config['server']['host-name']
304- config['config']['webdm']['avahi-hostname'] = hostname
305-
306- return config
307-
308-if __name__ == '__main__':
309- main()
310
311=== modified file 'pkg/meta/package.yaml'
312--- pkg/meta/package.yaml 2015-06-10 14:41:19 +0000
313+++ pkg/meta/package.yaml 2015-12-03 08:16:49 +0000
314@@ -3,8 +3,8 @@
315 icon: meta/webdm-icon.png
316 source: lp:webdm
317 type: framework
318-version: 0.9
319-architecture: UNKNOWN_ARCH
320+version: "0.11"
321+architectures: UNKNOWN_ARCH
322 services:
323 - name: snappyd
324 start: snappyd
325
326=== modified file 'pkg/snappyd'
327--- pkg/snappyd 2015-05-21 22:24:32 +0000
328+++ pkg/snappyd 2015-12-03 08:16:49 +0000
329@@ -4,6 +4,12 @@
330 platform=$(uname -i)
331
332 case $platform in
333+ i386)
334+ plat_abi=i386-linux-gnu
335+ ;;
336+ aarch64)
337+ plat_abi=aarch64-linux-gnu
338+ ;;
339 x86_64)
340 plat_abi=x86_64-linux-gnu
341 ;;
342@@ -15,7 +21,6 @@
343 ;;
344 esac
345
346-mkdir -m1777 -p $SNAP_APP_TMPDIR
347 exec $SNAP_APP_PATH/bin/$plat_abi/snappyd
348
349 # never reach this
350
351=== modified file 'snappy/common_test.go'
352--- snappy/common_test.go 2015-05-07 15:37:12 +0000
353+++ snappy/common_test.go 2015-12-03 08:16:49 +0000
354@@ -20,7 +20,7 @@
355 import (
356 "testing"
357
358- "launchpad.net/snappy/snappy"
359+ "github.com/ubuntu-core/snappy/snappy"
360
361 . "gopkg.in/check.v1"
362 )
363
364=== modified file 'snappy/converge.go'
365--- snappy/converge.go 2015-05-08 15:22:21 +0000
366+++ snappy/converge.go 2015-12-03 08:16:49 +0000
367@@ -25,7 +25,8 @@
368
369 "log"
370
371- "launchpad.net/snappy/snappy"
372+ "github.com/ubuntu-core/snappy/snappy"
373+ "github.com/ubuntu-core/snappy/pkg"
374 "launchpad.net/webdm/webprogress"
375 )
376
377@@ -43,7 +44,7 @@
378 Progress float64 `json:"progress,omitempty"`
379 InstalledSize int64 `json:"installed_size,omitempty"`
380 DownloadSize int64 `json:"download_size,omitempty"`
381- Type snappy.SnapType `json:"type,omitempty"`
382+ Type pkg.Type `json:"type,omitempty"`
383 UIPort uint64 `json:"ui_port,omitempty"`
384 UIUri string `json:"ui_uri,omitempty"`
385 }
386@@ -63,10 +64,10 @@
387 var activeSnapByName = snappy.ActiveSnapByName
388
389 func (h *Handler) packagePayload(resource string) (snapPkg, error) {
390- var pkgName, namespace string
391+ var pkgName, origin string
392 if s := strings.Split(resource, "."); len(s) == 2 {
393 pkgName = s[0]
394- namespace = s[1]
395+ origin = s[1]
396 } else {
397 pkgName = resource
398 }
399@@ -74,13 +75,13 @@
400 snapQ := activeSnapByName(pkgName)
401 if snapQ != nil {
402 // the second check is for locally installed snaps that lose their origin.
403- if snapQ.Namespace() == namespace || snapQ.Type() != snappy.SnapTypeApp {
404+ if snapQ.Origin() == origin || snapQ.Type() != pkg.TypeApp {
405 return h.snapQueryToPayload(snapQ), nil
406 }
407 }
408
409 mStore := snappy.NewMetaStoreRepository()
410- found, err := mStore.Details(resource)
411+ found, err := mStore.Details(pkgName, origin)
412 if err == nil && len(found) != 0 {
413 return h.snapQueryToPayload(found[0]), nil
414 }
415@@ -225,33 +226,24 @@
416 return snapPkgs
417 }
418
419-func isNamespaceless(snap snappy.Part) bool {
420- return snap.Type() == snappy.SnapTypeOem || snap.Type() == snappy.SnapTypeFramework
421-}
422-
423 func hasPortInformation(snap snappy.Part) bool {
424- return snap.Type() == snappy.SnapTypeApp || snap.Type() == snappy.SnapTypeFramework
425+ return snap.Type() == pkg.TypeApp || snap.Type() == pkg.TypeFramework
426 }
427
428 func (h *Handler) snapQueryToPayload(snapQ snappy.Part) snapPkg {
429 snap := snapPkg{
430 Name: snapQ.Name(),
431- Origin: snapQ.Namespace(),
432+ Origin: snapQ.Origin(),
433 Version: snapQ.Version(),
434 Vendor: snapQ.Vendor(),
435 Description: snapQ.Description(),
436 Type: snapQ.Type(),
437- }
438-
439- if isNamespaceless(snapQ) {
440- snap.ID = snapQ.Name()
441- } else {
442- snap.ID = snapQ.Name() + "." + snapQ.Namespace()
443+ ID: snappy.QualifiedName(snapQ),
444 }
445
446 if hasPortInformation(snapQ) {
447- if snapInstalled, ok := snapQ.(snappy.Services); ok {
448- port, uri := uiAccess(snapInstalled.Services())
449+ if snapInstalled, ok := snapQ.(snappy.ServiceYamler); ok {
450+ port, uri := uiAccess(snapInstalled.ServiceYamls())
451 snap.UIPort = port
452 snap.UIUri = uri
453 }
454@@ -293,7 +285,7 @@
455 return snap
456 }
457
458-func uiAccess(services []snappy.Service) (port uint64, uri string) {
459+func uiAccess(services []snappy.ServiceYaml) (port uint64, uri string) {
460 for i := range services {
461 if services[i].Ports == nil {
462 continue
463
464=== modified file 'snappy/converge_test.go'
465--- snappy/converge_test.go 2015-05-07 15:37:12 +0000
466+++ snappy/converge_test.go 2015-12-03 08:16:49 +0000
467@@ -23,7 +23,7 @@
468 "path/filepath"
469
470 . "gopkg.in/check.v1"
471- "launchpad.net/snappy/snappy"
472+ "github.com/ubuntu-core/snappy/snappy"
473 "launchpad.net/webdm/webprogress"
474 )
475
476
477=== modified file 'snappy/handlers.go'
478--- snappy/handlers.go 2015-05-08 14:56:30 +0000
479+++ snappy/handlers.go 2015-12-03 08:16:49 +0000
480@@ -24,7 +24,7 @@
481 "net/http"
482 "strings"
483
484- "launchpad.net/snappy/snappy"
485+ "github.com/ubuntu-core/snappy/snappy"
486 "launchpad.net/webdm/webprogress"
487
488 "github.com/gorilla/mux"
489
490=== modified file 'webprogress/meter.go'
491--- webprogress/meter.go 2015-05-06 17:14:44 +0000
492+++ webprogress/meter.go 2015-12-03 08:16:49 +0000
493@@ -17,7 +17,7 @@
494
495 package webprogress
496
497-import "launchpad.net/snappy/progress"
498+import "github.com/ubuntu-core/snappy/progress"
499
500 // Operation indicates the desired operation to perform
501 type Operation uint

Subscribers

People subscribed via source and target branches