Merge lp:~sergiusens/snapweb/oemBrokeFix into lp:~snappy-dev/snapweb/trunk

Proposed by Sergio Schvezov
Status: Merged
Approved by: John Lenton
Approved revision: 139
Merged at revision: 139
Proposed branch: lp:~sergiusens/snapweb/oemBrokeFix
Merge into: lp:~snappy-dev/snapweb/trunk
Diff against target: 121 lines (+23/-53)
4 files modified
cmd/snappyd/handlers.go (+0/-1)
oem/handlers.go (+0/-35)
oem/oem.go (+22/-16)
pkg/meta/package.yaml (+1/-1)
To merge this branch: bzr merge lp:~sergiusens/snapweb/oemBrokeFix
Reviewer Review Type Date Requested Status
John Lenton (community) Approve
Review via email: mp+258681@code.launchpad.net

Commit message

Fix broken oem package detection (removing more code along the way).

To post a comment you must log in.
Revision history for this message
John Lenton (chipaca) :
review: Approve

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 2015-05-03 20:42:50 +0000
3+++ cmd/snappyd/handlers.go 2015-05-08 19:24:12 +0000
4@@ -86,7 +86,6 @@
5 if err != nil && err != oem.ErrNotFound {
6 return f, err
7 } else if err != oem.ErrNotFound {
8- fmt.Println(pkg)
9 name = pkg.Branding.Name
10 subname = pkg.Branding.Subname
11 }
12
13=== removed file 'oem/handlers.go'
14--- oem/handlers.go 2015-05-03 20:41:25 +0000
15+++ oem/handlers.go 1970-01-01 00:00:00 +0000
16@@ -1,35 +0,0 @@
17-/*
18- * Copyright (C) 2014-2015 Canonical Ltd
19- *
20- * This program is free software: you can redistribute it and/or modify
21- * it under the terms of the GNU General Public License version 3 as
22- * published by the Free Software Foundation.
23- *
24- * This program is distributed in the hope that it will be useful,
25- * but WITHOUT ANY WARRANTY; without even the implied warranty of
26- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27- * GNU General Public License for more details.
28- *
29- * You should have received a copy of the GNU General Public License
30- * along with this program. If not, see <http://www.gnu.org/licenses/>.
31- *
32- */
33-
34-package oem
35-
36-import (
37- "os"
38- "path/filepath"
39-)
40-
41-func glob(dir string, filename string) (pkgs []string, err error) {
42- err = filepath.Walk(dir, func(path string, f os.FileInfo, err error) error {
43- if filepath.Base(path) == filename {
44- pkgs = append(pkgs, path)
45- }
46-
47- return nil
48- })
49-
50- return pkgs, err
51-}
52
53=== modified file 'oem/oem.go'
54--- oem/oem.go 2015-05-03 20:41:25 +0000
55+++ oem/oem.go 2015-05-08 19:24:12 +0000
56@@ -20,6 +20,9 @@
57 import (
58 "errors"
59 "io/ioutil"
60+ "path/filepath"
61+
62+ "launchpad.net/snappy/snappy"
63
64 "gopkg.in/yaml.v2"
65 )
66@@ -52,23 +55,26 @@
67 var ErrDecode = errors.New("decoding problem")
68
69 // Oem returns an oem package
70-func Oem() (pkg Snap, err error) {
71- pkgs, err := glob("/oem/", "package.yaml")
72-
73- if len(pkgs) == 0 {
74- return pkg, ErrNotFound
75- } else if len(pkgs) > 1 || err != nil {
76- return pkg, ErrTooMany
77- }
78-
79- f, err := ioutil.ReadFile(pkgs[0])
80- if err != nil {
81- return pkg, ErrDecode
82- }
83-
84+func Oem() (*Snap, error) {
85+ oem, err := snappy.ActiveSnapsByType(snappy.SnapTypeOem)
86+ if err != nil {
87+ return nil, err
88+ } else if len(oem) > 1 {
89+ return nil, ErrTooMany
90+ } else if len(oem) == 0 {
91+ return nil, ErrNotFound
92+ }
93+
94+ yamlPath := filepath.Join("/oem", oem[0].Name(), oem[0].Version(), "meta", "package.yaml")
95+ f, err := ioutil.ReadFile(yamlPath)
96+ if err != nil {
97+ return nil, ErrDecode
98+ }
99+
100+ var pkg Snap
101 if err := yaml.Unmarshal([]byte(f), &pkg); err != nil {
102- return pkg, ErrDecode
103+ return nil, ErrDecode
104 }
105
106- return pkg, nil
107+ return &pkg, nil
108 }
109
110=== modified file 'pkg/meta/package.yaml'
111--- pkg/meta/package.yaml 2015-05-07 21:53:39 +0000
112+++ pkg/meta/package.yaml 2015-05-08 19:24:12 +0000
113@@ -3,7 +3,7 @@
114 icon: meta/webdm-icon.png
115 source: lp:webdm
116 type: framework
117-version: 0.6
118+version: 0.6.1
119 architecture: UNKNOWN_ARCH
120 services:
121 - name: snappyd

Subscribers

People subscribed via source and target branches