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
=== modified file 'cmd/snappyd/handlers.go'
--- cmd/snappyd/handlers.go 2015-05-03 20:42:50 +0000
+++ cmd/snappyd/handlers.go 2015-05-08 19:24:12 +0000
@@ -86,7 +86,6 @@
86 if err != nil && err != oem.ErrNotFound {86 if err != nil && err != oem.ErrNotFound {
87 return f, err87 return f, err
88 } else if err != oem.ErrNotFound {88 } else if err != oem.ErrNotFound {
89 fmt.Println(pkg)
90 name = pkg.Branding.Name89 name = pkg.Branding.Name
91 subname = pkg.Branding.Subname90 subname = pkg.Branding.Subname
92 }91 }
9392
=== removed file 'oem/handlers.go'
--- oem/handlers.go 2015-05-03 20:41:25 +0000
+++ oem/handlers.go 1970-01-01 00:00:00 +0000
@@ -1,35 +0,0 @@
1/*
2 * Copyright (C) 2014-2015 Canonical Ltd
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 3 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18package oem
19
20import (
21 "os"
22 "path/filepath"
23)
24
25func glob(dir string, filename string) (pkgs []string, err error) {
26 err = filepath.Walk(dir, func(path string, f os.FileInfo, err error) error {
27 if filepath.Base(path) == filename {
28 pkgs = append(pkgs, path)
29 }
30
31 return nil
32 })
33
34 return pkgs, err
35}
360
=== modified file 'oem/oem.go'
--- oem/oem.go 2015-05-03 20:41:25 +0000
+++ oem/oem.go 2015-05-08 19:24:12 +0000
@@ -20,6 +20,9 @@
20import (20import (
21 "errors"21 "errors"
22 "io/ioutil"22 "io/ioutil"
23 "path/filepath"
24
25 "launchpad.net/snappy/snappy"
2326
24 "gopkg.in/yaml.v2"27 "gopkg.in/yaml.v2"
25)28)
@@ -52,23 +55,26 @@
52var ErrDecode = errors.New("decoding problem")55var ErrDecode = errors.New("decoding problem")
5356
54// Oem returns an oem package57// Oem returns an oem package
55func Oem() (pkg Snap, err error) {58func Oem() (*Snap, error) {
56 pkgs, err := glob("/oem/", "package.yaml")59 oem, err := snappy.ActiveSnapsByType(snappy.SnapTypeOem)
5760 if err != nil {
58 if len(pkgs) == 0 {61 return nil, err
59 return pkg, ErrNotFound62 } else if len(oem) > 1 {
60 } else if len(pkgs) > 1 || err != nil {63 return nil, ErrTooMany
61 return pkg, ErrTooMany64 } else if len(oem) == 0 {
62 }65 return nil, ErrNotFound
6366 }
64 f, err := ioutil.ReadFile(pkgs[0])67
65 if err != nil {68 yamlPath := filepath.Join("/oem", oem[0].Name(), oem[0].Version(), "meta", "package.yaml")
66 return pkg, ErrDecode69 f, err := ioutil.ReadFile(yamlPath)
67 }70 if err != nil {
6871 return nil, ErrDecode
72 }
73
74 var pkg Snap
69 if err := yaml.Unmarshal([]byte(f), &pkg); err != nil {75 if err := yaml.Unmarshal([]byte(f), &pkg); err != nil {
70 return pkg, ErrDecode76 return nil, ErrDecode
71 }77 }
7278
73 return pkg, nil79 return &pkg, nil
74}80}
7581
=== modified file 'pkg/meta/package.yaml'
--- pkg/meta/package.yaml 2015-05-07 21:53:39 +0000
+++ pkg/meta/package.yaml 2015-05-08 19:24:12 +0000
@@ -3,7 +3,7 @@
3icon: meta/webdm-icon.png3icon: meta/webdm-icon.png
4source: lp:webdm4source: lp:webdm
5type: framework5type: framework
6version: 0.66version: 0.6.1
7architecture: UNKNOWN_ARCH7architecture: UNKNOWN_ARCH
8services:8services:
9 - name: snappyd9 - name: snappyd

Subscribers

People subscribed via source and target branches