Merge lp:~stevenwilkin/snapweb/snappy-2-0 into lp:~snappy-dev/snapweb/trunk

Proposed by Steven Wilkin
Status: Merged
Approved by: Steven Wilkin
Approved revision: 191
Merged at revision: 180
Proposed branch: lp:~stevenwilkin/snapweb/snappy-2-0
Merge into: lp:~snappy-dev/snapweb/trunk
Diff against target: 1070 lines (+94/-394)
23 files modified
cmd/snappyd/handlers.go (+3/-3)
dependencies.tsv (+1/-1)
pkg/meta/snap.yaml (+1/-7)
pkg/meta/snappyd.profile (+0/-110)
pkg/meta/snappyd.seccomp (+0/-4)
pkg/snappyd (+1/-2)
snappy/common_test.go (+9/-71)
snappy/converge.go (+12/-48)
snappy/converge_test.go (+11/-53)
snappy/handlers.go (+12/-12)
snappy/handlers_test.go (+1/-1)
snappy/icon.go (+5/-5)
snappy/icon_test.go (+12/-12)
snappy/snapd_client.go (+5/-6)
statustracker/statustracker.go (+7/-11)
statustracker/statustracker_test.go (+4/-4)
www/src/css/snaplist.css (+4/-4)
www/src/js/config.js (+1/-1)
www/src/js/models/snap.js (+3/-18)
www/src/js/templates/snap-menu.hbs (+0/-5)
www/src/js/templates/snaplist-item.hbs (+1/-1)
www/src/js/templates/storelist-item.hbs (+1/-1)
www/tests/modelSpec.js (+0/-14)
To merge this branch: bzr merge lp:~stevenwilkin/snapweb/snappy-2-0
Reviewer Review Type Date Requested Status
Michael Vogt (community) Approve
Review via email: mp+292902@code.launchpad.net

Commit message

Get WebDM building against Snappy 2.0

Description of the change

Get WebDM building against Snappy 2.0.

NOTE: the resulting snap will still need to be sideloaded with `--devmode`

To post a comment you must log in.
Revision history for this message
Michael Vogt (mvo) wrote :

Looks good!

review: Approve
Revision history for this message
Steven Wilkin (stevenwilkin) :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cmd/snappyd/handlers.go'
2--- cmd/snappyd/handlers.go 2016-03-08 18:55:57 +0000
3+++ cmd/snappyd/handlers.go 2016-04-26 10:36:16 +0000
4@@ -53,7 +53,7 @@
5 snappyHandler := snappy.NewHandler()
6 http.Handle("/api/v2/packages/", snappyHandler.MakeMuxer("/api/v2/packages"))
7
8- http.Handle("/public/", loggingHandler(http.FileServer(http.Dir("./www"))))
9+ http.Handle("/public/", loggingHandler(http.FileServer(http.Dir(filepath.Join(os.Getenv("SNAP"), "www")))))
10
11 if iconDir, relativePath, err := snappy.IconDir(); err == nil {
12 http.Handle(fmt.Sprintf("/%s/", relativePath), loggingHandler(http.FileServer(http.Dir(filepath.Join(iconDir, "..")))))
13@@ -95,13 +95,13 @@
14 }
15
16 func renderLayout(html string, data *page, w http.ResponseWriter) error {
17- htmlPath := filepath.Join("www", "templates", html)
18+ htmlPath := filepath.Join(os.Getenv("SNAP"), "www", "templates", html)
19 if _, err := os.Stat(htmlPath); err != nil {
20 http.Error(w, err.Error(), http.StatusInternalServerError)
21 return err
22 }
23
24- layoutPath := filepath.Join("www", "templates", "base.html")
25+ layoutPath := filepath.Join(os.Getenv("SNAP"), "www", "templates", "base.html")
26 t, err := template.ParseFiles(layoutPath, htmlPath)
27 if err != nil {
28 http.Error(w, err.Error(), http.StatusInternalServerError)
29
30=== modified file 'dependencies.tsv'
31--- dependencies.tsv 2016-02-23 16:00:47 +0000
32+++ dependencies.tsv 2016-04-26 10:36:16 +0000
33@@ -7,7 +7,7 @@
34 github.com/miekg/dns git 5a357a6fc5e85268b929350aa6423e2d56dcc4ff 2015-04-18T05:52:30Z
35 github.com/mvo5/goconfigparser git 26426272dda20cc76aa1fa44286dc743d2972fe8 2015-02-12T09:37:50Z
36 github.com/mvo5/uboot-go git 69978a3e4b05cca9d7cfee489b3453dfed45e72c 2015-07-23T08:17:10Z
37-github.com/ubuntu-core/snappy git 5bcb20229bb884b85144eab0fe5db7aa05a27ebf 2016-02-23T14:04:06Z
38+github.com/ubuntu-core/snappy git 462812cfc390aff5bc2861320edba4cf34b740cf 2016-04-19T15:04:48Z
39 golang.org/x/crypto git 60052bd85f2d91293457e8811b0cf26b773de469 2015-06-22T23:34:07Z
40 gopkg.in/check.v1 git 64131543e7896d5bcc6bd5a76287eb75ea96c673 2014-10-24T13:38:53Z
41 gopkg.in/yaml.v2 git 49c95bdc21843256fb6c4e0d370a05f24a0bf213 2015-02-24T22:57:58Z
42
43=== modified file 'pkg/meta/snap.yaml'
44--- pkg/meta/snap.yaml 2016-03-06 16:59:32 +0000
45+++ pkg/meta/snap.yaml 2016-04-26 10:36:16 +0000
46@@ -24,10 +24,4 @@
47 daemon: simple
48 description: Snappy WebDM
49 command: snappyd
50- plugs: [snappyd]
51-plugs:
52- snappyd:
53- interface: old-security
54- security-policy:
55- apparmor: meta/snappyd.profile
56- seccomp: meta/snappyd.seccomp
57+ plugs: [network, network-bind, snapd-control]
58
59=== removed file 'pkg/meta/snappyd.profile'
60--- pkg/meta/snappyd.profile 2016-01-27 14:16:35 +0000
61+++ pkg/meta/snappyd.profile 1970-01-01 00:00:00 +0000
62@@ -1,110 +0,0 @@
63-#include <tunables/global>
64-
65-###VAR###
66-
67-###PROFILEATTACH### (attach_disconnected) {
68- #include <abstractions/base>
69- #include <abstractions/nameservice>
70-
71- # Read-only for the install directory
72- @{CLICK_DIR}/@{APP_PKGNAME}/ r,
73- @{CLICK_DIR}/@{APP_PKGNAME}/@{APP_VERSION}/ r,
74- @{CLICK_DIR}/@{APP_PKGNAME}/@{APP_VERSION}/** mrklix,
75-
76- # Writable home area
77- owner @{HOMEDIRS}/snaps/@{APP_PKGNAME}/@{APP_VERSION}/ rw,
78- owner @{HOMEDIRS}/snaps/@{APP_PKGNAME}/@{APP_VERSION}/** mrwklix,
79-
80- # Read-only system area for other versions
81- /var/lib/snaps/@{APP_PKGNAME}/ rw,
82- /var/lib/snaps/@{APP_PKGNAME}/** mrkix,
83-
84- # Writable system area only for this version.
85- /var/lib/snaps/@{APP_PKGNAME}/@{APP_VERSION}/ w,
86- /var/lib/snaps/@{APP_PKGNAME}/@{APP_VERSION}/** wl,
87-
88- # temp dirs
89- /tmp/snaps/@{APP_PKGNAME}/ r,
90- /tmp/snaps/@{APP_PKGNAME}/** rk,
91- /tmp/snaps/@{APP_PKGNAME}/@{APP_VERSION}/ rw,
92- /tmp/snaps/@{APP_PKGNAME}/@{APP_VERSION}/** mrwlkix,
93-
94- # magic script
95- /bin/uname ixr,
96- /usr/bin/basename ixr,
97- /usr/bin/realpath ixr,
98- /usr/bin/dirname ixr,
99- /bin/dash ixr,
100- /bin/sed ixr,
101- /bin/mkdir ixr,
102-
103- @{PROC}/sys/kernel/hostname r,
104- @{PROC}/sys/kernel/somaxconn r,
105- @{PROC}/sys/net/core/somaxconn r,
106-
107- # system image
108- /etc/system-image/channel.ini r,
109- /writable/cache/system/etc/system-image/channel.ini r,
110-
111- # snaps
112- /snaps/ r,
113- /snaps/** rwl,
114- /gadget/ r,
115- /gadget/** rwl,
116- /tmp/ r,
117- /tmp/** rwl,
118- /var/lib/snaps/ r,
119- /var/lib/snaps/** rwl,
120- /var/lib/snappy/ r,
121- /var/lib/snappy/** rwl,
122- /var/lib/click/hooks/ r,
123- /var/lib/click/hooks/** rwl,
124- /home/ r,
125- /home/** r,
126-
127-
128- # snappy unpack
129- /usr/bin/snappy uxr,
130-
131- # snappy tty change
132- /dev/tty r,
133-
134- # snappy requirements
135- /bin/lsblk Uxr,
136- /bin/mountpoint Uxr,
137- /bin/cp Uxr,
138- /usr/bin/debsig-verify Uxr,
139- /usr/bin/sc-filtergen Uxr,
140- /usr/bin/aa-clickhook Uxr,
141- /usr/bin/aa-profile-hook Uxr,
142-
143- # snapd REST API
144- /run/snapd.socket rw,
145-
146- # TODO: attention needed here
147- /etc/lsb-release r,
148- /sbin/apparmor_parser Uxr,
149- /usr/bin/unsquashfs Uxr,
150- /usr/share/apparmor/easyprof/policygroups/** r,
151- /usr/share/apparmor/easyprof/templates/** r,
152- /usr/share/seccomp/policygroups/** r,
153- /usr/share/seccomp/templates/** r,
154- /var/cache/apparmor/** w,
155-
156- # snappy requirements for services
157- /etc/dbus-1/system.d/ r,
158- /etc/dbus-1/system.d/** rwl,
159- /etc/mime.types r,
160- /usr/share/click/hooks/ r,
161- /usr/share/click/hooks/** r,
162- /etc/systemd/system/ r,
163- /etc/systemd/system/** rwl,
164- /var/lib/apparmor/clicks/ r,
165- /var/lib/apparmor/clicks/** rwl,
166- /var/lib/apparmor/snappy/ r,
167- /var/lib/apparmor/snappy/** rwl,
168- /bin/systemctl Uxr,
169-
170- capability net_admin,
171- capability dac_override,
172-}
173
174=== removed file 'pkg/meta/snappyd.seccomp'
175--- pkg/meta/snappyd.seccomp 2015-06-11 22:03:29 +0000
176+++ pkg/meta/snappyd.seccomp 1970-01-01 00:00:00 +0000
177@@ -1,4 +0,0 @@
178-# This has to be unrestricted since snappyd will fork/exec /usr/bin/snappy for
179-# various things and seccomp would apply this policy to snappy and it then
180-# doesn't run well. Once there is a proper IPC service, this can be revisited.
181-@unrestricted
182
183=== modified file 'pkg/snappyd'
184--- pkg/snappyd 2016-02-23 12:15:07 +0000
185+++ pkg/snappyd 2016-04-26 10:36:16 +0000
186@@ -18,8 +18,7 @@
187 ;;
188 esac
189
190-mkdir -m1777 -p $SNAP_APP_TMPDIR
191-exec $SNAP_APP_PATH/bin/$plat_abi/snappyd
192+exec $SNAP/bin/$plat_abi/snappyd
193
194 # never reach this
195 exit 1
196
197=== modified file 'snappy/common_test.go'
198--- snappy/common_test.go 2016-04-21 04:33:37 +0000
199+++ snappy/common_test.go 2016-04-26 10:36:16 +0000
200@@ -18,7 +18,6 @@
201 package snappy
202
203 import (
204- "errors"
205 "testing"
206
207 "github.com/ubuntu-core/snappy/client"
208@@ -41,7 +40,7 @@
209 Icon: "/1.0/icons/chatroom.ogra/icon",
210 InstalledSize: 18976651,
211 Name: "chatroom",
212- Origin: "ogra",
213+ Developer: "ogra",
214 Status: client.StatusActive,
215 Type: client.TypeApp,
216 Version: "0.1-8",
217@@ -55,7 +54,7 @@
218 return snap
219 }
220
221-func (f *fakeSnapdClient) Icon(pkgID string) (*client.Icon, error) {
222+func (f *fakeSnapdClient) Icon(name string) (*client.Icon, error) {
223 icon := &client.Icon{
224 Filename: "icon.png",
225 Content: []byte("png"),
226@@ -63,86 +62,25 @@
227 return icon, nil
228 }
229
230-func (f *fakeSnapdClient) Services(pkg string) (map[string]*client.Service, error) {
231- return nil, errors.New("the package has no services")
232-}
233-
234-func (f *fakeSnapdClient) Snap(name string) (*client.Snap, error) {
235+func (f *fakeSnapdClient) Snap(name string) (*client.Snap, *client.ResultInfo, error) {
236 if len(f.snaps) > 0 {
237- return f.snaps[0], f.err
238+ return f.snaps[0], nil, f.err
239 }
240- return nil, f.err
241+ return nil, nil, f.err
242 }
243
244-func (f *fakeSnapdClient) FilterSnaps(filter client.SnapFilter) (map[string]*client.Snap, error) {
245+func (f *fakeSnapdClient) FilterSnaps(filter client.SnapFilter) ([]*client.Snap, *client.ResultInfo, error) {
246 f.filter = filter // record the filter used
247
248- snaps := make(map[string]*client.Snap)
249- for _, s := range f.snaps {
250- snaps[s.Name] = s
251- }
252-
253- return snaps, f.err
254+ return f.snaps, nil, f.err
255 }
256
257-func (f *fakeSnapdClient) AddSnap(name string) (string, error) {
258+func (f *fakeSnapdClient) Install(name string, options *client.SnapOptions) (string, error) {
259 return "", nil
260 }
261
262-func (f *fakeSnapdClient) RemoveSnap(name string) (string, error) {
263+func (f *fakeSnapdClient) Remove(name string, options *client.SnapOptions) (string, error) {
264 return "", nil
265 }
266
267 var _ snapdClient = (*fakeSnapdClient)(nil)
268-
269-type fakeSnapdClientServicesNoExternalUI struct {
270- fakeSnapdClient
271-}
272-
273-func (f *fakeSnapdClientServicesNoExternalUI) Services(pkg string) (map[string]*client.Service, error) {
274- internal := map[string]client.ServicePort{"ui": client.ServicePort{Port: "200/tcp"}}
275- external := map[string]client.ServicePort{"web": client.ServicePort{Port: "1024/tcp"}}
276- s1 := &client.Service{
277- Spec: client.ServiceSpec{
278- Ports: client.ServicePorts{
279- Internal: internal,
280- External: external,
281- },
282- },
283- }
284-
285- s2 := &client.Service{}
286-
287- services := map[string]*client.Service{
288- "s1": s1,
289- "s2": s2,
290- }
291-
292- return services, nil
293-}
294-
295-type fakeSnapdClientServicesExternalUI struct {
296- fakeSnapdClient
297-}
298-
299-func (f *fakeSnapdClientServicesExternalUI) Services(pkg string) (map[string]*client.Service, error) {
300- s1 := &client.Service{}
301-
302- internal := map[string]client.ServicePort{"ui": client.ServicePort{Port: "200/tcp"}}
303- external := map[string]client.ServicePort{"ui": client.ServicePort{Port: "1024/tcp"}}
304- s2 := &client.Service{
305- Spec: client.ServiceSpec{
306- Ports: client.ServicePorts{
307- Internal: internal,
308- External: external,
309- },
310- },
311- }
312-
313- services := map[string]*client.Service{
314- "s1": s1,
315- "s2": s2,
316- }
317-
318- return services, nil
319-}
320
321=== modified file 'snappy/converge.go'
322--- snappy/converge.go 2016-04-21 04:33:37 +0000
323+++ snappy/converge.go 2016-04-26 10:36:16 +0000
324@@ -19,8 +19,6 @@
325
326 import (
327 "sort"
328- "strconv"
329- "strings"
330
331 "log"
332
333@@ -31,7 +29,7 @@
334 type snapPkg struct {
335 ID string `json:"id"`
336 Name string `json:"name"`
337- Origin string `json:"origin"`
338+ Developer string `json:"developer"`
339 Version string `json:"version"`
340 Description string `json:"description"`
341 Icon string `json:"icon"`
342@@ -41,7 +39,6 @@
343 InstalledSize int64 `json:"installed_size,omitempty"`
344 DownloadSize int64 `json:"download_size,omitempty"`
345 Type snap.Type `json:"type,omitempty"`
346- UIPort uint64 `json:"ui_port,omitempty"`
347 }
348
349 type response struct {
350@@ -50,7 +47,7 @@
351 }
352
353 func (h *Handler) packagePayload(resource string) (snapPkg, error) {
354- snap, err := h.snapdClient.Snap(resource)
355+ snap, _, err := h.snapdClient.Snap(resource)
356 if err != nil {
357 return snapPkg{}, err
358 }
359@@ -59,7 +56,7 @@
360 }
361
362 func (h *Handler) allPackages(filter client.SnapFilter) ([]snapPkg, error) {
363- snaps, err := h.snapdClient.FilterSnaps(filter)
364+ snaps, _, err := h.snapdClient.FilterSnaps(filter)
365 if err != nil {
366 return nil, err
367 }
368@@ -74,56 +71,45 @@
369 return snapPkgs, nil
370 }
371
372-func (h *Handler) removePackage(ID string) error {
373- snap, err := h.snapdClient.Snap(ID)
374+func (h *Handler) removePackage(name string) error {
375+ snap, _, err := h.snapdClient.Snap(name)
376 if err != nil {
377 return err
378 }
379
380 h.statusTracker.TrackUninstall(snap)
381
382- _, err = h.snapdClient.RemoveSnap(ID)
383+ _, err = h.snapdClient.Remove(name, nil)
384 return err
385 }
386
387-func (h *Handler) installPackage(ID string) error {
388- snap, err := h.snapdClient.Snap(ID)
389+func (h *Handler) installPackage(name string) error {
390+ snap, _, err := h.snapdClient.Snap(name)
391 if err != nil {
392 return err
393 }
394
395 h.statusTracker.TrackInstall(snap)
396
397- _, err = h.snapdClient.AddSnap(ID)
398+ _, err = h.snapdClient.Install(name, nil)
399 return err
400 }
401
402-func hasPortInformation(snapQ *client.Snap) bool {
403- snapType := snap.Type(snapQ.Type)
404- return snapType == snap.TypeApp || snapType == snap.TypeFramework
405-}
406-
407 func (h *Handler) snapToPayload(snapQ *client.Snap) snapPkg {
408 snap := snapPkg{
409- ID: snapQ.Name + "." + snapQ.Origin,
410+ ID: snapQ.Name,
411 Name: snapQ.Name,
412- Origin: snapQ.Origin,
413+ Developer: snapQ.Developer,
414 Version: snapQ.Version,
415 Description: snapQ.Description,
416 Type: snap.Type(snapQ.Type),
417 Status: h.statusTracker.Status(snapQ),
418 }
419
420- if hasPortInformation(snapQ) {
421- if services, err := h.snapdClient.Services(snap.ID); err == nil {
422- snap.UIPort = uiAccess(services)
423- }
424- }
425-
426 isInstalled := snapQ.Status == client.StatusInstalled || snapQ.Status == client.StatusActive
427
428 if isInstalled {
429- iconPath, err := localIconPath(h.snapdClient, snap.ID)
430+ iconPath, err := localIconPath(h.snapdClient, snap.Name)
431 if err != nil {
432 log.Println("Icon path for installed package cannot be set", err)
433 iconPath = ""
434@@ -138,25 +124,3 @@
435
436 return snap
437 }
438-
439-func uiAccess(services map[string]*client.Service) uint64 {
440- for i := range services {
441- if services[i].Spec.Ports.External == nil {
442- continue
443- }
444-
445- if ui, ok := services[i].Spec.Ports.External["ui"]; ok {
446- ui := strings.Split(ui.Port, "/")
447- if len(ui) == 2 {
448- port, err := strconv.ParseUint(ui[0], 0, 64)
449- if err != nil {
450- return 0
451- }
452-
453- return port
454- }
455- }
456- }
457-
458- return 0
459-}
460
461=== modified file 'snappy/converge_test.go'
462--- snappy/converge_test.go 2016-03-08 18:30:48 +0000
463+++ snappy/converge_test.go 2016-04-26 10:36:16 +0000
464@@ -35,7 +35,7 @@
465 var _ = Suite(&PackagePayloadSuite{})
466
467 func (s *PackagePayloadSuite) SetUpTest(c *C) {
468- os.Setenv("SNAP_APP_DATA_PATH", c.MkDir())
469+ os.Setenv("SNAP_DATA", c.MkDir())
470 s.h.statusTracker = statustracker.New()
471 s.c = &fakeSnapdClient{}
472 s.h.setClient(s.c)
473@@ -44,23 +44,23 @@
474 func (s *PackagePayloadSuite) TestPackageNotFound(c *C) {
475 s.c.err = errors.New("the snap could not be retrieved")
476
477- _, err := s.h.packagePayload("chatroom.ogra")
478+ _, err := s.h.packagePayload("chatroom")
479 c.Assert(err, NotNil)
480 }
481
482 func (s *PackagePayloadSuite) TestPackage(c *C) {
483 s.c.snaps = []*client.Snap{newDefaultSnap()}
484
485- pkg, err := s.h.packagePayload("chatroom.ogra")
486+ pkg, err := s.h.packagePayload("chatroom")
487 c.Assert(err, IsNil)
488 c.Assert(pkg, DeepEquals, snapPkg{
489- ID: "chatroom.ogra",
490+ ID: "chatroom",
491 Description: "WebRTC Video chat server for Snappy",
492 DownloadSize: 0,
493- Icon: "/icons/chatroom.ogra_icon.png",
494+ Icon: "/icons/chatroom_icon.png",
495 InstalledSize: 18976651,
496 Name: "chatroom",
497- Origin: "ogra",
498+ Developer: "ogra",
499 Status: "installed",
500 Type: "app",
501 Version: "0.1-8",
502@@ -74,12 +74,12 @@
503 var _ = Suite(&PayloadSuite{})
504
505 func (s *PayloadSuite) SetUpTest(c *C) {
506- os.Setenv("SNAP_APP_DATA_PATH", c.MkDir())
507+ os.Setenv("SNAP_DATA", c.MkDir())
508 s.h.statusTracker = statustracker.New()
509 s.h.setClient(&fakeSnapdClient{})
510 }
511
512-func (s *PayloadSuite) TestPayloadWithNoServices(c *C) {
513+func (s *PayloadSuite) TestPayload(c *C) {
514 fakeSnap := newDefaultSnap()
515
516 q := s.h.snapToPayload(fakeSnap)
517@@ -88,55 +88,13 @@
518 c.Check(q.Version, Equals, fakeSnap.Version)
519 c.Check(q.Status, Equals, statustracker.StatusInstalled)
520 c.Check(q.Type, Equals, snap.Type(fakeSnap.Type))
521- c.Check(q.UIPort, Equals, uint64(0))
522- c.Check(q.Icon, Equals, "/icons/chatroom.ogra_icon.png")
523+ c.Check(q.Icon, Equals, "/icons/chatroom_icon.png")
524 c.Check(q.Description, Equals, fakeSnap.Description)
525 }
526
527-func (s *PayloadSuite) TestPayloadWithServicesButNoUI(c *C) {
528- s.h.setClient(&fakeSnapdClientServicesNoExternalUI{})
529-
530- fakeSnap := newDefaultSnap()
531- q := s.h.snapToPayload(fakeSnap)
532-
533- c.Assert(q.Name, Equals, fakeSnap.Name)
534- c.Assert(q.Version, Equals, fakeSnap.Version)
535- c.Assert(q.Status, Equals, statustracker.StatusInstalled)
536- c.Assert(q.Type, Equals, snap.Type(fakeSnap.Type))
537- c.Assert(q.UIPort, Equals, uint64(0))
538-}
539-
540-func (s *PayloadSuite) TestPayloadWithServicesUI(c *C) {
541- s.h.setClient(&fakeSnapdClientServicesExternalUI{})
542-
543- fakeSnap := newDefaultSnap()
544- q := s.h.snapToPayload(fakeSnap)
545-
546- c.Assert(q.Name, Equals, fakeSnap.Name)
547- c.Assert(q.Version, Equals, fakeSnap.Version)
548- c.Assert(q.Status, Equals, statustracker.StatusInstalled)
549- c.Assert(q.Type, Equals, snap.Type(fakeSnap.Type))
550- c.Assert(q.UIPort, Equals, uint64(1024))
551-}
552-
553-func (s *PayloadSuite) TestPayloadTypeGadget(c *C) {
554- s.h.setClient(&fakeSnapdClientServicesExternalUI{})
555-
556- fakeSnap := newDefaultSnap()
557- fakeSnap.Type = string(snap.TypeGadget)
558-
559- q := s.h.snapToPayload(fakeSnap)
560-
561- c.Assert(q.Name, Equals, fakeSnap.Name)
562- c.Assert(q.Version, Equals, fakeSnap.Version)
563- c.Assert(q.Status, Equals, statustracker.StatusInstalled)
564- c.Assert(q.Type, Equals, snap.Type(fakeSnap.Type))
565- c.Assert(q.UIPort, Equals, uint64(0))
566-}
567-
568 func (s *PayloadSuite) TestPayloadSnapInstalling(c *C) {
569 fakeSnap := newDefaultSnap()
570- fakeSnap.Status = client.StatusNotInstalled
571+ fakeSnap.Status = client.StatusAvailable
572 s.h.statusTracker.TrackInstall(fakeSnap)
573
574 payload := s.h.snapToPayload(fakeSnap)
575@@ -151,7 +109,7 @@
576 var _ = Suite(&AllPackagesSuite{})
577
578 func (s *AllPackagesSuite) SetUpTest(c *C) {
579- os.Setenv("SNAP_APP_DATA_PATH", c.MkDir())
580+ os.Setenv("SNAP_DATA", c.MkDir())
581 s.h.statusTracker = statustracker.New()
582 s.c = &fakeSnapdClient{}
583 s.h.setClient(s.c)
584
585=== modified file 'snappy/handlers.go'
586--- snappy/handlers.go 2016-03-08 18:30:48 +0000
587+++ snappy/handlers.go 2016-04-26 10:36:16 +0000
588@@ -82,13 +82,13 @@
589 w.Header().Set("Content-Type", "application/json")
590 // Get the Key.
591 vars := mux.Vars(r)
592- resource := vars["id"]
593+ name := vars["name"]
594 enc := json.NewEncoder(w)
595
596- payload, err := h.packagePayload(resource)
597+ payload, err := h.packagePayload(name)
598 if err != nil {
599 w.WriteHeader(http.StatusNotFound)
600- enc.Encode(fmt.Sprintln(err, resource))
601+ enc.Encode(fmt.Sprintln(err, name))
602 return
603 }
604
605@@ -104,12 +104,12 @@
606 w.Header().Set("Content-Type", "application/json")
607 // Get the Key.
608 vars := mux.Vars(r)
609- ID := vars["id"]
610+ name := vars["name"]
611
612- err := h.installPackage(ID)
613+ err := h.installPackage(name)
614 msg, status := respond(err)
615
616- response := response{Message: msg, Package: ID}
617+ response := response{Message: msg, Package: name}
618 bs, err := json.Marshal(response)
619 if err != nil {
620 // giving up on json
621@@ -127,12 +127,12 @@
622 w.Header().Set("Content-Type", "application/json")
623 // Get the Key.
624 vars := mux.Vars(r)
625- ID := vars["id"]
626+ name := vars["name"]
627
628- err := h.removePackage(ID)
629+ err := h.removePackage(name)
630 msg, status := respond(err)
631
632- response := response{Message: msg, Package: ID}
633+ response := response{Message: msg, Package: name}
634 bs, err := json.Marshal(response)
635 if err != nil {
636 // giving up on json
637@@ -180,13 +180,13 @@
638 m.HandleFunc("/", h.getAll).Methods("GET")
639
640 // get specific package
641- m.HandleFunc("/{id}", h.get).Methods("GET")
642+ m.HandleFunc("/{name}", h.get).Methods("GET")
643
644 // Add a package
645- m.HandleFunc("/{id}", h.add).Methods("PUT")
646+ m.HandleFunc("/{name}", h.add).Methods("PUT")
647
648 // Remove a package
649- m.HandleFunc("/{id}", h.remove).Methods("DELETE")
650+ m.HandleFunc("/{name}", h.remove).Methods("DELETE")
651
652 return m
653 }
654
655=== modified file 'snappy/handlers_test.go'
656--- snappy/handlers_test.go 2016-03-08 18:30:48 +0000
657+++ snappy/handlers_test.go 2016-04-26 10:36:16 +0000
658@@ -35,7 +35,7 @@
659 var _ = Suite(&HandlersSuite{})
660
661 func (s *HandlersSuite) SetUpTest(c *C) {
662- os.Setenv("SNAP_APP_DATA_PATH", c.MkDir())
663+ os.Setenv("SNAP_DATA", c.MkDir())
664 s.c = &fakeSnapdClient{}
665 s.h.setClient(s.c)
666 }
667
668=== modified file 'snappy/icon.go'
669--- snappy/icon.go 2016-01-27 14:16:35 +0000
670+++ snappy/icon.go 2016-04-26 10:36:16 +0000
671@@ -26,7 +26,7 @@
672 )
673
674 var (
675- // ErrDataPathNotSet indicates that SNAP_APP_DATA_PATH has not been set by the
676+ // ErrDataPathNotSet indicates that SNAP_DATA has not been set by the
677 // launching system.
678 ErrDataPathNotSet = errors.New("package data path not set")
679 // ErrOnIconDataPathSet indicates that there has been an error when setting up
680@@ -36,18 +36,18 @@
681 ErrIconNotExist = errors.New("the icon does not exist")
682 )
683
684-func localIconPath(c snapdClient, ID string) (relativePath string, err error) {
685+func localIconPath(c snapdClient, name string) (relativePath string, err error) {
686 dataPath, relativePath, err := IconDir()
687 if err != nil {
688 return "", err
689 }
690
691- icon, err := c.Icon(ID)
692+ icon, err := c.Icon(name)
693 if err != nil {
694 return "", ErrIconNotExist
695 }
696
697- baseIcon := fmt.Sprintf("%s_%s", ID, icon.Filename)
698+ baseIcon := fmt.Sprintf("%s_%s", name, icon.Filename)
699
700 relativePath = filepath.Join(relativePath, baseIcon)
701 iconDstPath := filepath.Join(dataPath, baseIcon)
702@@ -67,7 +67,7 @@
703
704 // IconDir returns information to properly serve package icons with an http.FileServer
705 func IconDir() (dataPath, relativeBasePath string, err error) {
706- dataPath = os.Getenv("SNAP_APP_DATA_PATH")
707+ dataPath = os.Getenv("SNAP_DATA")
708 if dataPath == "" {
709 return "", "", ErrDataPathNotSet
710 }
711
712=== modified file 'snappy/icon_test.go'
713--- snappy/icon_test.go 2016-01-27 14:16:35 +0000
714+++ snappy/icon_test.go 2016-04-26 10:36:16 +0000
715@@ -36,7 +36,7 @@
716
717 func (s *IconSuite) SetUpTest(c *C) {
718 s.dataPath = c.MkDir()
719- os.Setenv("SNAP_APP_DATA_PATH", s.dataPath)
720+ os.Setenv("SNAP_DATA", s.dataPath)
721 }
722
723 func (s *IconSuite) TestIconDir(c *C) {
724@@ -47,7 +47,7 @@
725 }
726
727 func (s *IconSuite) TestNoSnapAppDataPathCausesError(c *C) {
728- os.Setenv("SNAP_APP_DATA_PATH", "")
729+ os.Setenv("SNAP_DATA", "")
730 _, _, err := IconDir()
731 c.Assert(err, Equals, ErrDataPathNotSet)
732 }
733@@ -55,7 +55,7 @@
734 func (s *IconSuite) TestIconDirCreateFails(c *C) {
735 fileAsDir := filepath.Join(s.dataPath, "badDataPath")
736 c.Assert(ioutil.WriteFile(fileAsDir, []byte{}, 0644), IsNil)
737- os.Setenv("SNAP_APP_DATA_PATH", fileAsDir)
738+ os.Setenv("SNAP_DATA", fileAsDir)
739 _, _, err := IconDir()
740 c.Assert(err, Equals, ErrOnIconDataPathSet)
741 }
742@@ -66,7 +66,7 @@
743 err error
744 }
745
746-func (s *IconPathSuite) Icon(pkgID string) (*client.Icon, error) {
747+func (s *IconPathSuite) Icon(name string) (*client.Icon, error) {
748 icon := &client.Icon{
749 Filename: "pkgIcon.png",
750 Content: []byte("png"),
751@@ -78,14 +78,14 @@
752
753 func (s *IconPathSuite) SetUpTest(c *C) {
754 s.dataPath = c.MkDir()
755- os.Setenv("SNAP_APP_DATA_PATH", s.dataPath)
756+ os.Setenv("SNAP_DATA", s.dataPath)
757 s.err = nil
758 }
759
760 func (s *IconPathSuite) TestIconCopy(c *C) {
761- relativePath, err := localIconPath(s, "mypackage.sergiusens")
762+ relativePath, err := localIconPath(s, "mypackage")
763 c.Assert(err, IsNil)
764- iconBaseName := "icons/mypackage.sergiusens_pkgIcon.png"
765+ iconBaseName := "icons/mypackage_pkgIcon.png"
766 c.Check(relativePath, Equals, filepath.Join("/", iconBaseName))
767
768 contents, err := ioutil.ReadFile(filepath.Join(s.dataPath, iconBaseName))
769@@ -95,23 +95,23 @@
770 }
771
772 func (s *IconPathSuite) TestIconCopyNoDataPath(c *C) {
773- os.Setenv("SNAP_APP_DATA_PATH", "")
774- _, err := localIconPath(s, "mypackage.sergiusens")
775+ os.Setenv("SNAP_DATA", "")
776+ _, err := localIconPath(s, "mypackage")
777 c.Assert(err, Equals, ErrDataPathNotSet)
778 }
779
780 func (s *IconPathSuite) TestIconCopyNoIcon(c *C) {
781 s.err = errors.New("Not Found")
782- _, err := localIconPath(s, "mypackage.sergiusens")
783+ _, err := localIconPath(s, "mypackage")
784 c.Assert(err, Equals, ErrIconNotExist)
785 }
786
787 func (s *IconPathSuite) TestIconCopyTargetIconExists(c *C) {
788- iconBaseName := "icons/mypackage.sergiusens_pkgIcon.png"
789+ iconBaseName := "icons/mypackage_pkgIcon.png"
790 c.Assert(os.MkdirAll(filepath.Join(s.dataPath, "icons"), 0755), IsNil)
791 c.Assert(ioutil.WriteFile(filepath.Join(s.dataPath, iconBaseName), []byte{}, 0644), IsNil)
792
793- relativePath, err := localIconPath(s, "mypackage.sergiusens")
794+ relativePath, err := localIconPath(s, "mypackage")
795 c.Assert(err, IsNil)
796 c.Check(relativePath, Equals, filepath.Join("/", iconBaseName))
797 }
798
799=== modified file 'snappy/snapd_client.go'
800--- snappy/snapd_client.go 2016-04-21 04:33:37 +0000
801+++ snappy/snapd_client.go 2016-04-26 10:36:16 +0000
802@@ -22,10 +22,9 @@
803 )
804
805 type snapdClient interface {
806- Icon(pkgID string) (*client.Icon, error)
807- Services(pkg string) (map[string]*client.Service, error)
808- Snap(name string) (*client.Snap, error)
809- FilterSnaps(filter client.SnapFilter) (map[string]*client.Snap, error)
810- AddSnap(name string) (string, error)
811- RemoveSnap(name string) (string, error)
812+ Icon(name string) (*client.Icon, error)
813+ Snap(name string) (*client.Snap, *client.ResultInfo, error)
814+ FilterSnaps(filter client.SnapFilter) ([]*client.Snap, *client.ResultInfo, error)
815+ Install(name string, options *client.SnapOptions) (string, error)
816+ Remove(name string, options *client.SnapOptions) (string, error)
817 }
818
819=== modified file 'statustracker/statustracker.go'
820--- statustracker/statustracker.go 2016-03-08 18:30:49 +0000
821+++ statustracker/statustracker.go 2016-04-26 10:36:16 +0000
822@@ -62,13 +62,13 @@
823 s.Lock()
824 defer s.Unlock()
825
826- status, ok := s.statuses[snapID(snap)]
827+ status, ok := s.statuses[snap.Name]
828 if !ok {
829 return translateStatus(snap)
830 }
831
832 if hasCompleted(status, snap) {
833- delete(s.statuses, snapID(snap))
834+ delete(s.statuses, snap.Name)
835 return translateStatus(snap)
836 }
837
838@@ -81,19 +81,19 @@
839 return
840 }
841
842- s.trackOperation(snapID(snap), StatusInstalling)
843+ s.trackOperation(snap.Name, StatusInstalling)
844 }
845
846-func (s *StatusTracker) trackOperation(id, operation string) {
847+func (s *StatusTracker) trackOperation(name, operation string) {
848 s.Lock()
849 defer s.Unlock()
850
851- s.statuses[id] = operation
852+ s.statuses[name] = operation
853
854 go func() {
855 <-time.After(trackerDuration)
856 s.Lock()
857- delete(s.statuses, id)
858+ delete(s.statuses, name)
859 s.Unlock()
860 }()
861 }
862@@ -104,11 +104,7 @@
863 return
864 }
865
866- s.trackOperation(snapID(snap), StatusUninstalling)
867-}
868-
869-func snapID(s *client.Snap) string {
870- return s.Name + "." + s.Origin
871+ s.trackOperation(snap.Name, StatusUninstalling)
872 }
873
874 func isInstalled(s *client.Snap) bool {
875
876=== modified file 'statustracker/statustracker_test.go'
877--- statustracker/statustracker_test.go 2016-04-21 06:03:28 +0000
878+++ statustracker/statustracker_test.go 2016-04-26 10:36:16 +0000
879@@ -45,7 +45,7 @@
880 }{
881 {client.StatusInstalled, StatusInstalled},
882 {client.StatusActive, StatusInstalled},
883- {client.StatusNotInstalled, StatusUninstalled},
884+ {client.StatusAvailable, StatusUninstalled},
885 {client.StatusRemoved, StatusUninstalled},
886 }
887
888@@ -85,7 +85,7 @@
889 }
890
891 func (s *StatusTrackerSuite) TestTrackInstall(c *C) {
892- snap := &client.Snap{Status: client.StatusNotInstalled}
893+ snap := &client.Snap{Status: client.StatusAvailable}
894 s.t.TrackInstall(snap)
895 c.Assert(s.t.Status(snap), Equals, StatusInstalling)
896 // installation completes
897@@ -96,7 +96,7 @@
898 func (s *StatusTrackerSuite) TestTrackInstallExpiry(c *C) {
899 trackerDuration = 200 * time.Millisecond
900
901- snap := &client.Snap{Status: client.StatusNotInstalled}
902+ snap := &client.Snap{Status: client.StatusAvailable}
903 s.t.TrackInstall(snap)
904 c.Assert(s.t.Status(snap), Equals, StatusInstalling)
905
906@@ -106,7 +106,7 @@
907 }
908
909 func (s *StatusTrackerSuite) TestTrackUninstallNotInstalled(c *C) {
910- snap := &client.Snap{Status: client.StatusNotInstalled}
911+ snap := &client.Snap{Status: client.StatusAvailable}
912 s.t.TrackUninstall(snap)
913 c.Assert(s.t.Status(snap), Equals, StatusUninstalled)
914 }
915
916=== modified file 'www/src/css/snaplist.css'
917--- www/src/css/snaplist.css 2015-12-11 15:07:16 +0000
918+++ www/src/css/snaplist.css 2016-04-26 10:36:16 +0000
919@@ -62,7 +62,7 @@
920
921 .b-snaplist_grid .b-snaplist__version,
922 .b-snaplist_grid .b-snaplist__type,
923-.b-snaplist_grid .b-snaplist__origin,
924+.b-snaplist_grid .b-snaplist__developer,
925 .b-snaplist_grid .b-snaplist__actions {
926 display:none;
927 }
928@@ -114,7 +114,7 @@
929
930 .b-snaplist_row .b-snaplist__name,
931 .b-snaplist_row .b-snaplist__version,
932-.b-snaplist_row .b-snaplist__origin,
933+.b-snaplist_row .b-snaplist__developer,
934 .b-snaplist_row .b-snaplist__size {
935 white-space: nowrap;
936 width: 100%;
937@@ -142,8 +142,8 @@
938 display:none;
939 }
940
941-.b-snaplist_row .b-snaplist__origin
942-.b-snaplist_row .b-snaplist__origin {
943+.b-snaplist_row .b-snaplist__developer
944+.b-snaplist_row .b-snaplist__developer {
945 text-transform: capitalize;
946 }
947
948
949=== modified file 'www/src/js/config.js'
950--- www/src/js/config.js 2016-01-27 14:16:35 +0000
951+++ www/src/js/config.js 2016-04-26 10:36:16 +0000
952@@ -7,7 +7,7 @@
953 ],
954 NON_INSTALLABLE_IDS: [
955 'webdm',
956- 'ubuntu-core.ubuntu'
957+ 'ubuntu-core'
958 ],
959 NON_INSTALLABLE_TYPES: [
960 'gadget'
961
962=== modified file 'www/src/js/models/snap.js'
963--- www/src/js/models/snap.js 2015-06-03 11:45:59 +0000
964+++ www/src/js/models/snap.js 2016-04-26 10:36:16 +0000
965@@ -166,8 +166,8 @@
966 response.icon = this.defaults.icon;
967 }
968
969- if (response.hasOwnProperty('origin') && !response.origin.length) {
970- response.origin = this.defaults.origin;
971+ if (response.hasOwnProperty('developer') && !response.developer.length) {
972+ response.developer = this.defaults.developer;
973 }
974
975 if (type) {
976@@ -200,28 +200,13 @@
977 );
978 }
979
980- if (response.hasOwnProperty('ui_port')) {
981- //jscs:disable requireCamelCaseOrUpperCaseIdentifiers
982- var port = response.ui_port;
983- //jscs:enable requireCamelCaseOrUpperCaseIdentifiers
984-
985- if (_.isFinite(port) && port > 0) {
986-
987- this.set('vendorGuiHref', window.location.protocol + '//' +
988- window.location.hostname + ':' + port + '/'
989- );
990- } else {
991- this.unset('vendorGuiHref');
992- }
993- }
994-
995 return response;
996 },
997
998 defaults: {
999 icon: '/public/images/default-package-icon.svg',
1000 installActionString: false,
1001- origin: '-',
1002+ developer: '-',
1003 isInstallable: true
1004 }
1005
1006
1007=== modified file 'www/src/js/templates/snap-menu.hbs'
1008--- www/src/js/templates/snap-menu.hbs 2015-06-03 11:33:11 +0000
1009+++ www/src/js/templates/snap-menu.hbs 2016-04-26 10:36:16 +0000
1010@@ -8,9 +8,4 @@
1011 <a class="b-snap__nav-item" href="settings">
1012 Settings
1013 </a>
1014- {{#if vendorGuiHref}}
1015- <a class="b-snap__nav-item" href="{{vendorGuiHref}}" target="_blank">
1016- Open / Manage
1017- </a>
1018- {{/if}}
1019 </div>
1020
1021=== modified file 'www/src/js/templates/snaplist-item.hbs'
1022--- www/src/js/templates/snaplist-item.hbs 2015-12-11 15:07:16 +0000
1023+++ www/src/js/templates/snaplist-item.hbs 2016-04-26 10:36:16 +0000
1024@@ -6,7 +6,7 @@
1025 <div class="b-snaplist__version">{{ version }}</div>
1026 </div>
1027 <div class="b-snaplist__src">
1028- <div class="b-snaplist__origin">{{ origin }}</div>
1029+ <div class="b-snaplist__developer">{{ developer }}</div>
1030 </div>
1031 <div class="b-snaplist__size" title="Installed file size">{{ prettyInstalledSize }}</div>
1032 <div class="b-snaplist__actions">
1033
1034=== modified file 'www/src/js/templates/storelist-item.hbs'
1035--- www/src/js/templates/storelist-item.hbs 2015-12-11 15:07:16 +0000
1036+++ www/src/js/templates/storelist-item.hbs 2016-04-26 10:36:16 +0000
1037@@ -6,7 +6,7 @@
1038 <div class="b-snaplist__version">{{ version }}</div>
1039 </div>
1040 <div class="b-snaplist__src">
1041- <div class="b-snaplist__origin">{{ origin }}</div>
1042+ <div class="b-snaplist__developer">{{ developer }}</div>
1043 </div>
1044 <div class="b-snaplist__actions">
1045 {{> installer}}
1046
1047=== modified file 'www/tests/modelSpec.js'
1048--- www/tests/modelSpec.js 2015-06-03 11:45:59 +0000
1049+++ www/tests/modelSpec.js 2016-04-26 10:36:16 +0000
1050@@ -88,20 +88,6 @@
1051 expect(this.model.get('prettyDownloadSize')).toBe('0 B');
1052 });
1053
1054- it('should parse response to create vendorGuiHref', function() {
1055- this.model.parse({'ui_port': 8080});
1056- expect(this.model.get('vendorGuiHref')).toBe('http://localhost:8080/');
1057- });
1058-
1059- it('should not set vendorGuiHref if not a finite number', function() {
1060- this.model.parse({'ui_port': NaN});
1061- expect(this.model.get('vendorGuiHref')).not.toBeDefined();
1062- this.model.parse({'ui_port': ''});
1063- expect(this.model.get('vendorGuiHref')).not.toBeDefined();
1064- this.model.parse({'ui_port': -9});
1065- expect(this.model.get('vendorGuiHref')).not.toBeDefined();
1066- });
1067-
1068 });
1069
1070 describe('sync methods', function() {

Subscribers

People subscribed via source and target branches