Merge lp:~sergiusens/snappy/lockDownRemove into lp:~snappy-dev/snappy/snappy-moved-to-github
- lockDownRemove
- Merge into snappy-moved-to-github
Proposed by
Sergio Schvezov
Status: | Merged |
---|---|
Approved by: | John Lenton |
Approved revision: | no longer in the source branch. |
Merged at revision: | 398 |
Proposed branch: | lp:~sergiusens/snappy/lockDownRemove |
Merge into: | lp:~snappy-dev/snappy/snappy-moved-to-github |
Diff against target: |
496 lines (+298/-123) 4 files modified
snappy/oem.go (+197/-0) snappy/oem_test.go (+59/-0) snappy/snapp.go (+9/-121) snappy/snapp_test.go (+33/-2) |
To merge this branch: | bzr merge lp:~sergiusens/snappy/lockDownRemove |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
John Lenton (community) | Approve | ||
Review via email: mp+256849@code.launchpad.net |
Commit message
Moving oem related tasks to an oem.go unit and adding support for Uninstall prevention of builtins.
Description of the change
This will need a remerge of mvo's changes, but wanted to get the general idea.
To post a comment you must log in.
Revision history for this message
John Lenton (chipaca) : | # |
review:
Approve
Revision history for this message
Snappy Tarmac (snappydevtarmac) wrote : | # |
Revision history for this message
John Lenton (chipaca) : | # |
review:
Approve
- 398. By Sergio Schvezov
-
Moving oem related tasks to an oem.go unit and adding support for Uninstall prevention of builtins. by sergiusens approved by chipaca
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added file 'snappy/oem.go' | |||
2 | --- snappy/oem.go 1970-01-01 00:00:00 +0000 | |||
3 | +++ snappy/oem.go 2015-04-20 23:57:04 +0000 | |||
4 | @@ -0,0 +1,197 @@ | |||
5 | 1 | /* | ||
6 | 2 | * Copyright (C) 2014-2015 Canonical Ltd | ||
7 | 3 | * | ||
8 | 4 | * This program is free software: you can redistribute it and/or modify | ||
9 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
10 | 6 | * published by the Free Software Foundation. | ||
11 | 7 | * | ||
12 | 8 | * This program is distributed in the hope that it will be useful, | ||
13 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | 11 | * GNU General Public License for more details. | ||
16 | 12 | * | ||
17 | 13 | * You should have received a copy of the GNU General Public License | ||
18 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | 15 | * | ||
20 | 16 | */ | ||
21 | 17 | |||
22 | 18 | // TODO this should be it's own package, but depends on splitting out | ||
23 | 19 | // package.yaml's | ||
24 | 20 | |||
25 | 21 | package snappy | ||
26 | 22 | |||
27 | 23 | import ( | ||
28 | 24 | "errors" | ||
29 | 25 | "fmt" | ||
30 | 26 | "io/ioutil" | ||
31 | 27 | "os" | ||
32 | 28 | "os/exec" | ||
33 | 29 | "path/filepath" | ||
34 | 30 | "strings" | ||
35 | 31 | ) | ||
36 | 32 | |||
37 | 33 | // OEM represents the structure inside the package.yaml for the oem component | ||
38 | 34 | // of an oem package type. | ||
39 | 35 | type OEM struct { | ||
40 | 36 | Store Store `yaml:"store,omitempty"` | ||
41 | 37 | Hardware struct { | ||
42 | 38 | Assign []HardwareAssign `yaml:"assign,omitempty"` | ||
43 | 39 | } `yaml:"hardware,omitempty"` | ||
44 | 40 | Software Software `yaml:"software,omitempty"` | ||
45 | 41 | } | ||
46 | 42 | |||
47 | 43 | // Store holds information relevant to the store provided by an OEM snap | ||
48 | 44 | type Store struct { | ||
49 | 45 | ID string `yaml:"id,omitempty"` | ||
50 | 46 | } | ||
51 | 47 | |||
52 | 48 | // Software describes the installed software provided by an OEM snap | ||
53 | 49 | type Software struct { | ||
54 | 50 | BuiltIn []string `yaml:"built-in,omitempty"` | ||
55 | 51 | } | ||
56 | 52 | |||
57 | 53 | // HardwareAssign describes the hardware a app can use | ||
58 | 54 | type HardwareAssign struct { | ||
59 | 55 | PartID string `yaml:"part-id,omitempty"` | ||
60 | 56 | Rules []struct { | ||
61 | 57 | Kernel string `yaml:"kernel,omitempty"` | ||
62 | 58 | Subsystem string `yaml:"subsystem,omitempty"` | ||
63 | 59 | WithSubsystems string `yaml:"with-subsystems,omitempty"` | ||
64 | 60 | WithDriver string `yaml:"with-driver,omitempty"` | ||
65 | 61 | WithAttrs []string `yaml:"with-attrs,omitempty"` | ||
66 | 62 | WithProps []string `yaml:"with-props,omitempty"` | ||
67 | 63 | } `yaml:"rules,omitempty"` | ||
68 | 64 | } | ||
69 | 65 | |||
70 | 66 | func (hw *HardwareAssign) generateUdevRuleContent() (string, error) { | ||
71 | 67 | s := "" | ||
72 | 68 | for _, r := range hw.Rules { | ||
73 | 69 | if r.Kernel != "" { | ||
74 | 70 | s += fmt.Sprintf(`KERNEL=="%v", `, r.Kernel) | ||
75 | 71 | } | ||
76 | 72 | if r.Subsystem != "" { | ||
77 | 73 | s += fmt.Sprintf(`SUBSYSTEM=="%v", `, r.Subsystem) | ||
78 | 74 | } | ||
79 | 75 | if r.WithSubsystems != "" { | ||
80 | 76 | s += fmt.Sprintf(`SUBSYSTEMS=="%v", `, r.WithSubsystems) | ||
81 | 77 | } | ||
82 | 78 | if r.WithDriver != "" { | ||
83 | 79 | s += fmt.Sprintf(`DRIVER=="%v", `, r.WithDriver) | ||
84 | 80 | } | ||
85 | 81 | for _, a := range r.WithAttrs { | ||
86 | 82 | l := strings.Split(a, "=") | ||
87 | 83 | s += fmt.Sprintf(`ATTRS{%v}=="%v", `, l[0], l[1]) | ||
88 | 84 | } | ||
89 | 85 | for _, a := range r.WithProps { | ||
90 | 86 | l := strings.SplitN(a, "=", 2) | ||
91 | 87 | s += fmt.Sprintf(`ENV{%v}=="%v", `, l[0], l[1]) | ||
92 | 88 | } | ||
93 | 89 | s += fmt.Sprintf(`TAG:="snappy-assign", ENV{SNAPPY_APP}:="%s"`, hw.PartID) | ||
94 | 90 | s += "\n\n" | ||
95 | 91 | } | ||
96 | 92 | |||
97 | 93 | return s, nil | ||
98 | 94 | } | ||
99 | 95 | |||
100 | 96 | // getOem is a convenience function to not go into the details for the business | ||
101 | 97 | // logic for an oem package in every other function | ||
102 | 98 | var getOem = getOemImpl | ||
103 | 99 | |||
104 | 100 | var getOemImpl = func() (*packageYaml, error) { | ||
105 | 101 | oems, _ := ActiveSnapsByType(SnapTypeOem) | ||
106 | 102 | if len(oems) == 1 { | ||
107 | 103 | return oems[0].(*SnapPart).m, nil | ||
108 | 104 | } | ||
109 | 105 | |||
110 | 106 | return nil, errors.New("no oem snap") | ||
111 | 107 | } | ||
112 | 108 | |||
113 | 109 | // StoreID returns the store id setup by the oem package or an empty string | ||
114 | 110 | func StoreID() string { | ||
115 | 111 | oem, err := getOem() | ||
116 | 112 | if err != nil { | ||
117 | 113 | return "" | ||
118 | 114 | } | ||
119 | 115 | |||
120 | 116 | return oem.OEM.Store.ID | ||
121 | 117 | } | ||
122 | 118 | |||
123 | 119 | // IsBuiltInSoftware returns true if the package is part of the built-in software | ||
124 | 120 | // defined by the oem. | ||
125 | 121 | func IsBuiltInSoftware(name string) bool { | ||
126 | 122 | oem, err := getOem() | ||
127 | 123 | if err != nil { | ||
128 | 124 | return false | ||
129 | 125 | } | ||
130 | 126 | |||
131 | 127 | for _, builtin := range oem.OEM.Software.BuiltIn { | ||
132 | 128 | if builtin == name { | ||
133 | 129 | return true | ||
134 | 130 | } | ||
135 | 131 | } | ||
136 | 132 | |||
137 | 133 | return false | ||
138 | 134 | } | ||
139 | 135 | |||
140 | 136 | func cleanupOemHardwareUdevRules(m *packageYaml) error { | ||
141 | 137 | oldFiles, err := filepath.Glob(filepath.Join(snapUdevRulesDir, fmt.Sprintf("80-snappy_%s_*.rules", m.Name))) | ||
142 | 138 | if err != nil { | ||
143 | 139 | return err | ||
144 | 140 | } | ||
145 | 141 | |||
146 | 142 | for _, f := range oldFiles { | ||
147 | 143 | os.Remove(f) | ||
148 | 144 | } | ||
149 | 145 | |||
150 | 146 | return nil | ||
151 | 147 | } | ||
152 | 148 | |||
153 | 149 | func writeOemHardwareUdevRules(m *packageYaml) error { | ||
154 | 150 | // cleanup | ||
155 | 151 | if err := cleanupOemHardwareUdevRules(m); err != nil { | ||
156 | 152 | return err | ||
157 | 153 | } | ||
158 | 154 | // write new files | ||
159 | 155 | for _, h := range m.OEM.Hardware.Assign { | ||
160 | 156 | rulesContent, err := h.generateUdevRuleContent() | ||
161 | 157 | if err != nil { | ||
162 | 158 | return err | ||
163 | 159 | } | ||
164 | 160 | outfile := filepath.Join(snapUdevRulesDir, fmt.Sprintf("80-snappy_%s_%s.rules", m.Name, h.PartID)) | ||
165 | 161 | if err := ioutil.WriteFile(outfile, []byte(rulesContent), 0644); err != nil { | ||
166 | 162 | return err | ||
167 | 163 | } | ||
168 | 164 | } | ||
169 | 165 | |||
170 | 166 | return nil | ||
171 | 167 | } | ||
172 | 168 | |||
173 | 169 | // var to make testing easier | ||
174 | 170 | var runUdevAdm = runUdevAdmImpl | ||
175 | 171 | |||
176 | 172 | func runUdevAdmImpl(args ...string) error { | ||
177 | 173 | cmd := exec.Command(args[0], args[1:]...) | ||
178 | 174 | cmd.Stdout = os.Stdout | ||
179 | 175 | cmd.Stderr = os.Stderr | ||
180 | 176 | return cmd.Run() | ||
181 | 177 | } | ||
182 | 178 | |||
183 | 179 | func activateOemHardwareUdevRules(m *packageYaml) error { | ||
184 | 180 | if err := runUdevAdm("udevadm", "control", "--reload-rules"); err != nil { | ||
185 | 181 | return err | ||
186 | 182 | } | ||
187 | 183 | |||
188 | 184 | return runUdevAdm("udevadm", "trigger") | ||
189 | 185 | } | ||
190 | 186 | |||
191 | 187 | func installOemHardwareUdevRules(m *packageYaml) error { | ||
192 | 188 | if err := writeOemHardwareUdevRules(m); err != nil { | ||
193 | 189 | return err | ||
194 | 190 | } | ||
195 | 191 | |||
196 | 192 | if err := activateOemHardwareUdevRules(m); err != nil { | ||
197 | 193 | return err | ||
198 | 194 | } | ||
199 | 195 | |||
200 | 196 | return nil | ||
201 | 197 | } | ||
202 | 0 | 198 | ||
203 | === added file 'snappy/oem_test.go' | |||
204 | --- snappy/oem_test.go 1970-01-01 00:00:00 +0000 | |||
205 | +++ snappy/oem_test.go 2015-04-20 23:57:04 +0000 | |||
206 | @@ -0,0 +1,59 @@ | |||
207 | 1 | /* | ||
208 | 2 | * Copyright (C) 2014-2015 Canonical Ltd | ||
209 | 3 | * | ||
210 | 4 | * This program is free software: you can redistribute it and/or modify | ||
211 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
212 | 6 | * published by the Free Software Foundation. | ||
213 | 7 | * | ||
214 | 8 | * This program is distributed in the hope that it will be useful, | ||
215 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
216 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
217 | 11 | * GNU General Public License for more details. | ||
218 | 12 | * | ||
219 | 13 | * You should have received a copy of the GNU General Public License | ||
220 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
221 | 15 | * | ||
222 | 16 | */ | ||
223 | 17 | |||
224 | 18 | // TODO this should be it's own package, but depends on splitting out | ||
225 | 19 | // package.yaml's | ||
226 | 20 | |||
227 | 21 | package snappy | ||
228 | 22 | |||
229 | 23 | import ( | ||
230 | 24 | . "launchpad.net/gocheck" | ||
231 | 25 | ) | ||
232 | 26 | |||
233 | 27 | type OemSuite struct { | ||
234 | 28 | } | ||
235 | 29 | |||
236 | 30 | var _ = Suite(&OemSuite{}) | ||
237 | 31 | |||
238 | 32 | var ( | ||
239 | 33 | getOemOrig = getOem | ||
240 | 34 | ) | ||
241 | 35 | |||
242 | 36 | func (s *OemSuite) SetUpTest(c *C) { | ||
243 | 37 | getOem = func() (*packageYaml, error) { | ||
244 | 38 | return &packageYaml{ | ||
245 | 39 | OEM: OEM{ | ||
246 | 40 | Software: Software{[]string{"makeuppackage", "anotherpackage"}}, | ||
247 | 41 | Store: Store{"ninjablocks"}, | ||
248 | 42 | }, | ||
249 | 43 | }, nil | ||
250 | 44 | } | ||
251 | 45 | } | ||
252 | 46 | |||
253 | 47 | func (s *OemSuite) TearDownTest(c *C) { | ||
254 | 48 | getOem = getOemImpl | ||
255 | 49 | } | ||
256 | 50 | |||
257 | 51 | func (s *OemSuite) TestIsBuildIn(c *C) { | ||
258 | 52 | c.Check(IsBuiltInSoftware("notapackage"), Equals, false) | ||
259 | 53 | c.Check(IsBuiltInSoftware("makeuppackage"), Equals, true) | ||
260 | 54 | c.Check(IsBuiltInSoftware("anotherpackage"), Equals, true) | ||
261 | 55 | } | ||
262 | 56 | |||
263 | 57 | func (s *OemSuite) TestStoreID(c *C) { | ||
264 | 58 | c.Assert(StoreID(), Equals, "ninjablocks") | ||
265 | 59 | } | ||
266 | 0 | 60 | ||
267 | === modified file 'snappy/snapp.go' | |||
268 | --- snappy/snapp.go 2015-04-20 16:51:29 +0000 | |||
269 | +++ snappy/snapp.go 2015-04-20 23:57:04 +0000 | |||
270 | @@ -173,6 +173,8 @@ | |||
271 | 173 | 173 | ||
272 | 174 | var commasplitter = regexp.MustCompile(`\s*,\s*`).Split | 174 | var commasplitter = regexp.MustCompile(`\s*,\s*`).Split |
273 | 175 | 175 | ||
274 | 176 | // TODO split into payloads per package type composing the common | ||
275 | 177 | // elements for all snaps. | ||
276 | 176 | type packageYaml struct { | 178 | type packageYaml struct { |
277 | 177 | Name string | 179 | Name string |
278 | 178 | Version string | 180 | Version string |
279 | @@ -192,14 +194,7 @@ | |||
280 | 192 | Binaries []Binary `yaml:"binaries,omitempty"` | 194 | Binaries []Binary `yaml:"binaries,omitempty"` |
281 | 193 | 195 | ||
282 | 194 | // oem snap only | 196 | // oem snap only |
291 | 195 | OEM struct { | 197 | OEM OEM `yaml:"oem,omitempty"` |
284 | 196 | Store struct { | ||
285 | 197 | ID string `yaml:"id,omitempty"` | ||
286 | 198 | } `yaml:"store,omitempty"` | ||
287 | 199 | Hardware struct { | ||
288 | 200 | Assign []HardwareAssign `yaml:"assign,omitempty"` | ||
289 | 201 | } `yaml:"hardware,omitempty"` | ||
290 | 202 | } `yaml:"oem,omitempty"` | ||
292 | 203 | Config SystemConfig `yaml:"config,omitempty"` | 198 | Config SystemConfig `yaml:"config,omitempty"` |
293 | 204 | 199 | ||
294 | 205 | // this is a bit ugly, but right now integration is a one:one | 200 | // this is a bit ugly, but right now integration is a one:one |
295 | @@ -210,19 +205,6 @@ | |||
296 | 210 | LicenseVersion string `yaml:"license-version,omitempty"` | 205 | LicenseVersion string `yaml:"license-version,omitempty"` |
297 | 211 | } | 206 | } |
298 | 212 | 207 | ||
299 | 213 | // HardwareAssign describes the hardware a app can use | ||
300 | 214 | type HardwareAssign struct { | ||
301 | 215 | PartID string `yaml:"part-id,omitempty"` | ||
302 | 216 | Rules []struct { | ||
303 | 217 | Kernel string `yaml:"kernel,omitempty"` | ||
304 | 218 | Subsystem string `yaml:"subsystem,omitempty"` | ||
305 | 219 | WithSubsystems string `yaml:"with-subsystems,omitempty"` | ||
306 | 220 | WithDriver string `yaml:"with-driver,omitempty"` | ||
307 | 221 | WithAttrs []string `yaml:"with-attrs,omitempty"` | ||
308 | 222 | WithProps []string `yaml:"with-props,omitempty"` | ||
309 | 223 | } `yaml:"rules,omitempty"` | ||
310 | 224 | } | ||
311 | 225 | |||
312 | 226 | type remoteSnap struct { | 208 | type remoteSnap struct { |
313 | 227 | Alias string `json:"alias,omitempty"` | 209 | Alias string `json:"alias,omitempty"` |
314 | 228 | AnonDownloadURL string `json:"anon_download_url,omitempty"` | 210 | AnonDownloadURL string `json:"anon_download_url,omitempty"` |
315 | @@ -248,99 +230,6 @@ | |||
316 | 248 | } `json:"_embedded"` | 230 | } `json:"_embedded"` |
317 | 249 | } | 231 | } |
318 | 250 | 232 | ||
319 | 251 | func cleanupOemHardwareUdevRules(m *packageYaml) error { | ||
320 | 252 | oldFiles, err := filepath.Glob(filepath.Join(snapUdevRulesDir, fmt.Sprintf("80-snappy_%s_*.rules", m.Name))) | ||
321 | 253 | if err != nil { | ||
322 | 254 | return err | ||
323 | 255 | } | ||
324 | 256 | |||
325 | 257 | for _, f := range oldFiles { | ||
326 | 258 | os.Remove(f) | ||
327 | 259 | } | ||
328 | 260 | |||
329 | 261 | return nil | ||
330 | 262 | } | ||
331 | 263 | |||
332 | 264 | func writeOemHardwareUdevRules(m *packageYaml) error { | ||
333 | 265 | // cleanup | ||
334 | 266 | if err := cleanupOemHardwareUdevRules(m); err != nil { | ||
335 | 267 | return err | ||
336 | 268 | } | ||
337 | 269 | // write new files | ||
338 | 270 | for _, h := range m.OEM.Hardware.Assign { | ||
339 | 271 | rulesContent, err := h.generateUdevRuleContent() | ||
340 | 272 | if err != nil { | ||
341 | 273 | return err | ||
342 | 274 | } | ||
343 | 275 | outfile := filepath.Join(snapUdevRulesDir, fmt.Sprintf("80-snappy_%s_%s.rules", m.Name, h.PartID)) | ||
344 | 276 | if err := ioutil.WriteFile(outfile, []byte(rulesContent), 0644); err != nil { | ||
345 | 277 | return err | ||
346 | 278 | } | ||
347 | 279 | } | ||
348 | 280 | |||
349 | 281 | return nil | ||
350 | 282 | } | ||
351 | 283 | |||
352 | 284 | // var to make testing easier | ||
353 | 285 | var runUdevAdm = runUdevAdmImpl | ||
354 | 286 | |||
355 | 287 | func runUdevAdmImpl(args ...string) error { | ||
356 | 288 | cmd := exec.Command(args[0], args[1:]...) | ||
357 | 289 | cmd.Stdout = os.Stdout | ||
358 | 290 | cmd.Stderr = os.Stderr | ||
359 | 291 | return cmd.Run() | ||
360 | 292 | } | ||
361 | 293 | |||
362 | 294 | func activateOemHardwareUdevRules(m *packageYaml) error { | ||
363 | 295 | if err := runUdevAdm("udevadm", "control", "--reload-rules"); err != nil { | ||
364 | 296 | return err | ||
365 | 297 | } | ||
366 | 298 | |||
367 | 299 | return runUdevAdm("udevadm", "trigger") | ||
368 | 300 | } | ||
369 | 301 | |||
370 | 302 | func installOemHardwareUdevRules(m *packageYaml) error { | ||
371 | 303 | if err := writeOemHardwareUdevRules(m); err != nil { | ||
372 | 304 | return err | ||
373 | 305 | } | ||
374 | 306 | |||
375 | 307 | if err := activateOemHardwareUdevRules(m); err != nil { | ||
376 | 308 | return err | ||
377 | 309 | } | ||
378 | 310 | |||
379 | 311 | return nil | ||
380 | 312 | } | ||
381 | 313 | |||
382 | 314 | func (hw *HardwareAssign) generateUdevRuleContent() (string, error) { | ||
383 | 315 | s := "" | ||
384 | 316 | for _, r := range hw.Rules { | ||
385 | 317 | if r.Kernel != "" { | ||
386 | 318 | s += fmt.Sprintf(`KERNEL=="%v", `, r.Kernel) | ||
387 | 319 | } | ||
388 | 320 | if r.Subsystem != "" { | ||
389 | 321 | s += fmt.Sprintf(`SUBSYSTEM=="%v", `, r.Subsystem) | ||
390 | 322 | } | ||
391 | 323 | if r.WithSubsystems != "" { | ||
392 | 324 | s += fmt.Sprintf(`SUBSYSTEMS=="%v", `, r.WithSubsystems) | ||
393 | 325 | } | ||
394 | 326 | if r.WithDriver != "" { | ||
395 | 327 | s += fmt.Sprintf(`DRIVER=="%v", `, r.WithDriver) | ||
396 | 328 | } | ||
397 | 329 | for _, a := range r.WithAttrs { | ||
398 | 330 | l := strings.Split(a, "=") | ||
399 | 331 | s += fmt.Sprintf(`ATTRS{%v}=="%v", `, l[0], l[1]) | ||
400 | 332 | } | ||
401 | 333 | for _, a := range r.WithProps { | ||
402 | 334 | l := strings.SplitN(a, "=", 2) | ||
403 | 335 | s += fmt.Sprintf(`ENV{%v}=="%v", `, l[0], l[1]) | ||
404 | 336 | } | ||
405 | 337 | s += fmt.Sprintf(`TAG:="snappy-assign", ENV{SNAPPY_APP}:="%s"`, hw.PartID) | ||
406 | 338 | s += "\n\n" | ||
407 | 339 | } | ||
408 | 340 | |||
409 | 341 | return s, nil | ||
410 | 342 | } | ||
411 | 343 | |||
412 | 344 | func parsePackageYamlFile(yamlPath string) (*packageYaml, error) { | 233 | func parsePackageYamlFile(yamlPath string) (*packageYaml, error) { |
413 | 345 | 234 | ||
414 | 346 | yamlData, err := ioutil.ReadFile(yamlPath) | 235 | yamlData, err := ioutil.ReadFile(yamlPath) |
415 | @@ -689,6 +578,10 @@ | |||
416 | 689 | return ErrPackageNotRemovable | 578 | return ErrPackageNotRemovable |
417 | 690 | } | 579 | } |
418 | 691 | 580 | ||
419 | 581 | if IsBuiltInSoftware(s.Name()) && s.IsActive() { | ||
420 | 582 | return ErrPackageNotRemovable | ||
421 | 583 | } | ||
422 | 584 | |||
423 | 692 | deps, err := s.DependentNames() | 585 | deps, err := s.DependentNames() |
424 | 693 | if err != nil { | 586 | if err != nil { |
425 | 694 | return err | 587 | return err |
426 | @@ -1206,13 +1099,8 @@ | |||
427 | 1206 | req.Header.Set("X-Ubuntu-Architecture", string(Architecture())) | 1099 | req.Header.Set("X-Ubuntu-Architecture", string(Architecture())) |
428 | 1207 | req.Header.Set("X-Ubuntu-Release", release.String()) | 1100 | req.Header.Set("X-Ubuntu-Release", release.String()) |
429 | 1208 | 1101 | ||
437 | 1209 | // check if the oem part sets a custom store-id | 1102 | if storeID := StoreID(); storeID != "" { |
438 | 1210 | oems, _ := ActiveSnapsByType(SnapTypeOem) | 1103 | req.Header.Set("X-Ubuntu-Store", storeID) |
432 | 1211 | if len(oems) == 1 { | ||
433 | 1212 | storeID := oems[0].(*SnapPart).m.OEM.Store.ID | ||
434 | 1213 | if storeID != "" { | ||
435 | 1214 | req.Header.Set("X-Ubuntu-Store", storeID) | ||
436 | 1215 | } | ||
439 | 1216 | } | 1104 | } |
440 | 1217 | 1105 | ||
441 | 1218 | // sso | 1106 | // sso |
442 | 1219 | 1107 | ||
443 | === modified file 'snappy/snapp_test.go' | |||
444 | --- snappy/snapp_test.go 2015-04-20 18:40:29 +0000 | |||
445 | +++ snappy/snapp_test.go 2015-04-20 23:57:04 +0000 | |||
446 | @@ -835,6 +835,37 @@ | |||
447 | 835 | repo.Details("xkcd") | 835 | repo.Details("xkcd") |
448 | 836 | } | 836 | } |
449 | 837 | 837 | ||
450 | 838 | func (s *SnapTestSuite) TestUninstallBuiltIn(c *C) { | ||
451 | 839 | // install custom oem snap with store-id | ||
452 | 840 | oemYaml, err := makeInstalledMockSnap(s.tempdir, `name: oem-test | ||
453 | 841 | version: 1.0 | ||
454 | 842 | vendor: mvo | ||
455 | 843 | oem: | ||
456 | 844 | store: | ||
457 | 845 | id: my-store | ||
458 | 846 | software: | ||
459 | 847 | built-in: | ||
460 | 848 | - hello-app | ||
461 | 849 | type: oem | ||
462 | 850 | `) | ||
463 | 851 | c.Assert(err, IsNil) | ||
464 | 852 | makeSnapActive(oemYaml) | ||
465 | 853 | |||
466 | 854 | packageYaml, err := makeInstalledMockSnap(s.tempdir, "") | ||
467 | 855 | c.Assert(err, IsNil) | ||
468 | 856 | makeSnapActive(packageYaml) | ||
469 | 857 | |||
470 | 858 | p := &MockProgressMeter{} | ||
471 | 859 | |||
472 | 860 | snap := NewLocalSnapRepository(filepath.Join(s.tempdir, "apps")) | ||
473 | 861 | c.Assert(snap, NotNil) | ||
474 | 862 | installed, err := snap.Installed() | ||
475 | 863 | c.Assert(err, IsNil) | ||
476 | 864 | parts := FindSnapsByName("hello-app", installed) | ||
477 | 865 | c.Assert(parts, HasLen, 1) | ||
478 | 866 | c.Check(parts[0].Uninstall(p), Equals, ErrPackageNotRemovable) | ||
479 | 867 | } | ||
480 | 868 | |||
481 | 838 | var securityBinaryPackageYaml = []byte(`name: test-snap | 869 | var securityBinaryPackageYaml = []byte(`name: test-snap |
482 | 839 | version: 1.2.8 | 870 | version: 1.2.8 |
483 | 840 | vendor: Jamie Strandboge <jamie@canonical.com> | 871 | vendor: Jamie Strandboge <jamie@canonical.com> |
484 | @@ -1209,10 +1240,10 @@ | |||
485 | 1209 | - subsystem: tty | 1240 | - subsystem: tty |
486 | 1210 | with-subsystems: usb-serial | 1241 | with-subsystems: usb-serial |
487 | 1211 | with-driver: pl2303 | 1242 | with-driver: pl2303 |
489 | 1212 | with-attrs: | 1243 | with-attrs: |
490 | 1213 | - idVendor=0xf00f00 | 1244 | - idVendor=0xf00f00 |
491 | 1214 | - idProduct=0xb00 | 1245 | - idProduct=0xb00 |
493 | 1215 | with-props: | 1246 | with-props: |
494 | 1216 | - BAUD=9600 | 1247 | - BAUD=9600 |
495 | 1217 | - META1=foo* | 1248 | - META1=foo* |
496 | 1218 | - META2=foo? | 1249 | - META2=foo? |
The attempt to merge lp:~sergiusens/snappy/lockDownRemove into lp:snappy failed. Below is the output from the failed tests.
Checking formatting com/p/go. crypto failed; trying to fetch newer version com/blakesmith/ ar failed; trying to fetch newer version com/p/go. crypto now at 69e2a90ed92d038 12364aeb947b706 8dc42e561e com/cheggaaa/ pb failed; trying to fetch newer version com/blakesmith/ ar now at c9a977dd0cc1392 b023382c7bfa5a2 2af8d3b730 com/jessevdk/ go-flags failed; trying to fetch newer version com/cheggaaa/ pb now at e8c7cc515bfde3e 267957a3b110080 ceed51354e com/juju/ loggo failed; trying to fetch newer version com/jessevdk/ go-flags now at 15347ef417a3003 49807983f15af9e 65cd2e1b3a com/mvo5/ goconfigparser failed; trying to fetch newer version com/juju/ loggo now at 4c7cbce140ca070 eeb59a28f4bf950 7e511711f9 com/mvo5/ goconfigparser now at 26426272dda20cc 76aa1fa44286dc7 43d2972fe8 net/gocheck failed; trying to fetch newer version 6fb6c4e0d370a05 f24a0bf213 net/gocheck now at <email address hidden> lNdVwxZXOl/ src/launchpad. net/snappy net/snappy/ clickdeb 0.212s coverage: 80.0% of statements net/snappy/ cmd/snappy 0.017s coverage: 13.0% of statements net/snappy/ coreconfig 0.044s coverage: 100.0% of statements net/snappy/ helpers 1.442s coverage: 82.4% of statements net/snappy/ logger 0.035s coverage: 92.5% of statements net/snappy/ partition 0.105s coverage: 81.7% of statements net/snappy/ policy 0.077s coverage: 87.8% of statements net/snappy/ priv 0.004s coverage: 84.8% of statements net/snappy/ progress 0.011s coverage: 45.2% of statements net/snappy/ release 0.006s coverage: 100.0% of statements
Installing godeps
Install golint
Obtaining dependencies
update code.google.
update github.
code.google.
update github.
github.
update github.
github.
update github.
github.
update github.
github.
update gopkg.in/yaml.v2 failed; trying to fetch newer version
github.
update launchpad.
gopkg.in/yaml.v2 now at 49c95bdc2184325
launchpad.
Building
Running tests from /tmp/tmp.
=== RUN Test
OK: 8 passed
--- PASS: Test (0.21 seconds)
PASS
coverage: 80.0% of statements
ok launchpad.
=== RUN Test
OK: 6 passed
--- PASS: Test (0.01 seconds)
PASS
coverage: 13.0% of statements
ok launchpad.
=== RUN Test
OK: 24 passed
--- PASS: Test (0.04 seconds)
PASS
coverage: 100.0% of statements
ok launchpad.
=== RUN Test
OK: 30 passed
--- PASS: Test (1.44 seconds)
PASS
coverage: 82.4% of statements
ok launchpad.
=== RUN Test
OK: 7 passed
--- PASS: Test (0.03 seconds)
PASS
coverage: 92.5% of statements
ok launchpad.
=== RUN Test
OK: 36 passed
--- PASS: Test (0.10 seconds)
PASS
coverage: 81.7% of statements
ok launchpad.
=== RUN Test
OK: 12 passed
--- PASS: Test (0.07 seconds)
PASS
coverage: 87.8% of statements
ok launchpad.
=== RUN Test
OK: 3 passed
--- PASS: Test (0.00 seconds)
PASS
coverage: 84.8% of statements
ok launchpad.
=== RUN Test
OK: 3 passed
--- PASS: Test (0.01 seconds)
PASS
coverage: 45.2% of statements
ok launchpad.
=== RUN Test
OK: 6 passed
--- PASS: Test (0.00 seconds)
PASS
coverage: 100.0% of statements
ok launchpad.
=== RUN Test
2015-04-20 23:41:47 ERROR snappy logger.go:199 hello-app.potato failed to install: a package by that name is already installed
201...