Merge lp:~sergiusens/goget-ubuntu-touch/catchupToInstall into lp:goget-ubuntu-touch

Proposed by Sergio Schvezov
Status: Merged
Approved by: Sergio Schvezov
Approved revision: 162
Merged at revision: 161
Proposed branch: lp:~sergiusens/goget-ubuntu-touch/catchupToInstall
Merge into: lp:goget-ubuntu-touch
Prerequisite: lp:~sergiusens/goget-ubuntu-touch/polishit
Diff against target: 146 lines (+90/-5)
4 files modified
diskimage/common.go (+12/-2)
diskimage/common_test.go (+62/-0)
diskimage/core_uboot.go (+6/-1)
ubuntu-device-flash/core.go (+10/-2)
To merge this branch: bzr merge lp:~sergiusens/goget-ubuntu-touch/catchupToInstall
Reviewer Review Type Date Requested Status
Sergio Schvezov Approve
John Lenton (community) Approve
Review via email: mp+256602@code.launchpad.net

Commit message

Update to the sideload bandwagon

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'diskimage/common.go'
2--- diskimage/common.go 2015-04-16 22:59:21 +0000
3+++ diskimage/common.go 2015-04-16 22:59:21 +0000
4@@ -8,6 +8,7 @@
5 package diskimage
6
7 import (
8+ "errors"
9 "fmt"
10 "io/ioutil"
11 "os"
12@@ -108,8 +109,17 @@
13 Config map[string]interface{} `yaml:"config,omitempty"`
14 }
15
16-func (o OemDescription) InstallPath() string {
17- return filepath.Join("/oem", o.Name, o.Version)
18+func (o OemDescription) InstallPath(rootPath string) (string, error) {
19+ glob, err := filepath.Glob(fmt.Sprintf("/%s/oem/%s.*/%s", rootPath, o.Name, o.Version))
20+ if err != nil {
21+ return "", err
22+ }
23+
24+ if len(glob) != 1 {
25+ return "", errors.New("oem package not installed")
26+ }
27+
28+ return glob[0], nil
29 }
30
31 func (o OemDescription) Architecture() string {
32
33=== added file 'diskimage/common_test.go'
34--- diskimage/common_test.go 1970-01-01 00:00:00 +0000
35+++ diskimage/common_test.go 2015-04-16 22:59:21 +0000
36@@ -0,0 +1,62 @@
37+//
38+// diskimage - handles ubuntu disk images
39+//
40+// Copyright (c) 2015 Canonical Ltd.
41+//
42+// Written by Sergio Schvezov <sergio.schvezov@canonical.com>
43+//
44+package diskimage
45+
46+// This program is free software: you can redistribute it and/or modify it
47+// under the terms of the GNU General Public License version 3, as published
48+// by the Free Software Foundation.
49+//
50+// This program is distributed in the hope that it will be useful, but
51+// WITHOUT ANY WARRANTY; without even the implied warranties of
52+// MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
53+// PURPOSE. See the GNU General Public License for more details.
54+//
55+// You should have received a copy of the GNU General Public License along
56+// with this program. If not, see <http://www.gnu.org/licenses/>.
57+
58+import (
59+ "fmt"
60+ "os"
61+ "path/filepath"
62+
63+ . "launchpad.net/gocheck"
64+)
65+
66+type CommonTestSuite struct {
67+ tmpdir string
68+ oem OemDescription
69+ packageInst string
70+}
71+
72+var _ = Suite(&CommonTestSuite{})
73+
74+func (s *CommonTestSuite) SetUpTest(c *C) {
75+ s.tmpdir = c.MkDir()
76+ s.oem = OemDescription{Name: "packagename", Version: "42"}
77+ s.packageInst = fmt.Sprintf("%s.%s", s.oem.Name, "sideload")
78+}
79+
80+func (s *CommonTestSuite) TestOemInstallPath(c *C) {
81+ err := os.MkdirAll(filepath.Join(s.tmpdir, "oem", s.packageInst, s.oem.Version), 0755)
82+ c.Assert(err, IsNil)
83+
84+ installPath, err := s.oem.InstallPath(s.tmpdir)
85+
86+ c.Assert(err, IsNil)
87+ c.Assert(installPath, Equals, filepath.Join(s.tmpdir, "/oem/packagename.sideload/42"))
88+}
89+
90+func (s *CommonTestSuite) TestOemInstallPathNoOem(c *C) {
91+ err := os.MkdirAll(filepath.Join(s.tmpdir, "oem", s.packageInst), 0755)
92+ c.Assert(err, IsNil)
93+
94+ installPath, err := s.oem.InstallPath(s.tmpdir)
95+
96+ c.Assert(err, NotNil)
97+ c.Assert(installPath, Equals, "")
98+}
99
100=== modified file 'diskimage/core_uboot.go'
101--- diskimage/core_uboot.go 2015-04-01 19:07:26 +0000
102+++ diskimage/core_uboot.go 2015-04-16 22:59:21 +0000
103@@ -404,7 +404,12 @@
104 // if there is a specific dtb for the platform, copy it.
105 // First look in oem and then in device.
106 if oemDtb := img.oem.OEM.Hardware.Dtb; oemDtb != "" && img.oem.Platform() != "" {
107- oemDtb := filepath.Join(img.System(), img.oem.InstallPath(), oemDtb)
108+ oemInstallPath, err := img.oem.InstallPath(img.System())
109+ if err != nil {
110+ return err
111+ }
112+
113+ oemDtb := filepath.Join(oemInstallPath, oemDtb)
114 dst := filepath.Join(bootDtbPath, filepath.Base(dtb))
115 if err := sysutils.CopyFile(oemDtb, dst); err != nil {
116 return err
117
118=== modified file 'ubuntu-device-flash/core.go'
119--- ubuntu-device-flash/core.go 2015-04-16 22:59:21 +0000
120+++ ubuntu-device-flash/core.go 2015-04-16 22:59:21 +0000
121@@ -285,7 +285,11 @@
122 return err
123 }
124
125- oemRootPath := filepath.Join(coreCmd.stagingRootPath, coreCmd.oem.InstallPath())
126+ oemRootPath, err := coreCmd.oem.InstallPath(coreCmd.stagingRootPath)
127+ if err != nil {
128+ return err
129+ }
130+
131 if err := img.FlashExtra(oemRootPath, devicePart); err != nil {
132 return err
133 }
134@@ -361,7 +365,11 @@
135 return err
136 }
137
138- oemRootPath := filepath.Join(coreCmd.stagingRootPath, coreCmd.oem.InstallPath())
139+ oemRootPath, err := coreCmd.oem.InstallPath(coreCmd.stagingRootPath)
140+ if err != nil {
141+ return err
142+ }
143+
144 if err := img.SetupBoot(oemRootPath); err != nil {
145 return err
146 }

Subscribers

People subscribed via source and target branches