Merge lp:~chipaca/snappy/dddddirs into lp:~snappy-dev/snappy/snappy-moved-to-github

Proposed by John Lenton
Status: Merged
Approved by: John Lenton
Approved revision: 718
Merged at revision: 726
Proposed branch: lp:~chipaca/snappy/dddddirs
Merge into: lp:~snappy-dev/snappy/snappy-moved-to-github
Diff against target: 1599 lines (+244/-220)
22 files modified
dirs/dirs.go (+44/-44)
snappy/click.go (+20/-19)
snappy/click_test.go (+41/-40)
snappy/datadir.go (+3/-1)
snappy/datadir_test.go (+17/-15)
snappy/globals.go (+3/-2)
snappy/hwaccess.go (+5/-4)
snappy/hwaccess_test.go (+15/-14)
snappy/install_test.go (+7/-5)
snappy/oem.go (+8/-7)
snappy/oem_test.go (+5/-4)
snappy/parts.go (+5/-4)
snappy/parts_test.go (+7/-6)
snappy/purge.go (+2/-1)
snappy/purge_test.go (+5/-4)
snappy/security.go (+3/-2)
snappy/security_test.go (+4/-3)
snappy/service.go (+2/-1)
snappy/service_test.go (+7/-6)
snappy/set_test.go (+9/-8)
snappy/snapp.go (+13/-12)
snappy/snapp_test.go (+19/-18)
To merge this branch: bzr merge lp:~chipaca/snappy/dddddirs
Reviewer Review Type Date Requested Status
Sergio Schvezov Approve
Review via email: mp+272430@code.launchpad.net

Commit message

Move snappy/dirs.go into its own package.

To post a comment you must log in.
Revision history for this message
Sergio Schvezov (sergiusens) wrote :

Might it be better to use 'snappy/dirs' as the package?

review: Approve
Revision history for this message
Snappy Tarmac (snappydevtarmac) wrote :

Attempt to merge into lp:snappy failed due to conflicts:

text conflict in snappy/install_test.go
text conflict in snappy/set_test.go

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'dirs'
2=== renamed file 'snappy/dirs.go' => 'dirs/dirs.go'
3--- snappy/dirs.go 2015-06-30 12:36:00 +0000
4+++ dirs/dirs.go 2015-09-29 11:44:13 +0000
5@@ -17,58 +17,58 @@
6 *
7 */
8
9-package snappy
10+package dirs
11
12 import "path/filepath"
13
14 // the various file paths
15 var (
16- globalRootDir string
17-
18- snapAppsDir string
19- snapOemDir string
20- snapDataDir string
21- snapDataHomeGlob string
22- snapAppArmorDir string
23- snapSeccompDir string
24- snapUdevRulesDir string
25- localeDir string
26- snapIconsDir string
27- snapMetaDir string
28-
29- snapBinariesDir string
30- snapServicesDir string
31- snapBusPolicyDir string
32-
33- clickSystemHooksDir string
34- cloudMetaDataFile string
35+ GlobalRootDir string
36+
37+ SnapAppsDir string
38+ SnapOemDir string
39+ SnapDataDir string
40+ SnapDataHomeGlob string
41+ SnapAppArmorDir string
42+ SnapSeccompDir string
43+ SnapUdevRulesDir string
44+ LocaleDir string
45+ SnapIconsDir string
46+ SnapMetaDir string
47+
48+ SnapBinariesDir string
49+ SnapServicesDir string
50+ SnapBusPolicyDir string
51+
52+ ClickSystemHooksDir string
53+ CloudMetaDataFile string
54+
55+ SnappyDir = filepath.Join("var", "lib", "snappy")
56 )
57
58-var snappyDir = filepath.Join("var", "lib", "snappy")
59-
60 // SetRootDir allows settings a new global root directory, this is useful
61 // for e.g. chroot operations
62 func SetRootDir(rootdir string) {
63- globalRootDir = rootdir
64-
65- snapAppsDir = filepath.Join(rootdir, "/apps")
66- snapOemDir = filepath.Join(rootdir, "/oem")
67- snapDataDir = filepath.Join(rootdir, "/var/lib/apps")
68- snapDataHomeGlob = filepath.Join(rootdir, "/home/*/apps/")
69- snapAppArmorDir = filepath.Join(rootdir, "/var/lib/apparmor/clicks")
70- snapSeccompDir = filepath.Join(rootdir, snappyDir, "seccomp", "profiles")
71- snapIconsDir = filepath.Join(rootdir, snappyDir, "icons")
72- snapMetaDir = filepath.Join(rootdir, snappyDir, "meta")
73-
74- snapBinariesDir = filepath.Join(snapAppsDir, "bin")
75- snapServicesDir = filepath.Join(rootdir, "/etc/systemd/system")
76- snapBusPolicyDir = filepath.Join(rootdir, "/etc/dbus-1/system.d")
77-
78- clickSystemHooksDir = filepath.Join(rootdir, "/usr/share/click/hooks")
79-
80- cloudMetaDataFile = filepath.Join(rootdir, "/var/lib/cloud/seed/nocloud-net/meta-data")
81-
82- snapUdevRulesDir = filepath.Join(rootdir, "/etc/udev/rules.d")
83-
84- localeDir = filepath.Join(rootdir, "/usr/share/locale")
85+ GlobalRootDir = rootdir
86+
87+ SnapAppsDir = filepath.Join(rootdir, "/apps")
88+ SnapOemDir = filepath.Join(rootdir, "/oem")
89+ SnapDataDir = filepath.Join(rootdir, "/var/lib/apps")
90+ SnapDataHomeGlob = filepath.Join(rootdir, "/home/*/apps/")
91+ SnapAppArmorDir = filepath.Join(rootdir, "/var/lib/apparmor/clicks")
92+ SnapSeccompDir = filepath.Join(rootdir, SnappyDir, "seccomp", "profiles")
93+ SnapIconsDir = filepath.Join(rootdir, SnappyDir, "icons")
94+ SnapMetaDir = filepath.Join(rootdir, SnappyDir, "meta")
95+
96+ SnapBinariesDir = filepath.Join(SnapAppsDir, "bin")
97+ SnapServicesDir = filepath.Join(rootdir, "/etc/systemd/system")
98+ SnapBusPolicyDir = filepath.Join(rootdir, "/etc/dbus-1/system.d")
99+
100+ ClickSystemHooksDir = filepath.Join(rootdir, "/usr/share/click/hooks")
101+
102+ CloudMetaDataFile = filepath.Join(rootdir, "/var/lib/cloud/seed/nocloud-net/meta-data")
103+
104+ SnapUdevRulesDir = filepath.Join(rootdir, "/etc/udev/rules.d")
105+
106+ LocaleDir = filepath.Join(rootdir, "/usr/share/locale")
107 }
108
109=== modified file 'snappy/click.go'
110--- snappy/click.go 2015-09-15 14:53:38 +0000
111+++ snappy/click.go 2015-09-29 11:44:13 +0000
112@@ -42,6 +42,7 @@
113 "time"
114
115 "launchpad.net/snappy/clickdeb"
116+ "launchpad.net/snappy/dirs"
117 "launchpad.net/snappy/helpers"
118 "launchpad.net/snappy/i18n"
119 "launchpad.net/snappy/logger"
120@@ -154,7 +155,7 @@
121 func systemClickHooks() (hooks map[string]clickHook, err error) {
122 hooks = make(map[string]clickHook)
123
124- hookFiles, err := filepath.Glob(filepath.Join(clickSystemHooksDir, "*.hook"))
125+ hookFiles, err := filepath.Glob(filepath.Join(dirs.ClickSystemHooksDir, "*.hook"))
126 if err != nil {
127 return nil, err
128 }
129@@ -206,7 +207,7 @@
130 continue
131 }
132
133- dst := filepath.Join(globalRootDir, expandHookPattern(m.qualifiedName(origin), app, m.Version, systemHook.pattern))
134+ dst := filepath.Join(dirs.GlobalRootDir, expandHookPattern(m.qualifiedName(origin), app, m.Version, systemHook.pattern))
135
136 if _, err := os.Stat(dst); err == nil {
137 if err := os.Remove(dst); err != nil {
138@@ -274,7 +275,7 @@
139 binName = fmt.Sprintf("%s.%s", m.Name, filepath.Base(binary.Name))
140 }
141
142- return filepath.Join(snapBinariesDir, binName)
143+ return filepath.Join(dirs.SnapBinariesDir, binName)
144 }
145
146 func binPathForBinary(pkgPath string, binary Binary) string {
147@@ -434,7 +435,7 @@
148 socketFileName = filepath.Base(generateSocketFileName(m, service))
149 }
150
151- return systemd.New(globalRootDir, nil).GenServiceFile(
152+ return systemd.New(dirs.GlobalRootDir, nil).GenServiceFile(
153 &systemd.ServiceDescription{
154 AppName: m.Name,
155 ServiceName: service.Name,
156@@ -462,7 +463,7 @@
157
158 serviceFileName := filepath.Base(generateServiceFileName(m, service))
159
160- return systemd.New(globalRootDir, nil).GenSocketFile(
161+ return systemd.New(dirs.GlobalRootDir, nil).GenSocketFile(
162 &systemd.ServiceDescription{
163 ServiceFileName: serviceFileName,
164 ListenStream: service.ListenStream,
165@@ -473,15 +474,15 @@
166 }
167
168 func generateServiceFileName(m *packageYaml, service ServiceYaml) string {
169- return filepath.Join(snapServicesDir, fmt.Sprintf("%s_%s_%s.service", m.Name, service.Name, m.Version))
170+ return filepath.Join(dirs.SnapServicesDir, fmt.Sprintf("%s_%s_%s.service", m.Name, service.Name, m.Version))
171 }
172
173 func generateSocketFileName(m *packageYaml, service ServiceYaml) string {
174- return filepath.Join(snapServicesDir, fmt.Sprintf("%s_%s_%s.socket", m.Name, service.Name, m.Version))
175+ return filepath.Join(dirs.SnapServicesDir, fmt.Sprintf("%s_%s_%s.socket", m.Name, service.Name, m.Version))
176 }
177
178 func generateBusPolicyFileName(m *packageYaml, service ServiceYaml) string {
179- return filepath.Join(snapBusPolicyDir, fmt.Sprintf("%s_%s_%s.conf", m.Name, service.Name, m.Version))
180+ return filepath.Join(dirs.SnapBusPolicyDir, fmt.Sprintf("%s_%s_%s.conf", m.Name, service.Name, m.Version))
181 }
182
183 // takes a directory and removes the global root, this is needed
184@@ -490,11 +491,11 @@
185 var stripGlobalRootDir = stripGlobalRootDirImpl
186
187 func stripGlobalRootDirImpl(dir string) string {
188- if globalRootDir == "/" {
189+ if dirs.GlobalRootDir == "/" {
190 return dir
191 }
192
193- return dir[len(globalRootDir):]
194+ return dir[len(dirs.GlobalRootDir):]
195 }
196
197 func (m *packageYaml) addPackageServices(baseDir string, inhibitHooks bool, inter interacter) error {
198@@ -549,7 +550,7 @@
199 //
200 // *but* always run enable (which just sets a symlink)
201 serviceName := filepath.Base(generateServiceFileName(m, service))
202- sysd := systemd.New(globalRootDir, inter)
203+ sysd := systemd.New(dirs.GlobalRootDir, inter)
204 if !inhibitHooks {
205 if err := sysd.DaemonReload(); err != nil {
206 return err
207@@ -586,7 +587,7 @@
208 }
209
210 func (m *packageYaml) removePackageServices(baseDir string, inter interacter) error {
211- sysd := systemd.New(globalRootDir, inter)
212+ sysd := systemd.New(dirs.GlobalRootDir, inter)
213 for _, service := range m.ServiceYamls {
214 serviceName := filepath.Base(generateServiceFileName(m, service))
215 if err := sysd.Disable(serviceName); err != nil {
216@@ -628,7 +629,7 @@
217 }
218
219 func (m *packageYaml) addPackageBinaries(baseDir string) error {
220- if err := os.MkdirAll(snapBinariesDir, 0755); err != nil {
221+ if err := os.MkdirAll(dirs.SnapBinariesDir, 0755); err != nil {
222 return err
223 }
224
225@@ -673,7 +674,7 @@
226 return err
227 }
228
229- fn := filepath.Join(snapSeccompDir, profileName)
230+ fn := filepath.Join(dirs.SnapSeccompDir, profileName)
231 if err := ioutil.WriteFile(fn, content, 0644); err != nil {
232 return err
233 }
234@@ -706,7 +707,7 @@
235 if err != nil {
236 return err
237 }
238- fn := filepath.Join(snapSeccompDir, profileName)
239+ fn := filepath.Join(dirs.SnapSeccompDir, profileName)
240 if err := os.Remove(fn); err != nil && !os.IsNotExist(err) {
241 return err
242 }
243@@ -799,15 +800,15 @@
244 // snapDataDirs returns the list of data directories for the given snap version
245 func snapDataDirs(fullName, version string) ([]string, error) {
246 // collect the directories, homes first
247- dirs, err := filepath.Glob(filepath.Join(snapDataHomeGlob, fullName, version))
248+ found, err := filepath.Glob(filepath.Join(dirs.SnapDataHomeGlob, fullName, version))
249 if err != nil {
250 return nil, err
251 }
252 // then system data
253- systemPath := filepath.Join(snapDataDir, fullName, version)
254- dirs = append(dirs, systemPath)
255+ systemPath := filepath.Join(dirs.SnapDataDir, fullName, version)
256+ found = append(found, systemPath)
257
258- return dirs, nil
259+ return found, nil
260 }
261
262 // Copy all data for "fullName" from "oldVersion" to "newVersion"
263
264=== modified file 'snappy/click_test.go'
265--- snappy/click_test.go 2015-09-15 20:24:56 +0000
266+++ snappy/click_test.go 2015-09-29 11:44:13 +0000
267@@ -32,6 +32,7 @@
268 . "gopkg.in/check.v1"
269
270 "launchpad.net/snappy/clickdeb"
271+ "launchpad.net/snappy/dirs"
272 "launchpad.net/snappy/helpers"
273 "launchpad.net/snappy/pkg"
274 "launchpad.net/snappy/policy"
275@@ -78,10 +79,10 @@
276 hookName, err := cfg.Get("hook", "Hook-Name")
277 c.Assert(err, IsNil)
278
279- if _, err := os.Stat(clickSystemHooksDir); err != nil {
280- os.MkdirAll(clickSystemHooksDir, 0755)
281+ if _, err := os.Stat(dirs.ClickSystemHooksDir); err != nil {
282+ os.MkdirAll(dirs.ClickSystemHooksDir, 0755)
283 }
284- ioutil.WriteFile(filepath.Join(clickSystemHooksDir, hookName+".hook"), []byte(hookContent), 0644)
285+ ioutil.WriteFile(filepath.Join(dirs.ClickSystemHooksDir, hookName+".hook"), []byte(hookContent), 0644)
286 }
287
288 func (s *SnapTestSuite) TestReadClickHookFile(c *C) {
289@@ -89,7 +90,7 @@
290 User: root
291 Exec: /usr/lib/click-systemd/systemd-clickhook
292 Pattern: /var/lib/systemd/click/${id}`)
293- hook, err := readClickHookFile(filepath.Join(clickSystemHooksDir, "systemd.hook"))
294+ hook, err := readClickHookFile(filepath.Join(dirs.ClickSystemHooksDir, "systemd.hook"))
295 c.Assert(err, IsNil)
296 c.Assert(hook.name, Equals, "systemd")
297 c.Assert(hook.user, Equals, "root")
298@@ -99,7 +100,7 @@
299 // click allows non-existing "Hook-Name" and uses the filename then
300 makeClickHook(c, `Hook-Name: apparmor
301 Pattern: /var/lib/apparmor/click/${id}`)
302- hook, err = readClickHookFile(filepath.Join(clickSystemHooksDir, "apparmor.hook"))
303+ hook, err = readClickHookFile(filepath.Join(dirs.ClickSystemHooksDir, "apparmor.hook"))
304 c.Assert(err, IsNil)
305 c.Assert(hook.name, Equals, "apparmor")
306 }
307@@ -179,7 +180,7 @@
308 c.Assert(err, IsNil)
309 c.Check(name, Equals, "foo")
310
311- baseDir := filepath.Join(snapAppsDir, fooComposedName, "1.0")
312+ baseDir := filepath.Join(dirs.SnapAppsDir, fooComposedName, "1.0")
313 contentFile := filepath.Join(baseDir, "bin", "foo")
314 content, err := ioutil.ReadFile(contentFile)
315 c.Assert(err, IsNil)
316@@ -589,7 +590,7 @@
317 }
318
319 func (s *SnapTestSuite) TestClickCopyData(c *C) {
320- snapDataHomeGlob = filepath.Join(s.tempdir, "home", "*", "apps")
321+ dirs.SnapDataHomeGlob = filepath.Join(s.tempdir, "home", "*", "apps")
322 homeDir := filepath.Join(s.tempdir, "home", "user1", "apps")
323 appDir := "foo." + testOrigin
324 homeData := filepath.Join(homeDir, appDir, "1.0")
325@@ -605,7 +606,7 @@
326 snapFile := makeTestSnapPackage(c, packageYaml+"version: 1.0")
327 _, err = installClick(snapFile, AllowUnauthenticated, nil, testOrigin)
328 c.Assert(err, IsNil)
329- canaryDataFile := filepath.Join(snapDataDir, appDir, "1.0", "canary.txt")
330+ canaryDataFile := filepath.Join(dirs.SnapDataDir, appDir, "1.0", "canary.txt")
331 err = ioutil.WriteFile(canaryDataFile, canaryData, 0644)
332 c.Assert(err, IsNil)
333 err = ioutil.WriteFile(filepath.Join(homeData, "canary.home"), canaryData, 0644)
334@@ -614,7 +615,7 @@
335 snapFile = makeTestSnapPackage(c, packageYaml+"version: 2.0")
336 _, err = installClick(snapFile, AllowUnauthenticated, nil, testOrigin)
337 c.Assert(err, IsNil)
338- newCanaryDataFile := filepath.Join(snapDataDir, appDir, "2.0", "canary.txt")
339+ newCanaryDataFile := filepath.Join(dirs.SnapDataDir, appDir, "2.0", "canary.txt")
340 content, err := ioutil.ReadFile(newCanaryDataFile)
341 c.Assert(err, IsNil)
342 c.Assert(content, DeepEquals, canaryData)
343@@ -629,7 +630,7 @@
344 // system data gets copied
345 func (s *SnapTestSuite) TestClickCopyDataNoUserHomes(c *C) {
346 // this home dir path does not exist
347- snapDataHomeGlob = filepath.Join(s.tempdir, "no-such-home", "*", "apps")
348+ dirs.SnapDataHomeGlob = filepath.Join(s.tempdir, "no-such-home", "*", "apps")
349
350 packageYaml := `name: foo
351 icon: foo.svg
352@@ -639,14 +640,14 @@
353 snapFile := makeTestSnapPackage(c, packageYaml+"version: 1.0")
354 _, err := installClick(snapFile, AllowUnauthenticated, nil, testOrigin)
355 c.Assert(err, IsNil)
356- canaryDataFile := filepath.Join(snapDataDir, appDir, "1.0", "canary.txt")
357+ canaryDataFile := filepath.Join(dirs.SnapDataDir, appDir, "1.0", "canary.txt")
358 err = ioutil.WriteFile(canaryDataFile, []byte(""), 0644)
359 c.Assert(err, IsNil)
360
361 snapFile = makeTestSnapPackage(c, packageYaml+"version: 2.0")
362 _, err = installClick(snapFile, AllowUnauthenticated, nil, testOrigin)
363 c.Assert(err, IsNil)
364- _, err = os.Stat(filepath.Join(snapDataDir, appDir, "2.0", "canary.txt"))
365+ _, err = os.Stat(filepath.Join(dirs.SnapDataDir, appDir, "2.0", "canary.txt"))
366 c.Assert(err, IsNil)
367 }
368
369@@ -675,14 +676,14 @@
370 snapFile := makeTestSnapPackage(c, packageYaml+"version: 1.0")
371 _, err := installClick(snapFile, AllowUnauthenticated, nil, testOrigin)
372 c.Assert(err, IsNil)
373- canaryDataFile := filepath.Join(snapDataDir, appDir, "1.0", "canary.txt")
374+ canaryDataFile := filepath.Join(dirs.SnapDataDir, appDir, "1.0", "canary.txt")
375 err = ioutil.WriteFile(canaryDataFile, []byte(""), 0644)
376 c.Assert(err, IsNil)
377
378 snapFile = makeTestSnapPackage(c, packageYaml+"version: 2.0")
379 _, err = installClick(snapFile, AllowUnauthenticated, nil, testOrigin)
380 c.Assert(err, IsNil)
381- _, err = os.Stat(filepath.Join(snapDataDir, appDir, "2.0", "canary.txt"))
382+ _, err = os.Stat(filepath.Join(dirs.SnapDataDir, appDir, "2.0", "canary.txt"))
383 c.Assert(err, IsNil)
384
385 // read the hook trace file, this shows that 1.0 was active, then
386@@ -720,7 +721,7 @@
387 snapFile := makeTestSnapPackage(c, packageYaml+"version: 1.0")
388 _, err := installClick(snapFile, AllowUnauthenticated, nil, testOrigin)
389 c.Assert(err, IsNil)
390- canaryDataFile := filepath.Join(snapDataDir, appDir, "1.0", "canary.txt")
391+ canaryDataFile := filepath.Join(dirs.SnapDataDir, appDir, "1.0", "canary.txt")
392 err = ioutil.WriteFile(canaryDataFile, []byte(""), 0644)
393 c.Assert(err, IsNil)
394
395@@ -730,12 +731,12 @@
396
397 // installing 2.0 will fail in the hooks,
398 // so ensure we fall back to v1.0
399- content, err := ioutil.ReadFile(filepath.Join(snapAppsDir, appDir, "current", "meta", "package.yaml"))
400+ content, err := ioutil.ReadFile(filepath.Join(dirs.SnapAppsDir, appDir, "current", "meta", "package.yaml"))
401 c.Assert(err, IsNil)
402 c.Assert(strings.Contains(string(content), "version: 1.0"), Equals, true)
403
404 // no leftovers from the failed install
405- _, err = os.Stat(filepath.Join(snapAppsDir, fooComposedName, "2.0"))
406+ _, err = os.Stat(filepath.Join(dirs.SnapAppsDir, fooComposedName, "2.0"))
407 c.Assert(err, NotNil)
408 }
409
410@@ -846,11 +847,11 @@
411
412 // ensure that the binary wrapper file go generated with the right
413 // name
414- binaryWrapper := filepath.Join(snapBinariesDir, "foo.bar")
415+ binaryWrapper := filepath.Join(dirs.SnapBinariesDir, "foo.bar")
416 c.Assert(helpers.FileExists(binaryWrapper), Equals, true)
417
418 // and that it gets removed on remove
419- snapDir := filepath.Join(snapAppsDir, "foo.mvo", "1.0")
420+ snapDir := filepath.Join(dirs.SnapAppsDir, "foo.mvo", "1.0")
421 yamlPath := filepath.Join(snapDir, "meta", "package.yaml")
422 part, err := NewInstalledSnapPart(yamlPath, testOrigin)
423 c.Assert(err, IsNil)
424@@ -873,8 +874,8 @@
425
426 // ensure that the binary wrapper file go generated with the right
427 // path
428- oldSnapBin := filepath.Join(snapAppsDir[len(globalRootDir):], "foo.mvo", "1.0", "bin", "bar")
429- binaryWrapper := filepath.Join(snapBinariesDir, "foo.bar")
430+ oldSnapBin := filepath.Join(dirs.SnapAppsDir[len(dirs.GlobalRootDir):], "foo.mvo", "1.0", "bin", "bar")
431+ binaryWrapper := filepath.Join(dirs.SnapBinariesDir, "foo.bar")
432 content, err := ioutil.ReadFile(binaryWrapper)
433 c.Assert(err, IsNil)
434 c.Assert(strings.Contains(string(content), oldSnapBin), Equals, true)
435@@ -883,7 +884,7 @@
436 snapFile = makeTestSnapPackage(c, packageYaml+"version: 2.0")
437 _, err = installClick(snapFile, AllowUnauthenticated, nil, "mvo")
438 c.Assert(err, IsNil)
439- newSnapBin := filepath.Join(snapAppsDir[len(globalRootDir):], "foo.mvo", "2.0", "bin", "bar")
440+ newSnapBin := filepath.Join(dirs.SnapAppsDir[len(dirs.GlobalRootDir):], "foo.mvo", "2.0", "bin", "bar")
441 content, err = ioutil.ReadFile(binaryWrapper)
442 c.Assert(err, IsNil)
443 c.Assert(strings.Contains(string(content), newSnapBin), Equals, true)
444@@ -901,7 +902,7 @@
445 _, err := installClick(snapFile, AllowUnauthenticated, nil, "mvo")
446 c.Assert(err, IsNil)
447
448- servicesFile := filepath.Join(snapServicesDir, "foo_service_1.0.service")
449+ servicesFile := filepath.Join(dirs.SnapServicesDir, "foo_service_1.0.service")
450 c.Assert(helpers.FileExists(servicesFile), Equals, true)
451 st, err := os.Stat(servicesFile)
452 c.Assert(err, IsNil)
453@@ -909,7 +910,7 @@
454 c.Assert(st.Mode().String(), Equals, "-rw-r--r--")
455
456 // and that it gets removed on remove
457- snapDir := filepath.Join(snapAppsDir, "foo.mvo", "1.0")
458+ snapDir := filepath.Join(dirs.SnapAppsDir, "foo.mvo", "1.0")
459 yamlPath := filepath.Join(snapDir, "meta", "package.yaml")
460 part, err := NewInstalledSnapPart(yamlPath, testOrigin)
461 c.Assert(err, IsNil)
462@@ -945,8 +946,8 @@
463 _, err = installClick(snapFile, AllowUnauthenticated, inter, testOrigin)
464 c.Assert(err, IsNil)
465
466- c.Assert(helpers.FileExists(filepath.Join(snapServicesDir, "foo_svc1_1.0.service")), Equals, true)
467- c.Assert(helpers.FileExists(filepath.Join(snapServicesDir, "foo_svc2_1.0.service")), Equals, true)
468+ c.Assert(helpers.FileExists(filepath.Join(dirs.SnapServicesDir, "foo_svc1_1.0.service")), Equals, true)
469+ c.Assert(helpers.FileExists(filepath.Join(dirs.SnapServicesDir, "foo_svc2_1.0.service")), Equals, true)
470
471 return fmkYaml, inter
472 }
473@@ -966,12 +967,12 @@
474 c.Check(cmdlog, DeepEquals, []string{"stop", "show", "stop", "show", "start", "start"})
475
476 // check it got set active
477- content, err := ioutil.ReadFile(filepath.Join(snapAppsDir, "fmk", "current", "meta", "package.yaml"))
478+ content, err := ioutil.ReadFile(filepath.Join(dirs.SnapAppsDir, "fmk", "current", "meta", "package.yaml"))
479 c.Assert(err, IsNil)
480 c.Assert(strings.Contains(string(content), "version: 2"), Equals, true)
481
482 // just in case (cf. the following tests)
483- _, err = os.Stat(filepath.Join(snapAppsDir, "fmk", "2"))
484+ _, err = os.Stat(filepath.Join(dirs.SnapAppsDir, "fmk", "2"))
485 c.Assert(err, IsNil)
486
487 }
488@@ -995,12 +996,12 @@
489 c.Check(cmdlog, DeepEquals, []string{"stop", "show", "stop", "start"})
490
491 // check it got rolled back
492- content, err := ioutil.ReadFile(filepath.Join(snapAppsDir, "fmk", "current", "meta", "package.yaml"))
493+ content, err := ioutil.ReadFile(filepath.Join(dirs.SnapAppsDir, "fmk", "current", "meta", "package.yaml"))
494 c.Assert(err, IsNil)
495 c.Assert(strings.Contains(string(content), "version: 1"), Equals, true)
496
497 // no leftovers from the failed install
498- _, err = os.Stat(filepath.Join(snapAppsDir, "fmk", "2"))
499+ _, err = os.Stat(filepath.Join(dirs.SnapAppsDir, "fmk", "2"))
500 c.Assert(err, NotNil)
501 }
502
503@@ -1026,12 +1027,12 @@
504 })
505
506 // check it got rolled back
507- content, err := ioutil.ReadFile(filepath.Join(snapAppsDir, "fmk", "current", "meta", "package.yaml"))
508+ content, err := ioutil.ReadFile(filepath.Join(dirs.SnapAppsDir, "fmk", "current", "meta", "package.yaml"))
509 c.Assert(err, IsNil)
510 c.Assert(strings.Contains(string(content), "version: 1"), Equals, true)
511
512 // no leftovers from the failed install
513- _, err = os.Stat(filepath.Join(snapAppsDir, "fmk", "2"))
514+ _, err = os.Stat(filepath.Join(dirs.SnapAppsDir, "fmk", "2"))
515 c.Assert(err, NotNil)
516
517 }
518@@ -1126,7 +1127,7 @@
519 // ensure that even with a global rootdir the paths in the generated
520 // .services file are setup correctly (i.e. that the global root
521 // is stripped)
522- c.Assert(globalRootDir, Not(Equals), "/")
523+ c.Assert(dirs.GlobalRootDir, Not(Equals), "/")
524
525 yamlFile, err := makeInstalledMockSnap(s.tempdir, "")
526 c.Assert(err, IsNil)
527@@ -1195,7 +1196,7 @@
528 // ensure that even with a global rootdir the paths in the generated
529 // .services file are setup correctly (i.e. that the global root
530 // is stripped)
531- c.Assert(globalRootDir, Not(Equals), "/")
532+ c.Assert(dirs.GlobalRootDir, Not(Equals), "/")
533
534 yamlFile, err := makeInstalledMockSnap(s.tempdir, "")
535 c.Assert(err, IsNil)
536@@ -1490,14 +1491,14 @@
537 `), false)
538 c.Assert(err, IsNil)
539
540- snapSeccompDir = c.MkDir()
541+ dirs.SnapSeccompDir = c.MkDir()
542 err = m.addSecurityPolicy("/apps/foo.mvo/1.0/")
543 c.Assert(err, IsNil)
544
545- binSeccompContent, err := ioutil.ReadFile(filepath.Join(snapSeccompDir, "foo.mvo_foo_1.0"))
546+ binSeccompContent, err := ioutil.ReadFile(filepath.Join(dirs.SnapSeccompDir, "foo.mvo_foo_1.0"))
547 c.Assert(string(binSeccompContent), Equals, scFilterGenFakeResult)
548
549- serviceSeccompContent, err := ioutil.ReadFile(filepath.Join(snapSeccompDir, "foo.mvo_bar_1.0"))
550+ serviceSeccompContent, err := ioutil.ReadFile(filepath.Join(dirs.SnapSeccompDir, "foo.mvo_bar_1.0"))
551 c.Assert(string(serviceSeccompContent), Equals, scFilterGenFakeResult)
552
553 }
554@@ -1514,9 +1515,9 @@
555 `), false)
556 c.Assert(err, IsNil)
557
558- snapSeccompDir = c.MkDir()
559- binSeccomp := filepath.Join(snapSeccompDir, "foo.mvo_foo_1.0")
560- serviceSeccomp := filepath.Join(snapSeccompDir, "foo.mvo_bar_1.0")
561+ dirs.SnapSeccompDir = c.MkDir()
562+ binSeccomp := filepath.Join(dirs.SnapSeccompDir, "foo.mvo_foo_1.0")
563+ serviceSeccomp := filepath.Join(dirs.SnapSeccompDir, "foo.mvo_bar_1.0")
564 c.Assert(helpers.FileExists(binSeccomp), Equals, false)
565 c.Assert(helpers.FileExists(serviceSeccomp), Equals, false)
566
567
568=== modified file 'snappy/datadir.go'
569--- snappy/datadir.go 2015-05-20 17:24:29 +0000
570+++ snappy/datadir.go 2015-09-29 11:44:13 +0000
571@@ -22,6 +22,8 @@
572 import (
573 "path/filepath"
574 "strings"
575+
576+ "launchpad.net/snappy/dirs"
577 )
578
579 // A SnapDataDir represents a single data directory for a version of a package
580@@ -102,5 +104,5 @@
581
582 // DataDirs returns the list of all SnapDataDirs in the system.
583 func DataDirs(spec string) []SnapDataDir {
584- return append(data1(spec, snapDataHomeGlob), data1(spec, snapDataDir)...)
585+ return append(data1(spec, dirs.SnapDataHomeGlob), data1(spec, dirs.SnapDataDir)...)
586 }
587
588=== modified file 'snappy/datadir_test.go'
589--- snappy/datadir_test.go 2015-06-02 20:46:07 +0000
590+++ snappy/datadir_test.go 2015-09-29 11:44:13 +0000
591@@ -25,6 +25,8 @@
592 "strings"
593
594 . "gopkg.in/check.v1"
595+
596+ "launchpad.net/snappy/dirs"
597 )
598
599 type DataDirSuite struct{}
600@@ -32,14 +34,14 @@
601 var _ = Suite(&DataDirSuite{})
602
603 func (s *DataDirSuite) SetUpTest(c *C) {
604- SetRootDir(c.MkDir())
605+ dirs.SetRootDir(c.MkDir())
606 }
607
608 func (s *DataDirSuite) TestSystemDataDirs(c *C) {
609- c.Assert(os.MkdirAll(filepath.Join(snapDataDir, "foo.bar", "v1"), 0755), IsNil)
610+ c.Assert(os.MkdirAll(filepath.Join(dirs.SnapDataDir, "foo.bar", "v1"), 0755), IsNil)
611 dds := DataDirs("foo")
612 c.Check(dds, DeepEquals, []SnapDataDir{{
613- Base: snapDataDir,
614+ Base: dirs.SnapDataDir,
615 Name: "foo",
616 Origin: "bar",
617 Version: "v1",
618@@ -52,10 +54,10 @@
619 }
620
621 func (s *DataDirSuite) TestDataDirsFramework(c *C) {
622- c.Assert(os.MkdirAll(filepath.Join(snapDataDir, "foo", "v1"), 0755), IsNil)
623+ c.Assert(os.MkdirAll(filepath.Join(dirs.SnapDataDir, "foo", "v1"), 0755), IsNil)
624 dds := DataDirs("foo")
625 c.Check(dds, DeepEquals, []SnapDataDir{{
626- Base: snapDataDir,
627+ Base: dirs.SnapDataDir,
628 Name: "foo",
629 Origin: "",
630 Version: "v1",
631@@ -64,11 +66,11 @@
632 }
633
634 func (s *DataDirSuite) TestHomeDataDirs(c *C) {
635- home := strings.Replace(snapDataHomeGlob, "*", "user1", -1)
636+ home := strings.Replace(dirs.SnapDataHomeGlob, "*", "user1", -1)
637 c.Assert(os.MkdirAll(filepath.Join(home, "foo.bar", "v1"), 0755), IsNil)
638 dds := DataDirs("foo")
639 c.Check(dds, DeepEquals, []SnapDataDir{{
640- Base: snapDataHomeGlob,
641+ Base: dirs.SnapDataHomeGlob,
642 Name: "foo",
643 Origin: "bar",
644 Version: "v1",
645@@ -76,39 +78,39 @@
646 }
647
648 func (s *DataDirSuite) TestEverywhichwhereDataDirs(c *C) {
649- home := strings.Replace(snapDataHomeGlob, "*", "user1", -1)
650+ home := strings.Replace(dirs.SnapDataHomeGlob, "*", "user1", -1)
651 c.Assert(os.MkdirAll(filepath.Join(home, "foo.bar", "v0"), 0755), IsNil)
652 c.Assert(os.MkdirAll(filepath.Join(home, "foo.bar", "v1"), 0755), IsNil)
653- c.Assert(os.MkdirAll(filepath.Join(snapDataDir, "foo.xyzzy", "v1"), 0755), IsNil)
654- c.Assert(os.MkdirAll(filepath.Join(snapDataDir, "foo", "v3"), 0755), IsNil)
655+ c.Assert(os.MkdirAll(filepath.Join(dirs.SnapDataDir, "foo.xyzzy", "v1"), 0755), IsNil)
656+ c.Assert(os.MkdirAll(filepath.Join(dirs.SnapDataDir, "foo", "v3"), 0755), IsNil)
657 dds := DataDirs("foo")
658 c.Assert(dds, HasLen, 4)
659 hi := 0
660 si := 2
661- if dds[0].Base == snapDataDir {
662+ if dds[0].Base == dirs.SnapDataDir {
663 si = 0
664 hi = 2
665 }
666 c.Check(dds[hi], DeepEquals, SnapDataDir{
667- Base: snapDataHomeGlob,
668+ Base: dirs.SnapDataHomeGlob,
669 Name: "foo",
670 Origin: "bar",
671 Version: "v0",
672 })
673 c.Check(dds[hi+1], DeepEquals, SnapDataDir{
674- Base: snapDataHomeGlob,
675+ Base: dirs.SnapDataHomeGlob,
676 Name: "foo",
677 Origin: "bar",
678 Version: "v1",
679 })
680 c.Check(dds[si], DeepEquals, SnapDataDir{
681- Base: snapDataDir,
682+ Base: dirs.SnapDataDir,
683 Name: "foo",
684 Origin: "",
685 Version: "v3",
686 })
687 c.Check(dds[si+1], DeepEquals, SnapDataDir{
688- Base: snapDataDir,
689+ Base: dirs.SnapDataDir,
690 Name: "foo",
691 Origin: "xyzzy",
692 Version: "v1",
693
694=== modified file 'snappy/globals.go'
695--- snappy/globals.go 2015-05-15 13:33:27 +0000
696+++ snappy/globals.go 2015-09-29 11:44:13 +0000
697@@ -22,6 +22,7 @@
698 import (
699 "os"
700
701+ "launchpad.net/snappy/dirs"
702 "launchpad.net/snappy/release"
703 )
704
705@@ -32,9 +33,9 @@
706 root = "/"
707 }
708
709- SetRootDir(root)
710+ dirs.SetRootDir(root)
711
712 // we don't need to care for the error here to take into account when
713 // initialized on a non snappy system
714- release.Setup(globalRootDir)
715+ release.Setup(dirs.GlobalRootDir)
716 }
717
718=== modified file 'snappy/hwaccess.go'
719--- snappy/hwaccess.go 2015-09-25 12:49:25 +0000
720+++ snappy/hwaccess.go 2015-09-29 11:44:13 +0000
721@@ -29,6 +29,7 @@
722 "path/filepath"
723 "strings"
724
725+ "launchpad.net/snappy/dirs"
726 "launchpad.net/snappy/helpers"
727 )
728
729@@ -43,7 +44,7 @@
730
731 // return the json filename to add to the security json
732 func getHWAccessJSONFile(snapname string) string {
733- return filepath.Join(snapAppArmorDir, fmt.Sprintf("%s.json.additional", snapname))
734+ return filepath.Join(dirs.SnapAppArmorDir, fmt.Sprintf("%s.json.additional", snapname))
735 }
736
737 // Return true if the device string is a valid device
738@@ -113,7 +114,7 @@
739
740 func udevRulesPathForPart(partid string) string {
741 // use 70- here so that its read before the OEM rules
742- return filepath.Join(snapUdevRulesDir, fmt.Sprintf("70-snappy_hwassign_%s.rules", partid))
743+ return filepath.Join(dirs.SnapUdevRulesDir, fmt.Sprintf("70-snappy_hwassign_%s.rules", partid))
744 }
745
746 func addUdevRuleForSnap(snapname, newRule string) error {
747@@ -137,7 +138,7 @@
748 }
749
750 func writeUdevRuleForDeviceCgroup(snapname, device string) error {
751- os.MkdirAll(snapUdevRulesDir, 0755)
752+ os.MkdirAll(dirs.SnapUdevRulesDir, 0755)
753
754 // the device cgroup/launcher etc support only the apps level,
755 // not a binary/service or version, so if we get a full
756@@ -168,7 +169,7 @@
757 }
758
759 // check if there is anything apparmor related to add to
760- globExpr := filepath.Join(snapAppArmorDir, fmt.Sprintf("%s_*.json", snapname))
761+ globExpr := filepath.Join(dirs.SnapAppArmorDir, fmt.Sprintf("%s_*.json", snapname))
762 matches, err := filepath.Glob(globExpr)
763 if err != nil {
764 return err
765
766=== modified file 'snappy/hwaccess_test.go'
767--- snappy/hwaccess_test.go 2015-09-22 15:27:35 +0000
768+++ snappy/hwaccess_test.go 2015-09-29 11:44:13 +0000
769@@ -23,9 +23,10 @@
770 "io/ioutil"
771 "path/filepath"
772
773+ . "gopkg.in/check.v1"
774+
775+ "launchpad.net/snappy/dirs"
776 "launchpad.net/snappy/helpers"
777-
778- . "gopkg.in/check.v1"
779 )
780
781 func mockRegenerateAppArmorRules() *bool {
782@@ -43,7 +44,7 @@
783
784 err := AddHWAccess("hello-app", "/dev/ttyUSB0")
785 c.Assert(err, IsNil)
786- content, err := ioutil.ReadFile(filepath.Join(snapAppArmorDir, "hello-app.json.additional"))
787+ content, err := ioutil.ReadFile(filepath.Join(dirs.SnapAppArmorDir, "hello-app.json.additional"))
788 c.Assert(err, IsNil)
789 c.Assert(string(content), Equals, `{
790 "write_path": [
791@@ -76,7 +77,7 @@
792 err = AddHWAccess("hello-app", "/sys/devices/gpio1")
793 c.Assert(err, IsNil)
794
795- content, err := ioutil.ReadFile(filepath.Join(snapAppArmorDir, "hello-app.json.additional"))
796+ content, err := ioutil.ReadFile(filepath.Join(dirs.SnapAppArmorDir, "hello-app.json.additional"))
797 c.Assert(err, IsNil)
798 c.Assert(string(content), Equals, `{
799 "write_path": [
800@@ -160,7 +161,7 @@
801
802 // check that the udev rules file got created
803 udevRulesFilename := "70-snappy_hwassign_hello-app.rules"
804- c.Assert(helpers.FileExists(filepath.Join(snapUdevRulesDir, udevRulesFilename)), Equals, true)
805+ c.Assert(helpers.FileExists(filepath.Join(dirs.SnapUdevRulesDir, udevRulesFilename)), Equals, true)
806
807 writePaths, err := ListHWAccess("hello-app")
808 c.Assert(err, IsNil)
809@@ -176,10 +177,10 @@
810 c.Assert(writePaths, HasLen, 0)
811
812 // check that the udev rules file got removed on unassign
813- c.Assert(helpers.FileExists(filepath.Join(snapUdevRulesDir, udevRulesFilename)), Equals, false)
814+ c.Assert(helpers.FileExists(filepath.Join(dirs.SnapUdevRulesDir, udevRulesFilename)), Equals, false)
815
816 // check the json.additional got cleaned out
817- content, err := ioutil.ReadFile(filepath.Join(snapAppArmorDir, "hello-app.json.additional"))
818+ content, err := ioutil.ReadFile(filepath.Join(dirs.SnapAppArmorDir, "hello-app.json.additional"))
819 c.Assert(err, IsNil)
820 c.Assert(string(content), Equals, "{}\n")
821 }
822@@ -196,7 +197,7 @@
823 c.Assert(writePaths, DeepEquals, []string{"/dev/bar", "/dev/bar*"})
824
825 // check the file only lists udevReadGlob once
826- content, err := ioutil.ReadFile(filepath.Join(snapAppArmorDir, "hello-app.json.additional"))
827+ content, err := ioutil.ReadFile(filepath.Join(dirs.SnapAppArmorDir, "hello-app.json.additional"))
828 c.Assert(err, IsNil)
829 c.Assert(string(content), Equals, `{
830 "write_path": [
831@@ -210,7 +211,7 @@
832 `)
833
834 // check the udev rule file contains all the rules
835- content, err = ioutil.ReadFile(filepath.Join(snapUdevRulesDir, "70-snappy_hwassign_hello-app.rules"))
836+ content, err = ioutil.ReadFile(filepath.Join(dirs.SnapUdevRulesDir, "70-snappy_hwassign_hello-app.rules"))
837 c.Assert(err, IsNil)
838 c.Assert(string(content), Equals, `
839 KERNEL=="bar", TAG:="snappy-assign", ENV{SNAPPY_APP}:="hello-app"
840@@ -226,7 +227,7 @@
841 c.Assert(writePaths, DeepEquals, []string{"/dev/bar*"})
842
843 // check udevReadGlob is still there
844- content, err = ioutil.ReadFile(filepath.Join(snapAppArmorDir, "hello-app.json.additional"))
845+ content, err = ioutil.ReadFile(filepath.Join(dirs.SnapAppArmorDir, "hello-app.json.additional"))
846 c.Assert(err, IsNil)
847 c.Assert(string(content), Equals, `{
848 "write_path": [
849@@ -238,7 +239,7 @@
850 }
851 `)
852 // check the udevReadGlob Udev rule is still there
853- content, err = ioutil.ReadFile(filepath.Join(snapUdevRulesDir, "70-snappy_hwassign_hello-app.rules"))
854+ content, err = ioutil.ReadFile(filepath.Join(dirs.SnapUdevRulesDir, "70-snappy_hwassign_hello-app.rules"))
855 c.Assert(err, IsNil)
856 c.Assert(string(content), Equals, `KERNEL=="bar*", TAG:="snappy-assign", ENV{SNAPPY_APP}:="hello-app"
857 `)
858@@ -280,7 +281,7 @@
859 err := writeUdevRuleForDeviceCgroup(snapapp, "/dev/ttyS0")
860 c.Assert(err, IsNil)
861
862- got, err := ioutil.ReadFile(filepath.Join(snapUdevRulesDir, "70-snappy_hwassign_foo-app.rules"))
863+ got, err := ioutil.ReadFile(filepath.Join(dirs.SnapUdevRulesDir, "70-snappy_hwassign_foo-app.rules"))
864 c.Assert(err, IsNil)
865 c.Assert(string(got), Equals, `
866 KERNEL=="ttyS0", TAG:="snappy-assign", ENV{SNAPPY_APP}:="foo-app"
867@@ -299,8 +300,8 @@
868 c.Check(*regenerateAppArmorRulesWasCalled, Equals, false)
869 c.Check(RemoveAllHWAccess("hello-app"), IsNil)
870
871- c.Check(helpers.FileExists(filepath.Join(snapUdevRulesDir, "70-snappy_hwassign_foo-app.rules")), Equals, false)
872- c.Check(helpers.FileExists(filepath.Join(snapAppArmorDir, "hello-app.json.additional")), Equals, false)
873+ c.Check(helpers.FileExists(filepath.Join(dirs.SnapUdevRulesDir, "70-snappy_hwassign_foo-app.rules")), Equals, false)
874+ c.Check(helpers.FileExists(filepath.Join(dirs.SnapAppArmorDir, "hello-app.json.additional")), Equals, false)
875 c.Check(*regenerateAppArmorRulesWasCalled, Equals, true)
876 }
877
878
879=== modified file 'snappy/install_test.go'
880--- snappy/install_test.go 2015-09-29 00:32:37 +0000
881+++ snappy/install_test.go 2015-09-29 11:44:13 +0000
882@@ -30,6 +30,8 @@
883 "path/filepath"
884
885 . "gopkg.in/check.v1"
886+
887+ "launchpad.net/snappy/dirs"
888 "launchpad.net/snappy/partition"
889 "launchpad.net/snappy/progress"
890 )
891@@ -50,7 +52,7 @@
892 }
893
894 func (s *SnapTestSuite) installThree(c *C, flags InstallFlags) {
895- snapDataHomeGlob = filepath.Join(s.tempdir, "home", "*", "apps")
896+ dirs.SnapDataHomeGlob = filepath.Join(s.tempdir, "home", "*", "apps")
897 homeDir := filepath.Join(s.tempdir, "home", "user1", "apps")
898 homeData := filepath.Join(homeDir, "foo", "1.0")
899 err := os.MkdirAll(homeData, 0755)
900@@ -77,12 +79,12 @@
901 func (s *SnapTestSuite) TestClickInstallGCSimple(c *C) {
902 s.installThree(c, AllowUnauthenticated|DoInstallGC)
903
904- globs, err := filepath.Glob(filepath.Join(snapAppsDir, "foo.sideload", "*"))
905+ globs, err := filepath.Glob(filepath.Join(dirs.SnapAppsDir, "foo.sideload", "*"))
906 c.Check(err, IsNil)
907 c.Check(globs, HasLen, 2+1) // +1 for "current"
908
909 // gc should leave one more data than app
910- globs, err = filepath.Glob(filepath.Join(snapDataDir, "foo.sideload", "*"))
911+ globs, err = filepath.Glob(filepath.Join(dirs.SnapDataDir, "foo.sideload", "*"))
912 c.Check(err, IsNil)
913 c.Check(globs, HasLen, 3+1) // +1 for "current"
914 }
915@@ -91,11 +93,11 @@
916 func (s *SnapTestSuite) TestClickInstallGCSuppressed(c *C) {
917 s.installThree(c, AllowUnauthenticated)
918
919- globs, err := filepath.Glob(filepath.Join(snapAppsDir, "foo.sideload", "*"))
920+ globs, err := filepath.Glob(filepath.Join(dirs.SnapAppsDir, "foo.sideload", "*"))
921 c.Assert(err, IsNil)
922 c.Assert(globs, HasLen, 3+1) // +1 for "current"
923
924- globs, err = filepath.Glob(filepath.Join(snapDataDir, "foo.sideload", "*"))
925+ globs, err = filepath.Glob(filepath.Join(dirs.SnapDataDir, "foo.sideload", "*"))
926 c.Check(err, IsNil)
927 c.Check(globs, HasLen, 3+1) // +1 for "current"
928 }
929
930=== modified file 'snappy/oem.go'
931--- snappy/oem.go 2015-07-01 14:48:33 +0000
932+++ snappy/oem.go 2015-09-29 11:44:13 +0000
933@@ -31,6 +31,7 @@
934 "path/filepath"
935 "strings"
936
937+ "launchpad.net/snappy/dirs"
938 "launchpad.net/snappy/logger"
939 "launchpad.net/snappy/pkg"
940 )
941@@ -141,7 +142,7 @@
942 }
943
944 fileList := make(map[string]string)
945- oemPath := filepath.Join(snapOemDir, oem.Name, oem.Version)
946+ oemPath := filepath.Join(dirs.SnapOemDir, oem.Name, oem.Version)
947
948 for _, asset := range oem.OEM.Hardware.BootAssets.Files {
949 orig := filepath.Join(oemPath, asset.Path)
950@@ -184,7 +185,7 @@
951 }
952
953 func cleanupOemHardwareUdevRules(m *packageYaml) error {
954- oldFiles, err := filepath.Glob(filepath.Join(snapUdevRulesDir, fmt.Sprintf("80-snappy_%s_*.rules", m.Name)))
955+ oldFiles, err := filepath.Glob(filepath.Join(dirs.SnapUdevRulesDir, fmt.Sprintf("80-snappy_%s_*.rules", m.Name)))
956 if err != nil {
957 return err
958 }
959@@ -195,7 +196,7 @@
960
961 // cleanup the additional files
962 for _, h := range m.OEM.Hardware.Assign {
963- jsonAdditionalPath := filepath.Join(snapAppArmorDir, fmt.Sprintf("%s.json.additional", h.PartID))
964+ jsonAdditionalPath := filepath.Join(dirs.SnapAppArmorDir, fmt.Sprintf("%s.json.additional", h.PartID))
965 err = os.Remove(jsonAdditionalPath)
966 if err != nil && !os.IsNotExist(err) {
967 logger.Noticef("Failed to remove %q: %v", jsonAdditionalPath, err)
968@@ -206,7 +207,7 @@
969 }
970
971 func writeOemHardwareUdevRules(m *packageYaml) error {
972- os.MkdirAll(snapUdevRulesDir, 0755)
973+ os.MkdirAll(dirs.SnapUdevRulesDir, 0755)
974
975 // cleanup
976 if err := cleanupOemHardwareUdevRules(m); err != nil {
977@@ -218,7 +219,7 @@
978 if err != nil {
979 return err
980 }
981- outfile := filepath.Join(snapUdevRulesDir, fmt.Sprintf("80-snappy_%s_%s.rules", m.Name, h.PartID))
982+ outfile := filepath.Join(dirs.SnapUdevRulesDir, fmt.Sprintf("80-snappy_%s_%s.rules", m.Name, h.PartID))
983 if err := ioutil.WriteFile(outfile, []byte(rulesContent), 0644); err != nil {
984 return err
985 }
986@@ -262,12 +263,12 @@
987 // and the ubuntu-core-launcher is then used to generate a confinement
988 // based on the devices cgroup.
989 func writeApparmorAdditionalFile(m *packageYaml) error {
990- if err := os.MkdirAll(snapAppArmorDir, 0755); err != nil {
991+ if err := os.MkdirAll(dirs.SnapAppArmorDir, 0755); err != nil {
992 return err
993 }
994
995 for _, h := range m.OEM.Hardware.Assign {
996- jsonAdditionalPath := filepath.Join(snapAppArmorDir, fmt.Sprintf("%s.json.additional", h.PartID))
997+ jsonAdditionalPath := filepath.Join(dirs.SnapAppArmorDir, fmt.Sprintf("%s.json.additional", h.PartID))
998 if err := ioutil.WriteFile(jsonAdditionalPath, []byte(apparmorAdditionalContent), 0644); err != nil {
999 return err
1000 }
1001
1002=== modified file 'snappy/oem_test.go'
1003--- snappy/oem_test.go 2015-09-15 20:24:56 +0000
1004+++ snappy/oem_test.go 2015-09-29 11:44:13 +0000
1005@@ -26,9 +26,10 @@
1006 "io/ioutil"
1007 "path/filepath"
1008
1009+ . "gopkg.in/check.v1"
1010+
1011+ "launchpad.net/snappy/dirs"
1012 "launchpad.net/snappy/helpers"
1013-
1014- . "gopkg.in/check.v1"
1015 )
1016
1017 type OemSuite struct {
1018@@ -72,7 +73,7 @@
1019 err = writeApparmorAdditionalFile(m)
1020 c.Assert(err, IsNil)
1021
1022- content, err := ioutil.ReadFile(filepath.Join(snapAppArmorDir, "device-hive-iot-hal.json.additional"))
1023+ content, err := ioutil.ReadFile(filepath.Join(dirs.SnapAppArmorDir, "device-hive-iot-hal.json.additional"))
1024 c.Assert(err, IsNil)
1025 c.Assert(string(content), Equals, apparmorAdditionalContent)
1026 }
1027@@ -84,7 +85,7 @@
1028 err = writeApparmorAdditionalFile(m)
1029 c.Assert(err, IsNil)
1030
1031- additionalFile := filepath.Join(snapAppArmorDir, "device-hive-iot-hal.json.additional")
1032+ additionalFile := filepath.Join(dirs.SnapAppArmorDir, "device-hive-iot-hal.json.additional")
1033 c.Assert(helpers.FileExists(additionalFile), Equals, true)
1034
1035 err = cleanupOemHardwareUdevRules(m)
1036
1037=== modified file 'snappy/parts.go'
1038--- snappy/parts.go 2015-09-23 11:42:22 +0000
1039+++ snappy/parts.go 2015-09-29 11:44:13 +0000
1040@@ -27,6 +27,7 @@
1041 "strings"
1042 "time"
1043
1044+ "launchpad.net/snappy/dirs"
1045 "launchpad.net/snappy/pkg"
1046 "launchpad.net/snappy/progress"
1047 )
1048@@ -139,10 +140,10 @@
1049 if repo := NewSystemImageRepository(); repo != nil {
1050 m.all = append(m.all, repo)
1051 }
1052- if repo := NewLocalSnapRepository(snapAppsDir); repo != nil {
1053+ if repo := NewLocalSnapRepository(dirs.SnapAppsDir); repo != nil {
1054 m.all = append(m.all, repo)
1055 }
1056- if repo := NewLocalSnapRepository(snapOemDir); repo != nil {
1057+ if repo := NewLocalSnapRepository(dirs.SnapOemDir); repo != nil {
1058 m.all = append(m.all, repo)
1059 }
1060
1061@@ -347,10 +348,10 @@
1062 // iconPath returns the would be path for the local icon
1063 func iconPath(s Part) string {
1064 // TODO: care about extension ever being different than png
1065- return filepath.Join(snapIconsDir, fmt.Sprintf("%s_%s.png", QualifiedName(s), s.Version()))
1066+ return filepath.Join(dirs.SnapIconsDir, fmt.Sprintf("%s_%s.png", QualifiedName(s), s.Version()))
1067 }
1068
1069 // manifestPath returns the would be path for the store manifest meta data
1070 func manifestPath(s Part) string {
1071- return filepath.Join(snapMetaDir, fmt.Sprintf("%s_%s.manifest", QualifiedName(s), s.Version()))
1072+ return filepath.Join(dirs.SnapMetaDir, fmt.Sprintf("%s_%s.manifest", QualifiedName(s), s.Version()))
1073 }
1074
1075=== modified file 'snappy/parts_test.go'
1076--- snappy/parts_test.go 2015-09-23 11:42:22 +0000
1077+++ snappy/parts_test.go 2015-09-29 11:44:13 +0000
1078@@ -26,6 +26,7 @@
1079
1080 . "gopkg.in/check.v1"
1081
1082+ "launchpad.net/snappy/dirs"
1083 "launchpad.net/snappy/pkg"
1084 "launchpad.net/snappy/progress"
1085 )
1086@@ -96,7 +97,7 @@
1087
1088 func (s *SnapTestSuite) TestFindSnapsByNameNotAvailable(c *C) {
1089 _, err := makeInstalledMockSnap(s.tempdir, "")
1090- repo := NewLocalSnapRepository(snapAppsDir)
1091+ repo := NewLocalSnapRepository(dirs.SnapAppsDir)
1092 installed, err := repo.Installed()
1093 c.Assert(err, IsNil)
1094
1095@@ -106,7 +107,7 @@
1096
1097 func (s *SnapTestSuite) TestFindSnapsByNameFound(c *C) {
1098 _, err := makeInstalledMockSnap(s.tempdir, "")
1099- repo := NewLocalSnapRepository(snapAppsDir)
1100+ repo := NewLocalSnapRepository(dirs.SnapAppsDir)
1101 installed, err := repo.Installed()
1102 c.Assert(err, IsNil)
1103 c.Assert(installed, HasLen, 1)
1104@@ -118,7 +119,7 @@
1105
1106 func (s *SnapTestSuite) TestFindSnapsByNameWithOrigin(c *C) {
1107 _, err := makeInstalledMockSnap(s.tempdir, "")
1108- repo := NewLocalSnapRepository(snapAppsDir)
1109+ repo := NewLocalSnapRepository(dirs.SnapAppsDir)
1110 installed, err := repo.Installed()
1111 c.Assert(err, IsNil)
1112 c.Assert(installed, HasLen, 1)
1113@@ -130,7 +131,7 @@
1114
1115 func (s *SnapTestSuite) TestFindSnapsByNameWithOriginNotThere(c *C) {
1116 _, err := makeInstalledMockSnap(s.tempdir, "")
1117- repo := NewLocalSnapRepository(snapAppsDir)
1118+ repo := NewLocalSnapRepository(dirs.SnapAppsDir)
1119 installed, err := repo.Installed()
1120 c.Assert(err, IsNil)
1121 c.Assert(installed, HasLen, 1)
1122@@ -162,7 +163,7 @@
1123
1124 func (s *SnapTestSuite) TestFindSnapsByNameAndVersion(c *C) {
1125 _, err := makeInstalledMockSnap(s.tempdir, "")
1126- repo := NewLocalSnapRepository(snapAppsDir)
1127+ repo := NewLocalSnapRepository(dirs.SnapAppsDir)
1128 installed, err := repo.Installed()
1129 c.Assert(err, IsNil)
1130
1131@@ -185,7 +186,7 @@
1132
1133 func (s *SnapTestSuite) TestFindSnapsByNameAndVersionFmk(c *C) {
1134 _, err := makeInstalledMockSnap(s.tempdir, "name: fmk\ntype: framework\nversion: 1\nvendor: foo")
1135- repo := NewLocalSnapRepository(snapAppsDir)
1136+ repo := NewLocalSnapRepository(dirs.SnapAppsDir)
1137 installed, err := repo.Installed()
1138 c.Assert(err, IsNil)
1139
1140
1141=== modified file 'snappy/purge.go'
1142--- snappy/purge.go 2015-05-29 12:08:46 +0000
1143+++ snappy/purge.go 2015-09-29 11:44:13 +0000
1144@@ -23,6 +23,7 @@
1145 "fmt"
1146 "path/filepath"
1147
1148+ "launchpad.net/snappy/dirs"
1149 "launchpad.net/snappy/progress"
1150 )
1151
1152@@ -50,7 +51,7 @@
1153 var active []*SnapPart
1154
1155 for _, datadir := range datadirs {
1156- yamlPath := filepath.Join(snapAppsDir, datadir.QualifiedName(), datadir.Version, "meta", "package.yaml")
1157+ yamlPath := filepath.Join(dirs.SnapAppsDir, datadir.QualifiedName(), datadir.Version, "meta", "package.yaml")
1158 part, err := NewInstalledSnapPart(yamlPath, datadir.Origin)
1159 if err != nil {
1160 // no such part installed
1161
1162=== modified file 'snappy/purge_test.go'
1163--- snappy/purge_test.go 2015-09-29 00:32:37 +0000
1164+++ snappy/purge_test.go 2015-09-29 11:44:13 +0000
1165@@ -27,6 +27,7 @@
1166
1167 . "gopkg.in/check.v1"
1168
1169+ "launchpad.net/snappy/dirs"
1170 "launchpad.net/snappy/helpers"
1171 "launchpad.net/snappy/systemd"
1172 )
1173@@ -39,13 +40,13 @@
1174
1175 func (s *purgeSuite) SetUpTest(c *C) {
1176 s.tempdir = c.MkDir()
1177- SetRootDir(s.tempdir)
1178- os.MkdirAll(filepath.Join(snapServicesDir, "multi-user.target.wants"), 0755)
1179+ dirs.SetRootDir(s.tempdir)
1180+ os.MkdirAll(filepath.Join(dirs.SnapServicesDir, "multi-user.target.wants"), 0755)
1181 systemd.SystemctlCmd = func(cmd ...string) ([]byte, error) {
1182 return []byte("ActiveState=inactive\n"), nil
1183 }
1184
1185- snapSeccompDir = c.MkDir()
1186+ dirs.SnapSeccompDir = c.MkDir()
1187 runScFilterGen = mockRunScFilterGen
1188 }
1189
1190@@ -78,7 +79,7 @@
1191 c.Assert(os.MkdirAll(filepath.Join(pkgdir, ".click", "info"), 0755), IsNil)
1192 c.Assert(ioutil.WriteFile(filepath.Join(pkgdir, ".click", "info", app+".manifest"), []byte(`{"name": "`+app+`"}`), 0644), IsNil)
1193
1194- dataDir = filepath.Join(snapDataDir, app, version)
1195+ dataDir = filepath.Join(dirs.SnapDataDir, app, version)
1196 c.Assert(os.MkdirAll(dataDir, 0755), IsNil)
1197 canaryDataFile := filepath.Join(dataDir, "canary.txt")
1198 err = ioutil.WriteFile(canaryDataFile, []byte(""), 0644)
1199
1200=== modified file 'snappy/security.go'
1201--- snappy/security.go 2015-09-15 12:55:09 +0000
1202+++ snappy/security.go 2015-09-29 11:44:13 +0000
1203@@ -30,6 +30,7 @@
1204
1205 "gopkg.in/yaml.v2"
1206
1207+ "launchpad.net/snappy/dirs"
1208 "launchpad.net/snappy/logger"
1209 "launchpad.net/snappy/pkg"
1210 )
1211@@ -138,7 +139,7 @@
1212 return content, err
1213 }
1214
1215- os.MkdirAll(snapSeccompDir, 0755)
1216+ os.MkdirAll(dirs.SnapSeccompDir, 0755)
1217
1218 // defaults
1219 policyVendor := defaultPolicyVendor
1220@@ -187,7 +188,7 @@
1221 // Build up the command line
1222 args := []string{
1223 "sc-filtergen",
1224- fmt.Sprintf("--include-policy-dir=%s", filepath.Dir(snapSeccompDir)),
1225+ fmt.Sprintf("--include-policy-dir=%s", filepath.Dir(dirs.SnapSeccompDir)),
1226 fmt.Sprintf("--policy-vendor=%s", policyVendor),
1227 fmt.Sprintf("--policy-version=%.2f", policyVersion),
1228 fmt.Sprintf("--template=%s", template),
1229
1230=== modified file 'snappy/security_test.go'
1231--- snappy/security_test.go 2015-09-15 20:24:56 +0000
1232+++ snappy/security_test.go 2015-09-29 11:44:13 +0000
1233@@ -27,6 +27,7 @@
1234
1235 . "gopkg.in/check.v1"
1236
1237+ "launchpad.net/snappy/dirs"
1238 "launchpad.net/snappy/pkg"
1239 )
1240
1241@@ -216,7 +217,7 @@
1242 // sc-filtergen is called with mostly defaults
1243 c.Assert(a.scFilterGenCall, DeepEquals, []string{
1244 "sc-filtergen",
1245- fmt.Sprintf("--include-policy-dir=%s", filepath.Dir(snapSeccompDir)),
1246+ fmt.Sprintf("--include-policy-dir=%s", filepath.Dir(dirs.SnapSeccompDir)),
1247 "--policy-vendor=ubuntu-core",
1248 "--policy-version=15.04",
1249 "--template=something",
1250@@ -237,7 +238,7 @@
1251 // sc-filtergen is called with mostly defaults
1252 c.Assert(a.scFilterGenCall, DeepEquals, []string{
1253 "sc-filtergen",
1254- fmt.Sprintf("--include-policy-dir=%s", filepath.Dir(snapSeccompDir)),
1255+ fmt.Sprintf("--include-policy-dir=%s", filepath.Dir(dirs.SnapSeccompDir)),
1256 "--policy-vendor=ubuntu-core",
1257 "--policy-version=15.04",
1258 "--template=something",
1259@@ -269,7 +270,7 @@
1260 // sc-filtergen is called with custom seccomp options
1261 c.Assert(a.scFilterGenCall, DeepEquals, []string{
1262 "sc-filtergen",
1263- fmt.Sprintf("--include-policy-dir=%s", filepath.Dir(snapSeccompDir)),
1264+ fmt.Sprintf("--include-policy-dir=%s", filepath.Dir(dirs.SnapSeccompDir)),
1265 "--policy-vendor=policy-vendor",
1266 "--policy-version=18.10",
1267 "--template=security-template",
1268
1269=== modified file 'snappy/service.go'
1270--- snappy/service.go 2015-09-15 00:56:26 +0000
1271+++ snappy/service.go 2015-09-29 11:44:13 +0000
1272@@ -24,6 +24,7 @@
1273 "path/filepath"
1274 "time"
1275
1276+ "launchpad.net/snappy/dirs"
1277 "launchpad.net/snappy/i18n"
1278 "launchpad.net/snappy/progress"
1279 "launchpad.net/snappy/systemd"
1280@@ -105,7 +106,7 @@
1281 return &serviceActor{
1282 svcs: svcs,
1283 pb: pb,
1284- sysd: systemd.New(globalRootDir, pb),
1285+ sysd: systemd.New(dirs.GlobalRootDir, pb),
1286 }, nil
1287 }
1288
1289
1290=== modified file 'snappy/service_test.go'
1291--- snappy/service_test.go 2015-09-14 12:29:15 +0000
1292+++ snappy/service_test.go 2015-09-29 11:44:13 +0000
1293@@ -21,13 +21,14 @@
1294
1295 import (
1296 "errors"
1297+ "os"
1298+ "path/filepath"
1299
1300 . "gopkg.in/check.v1"
1301
1302+ "launchpad.net/snappy/dirs"
1303 "launchpad.net/snappy/progress"
1304 "launchpad.net/snappy/systemd"
1305- "os"
1306- "path/filepath"
1307 )
1308
1309 type ServiceActorSuite struct {
1310@@ -74,12 +75,12 @@
1311 // force UTC timezone, for reproducible timestamps
1312 os.Setenv("TZ", "")
1313
1314- SetRootDir(c.MkDir())
1315+ dirs.SetRootDir(c.MkDir())
1316 // TODO: this mkdir hack is so enable doesn't fail; remove when enable is the same as the rest
1317- c.Assert(os.MkdirAll(filepath.Join(globalRootDir, "/etc/systemd/system/multi-user.target.wants"), 0755), IsNil)
1318+ c.Assert(os.MkdirAll(filepath.Join(dirs.GlobalRootDir, "/etc/systemd/system/multi-user.target.wants"), 0755), IsNil)
1319 systemd.SystemctlCmd = s.myRun
1320 systemd.JournalctlCmd = s.myJctl
1321- makeInstalledMockSnap(globalRootDir, "")
1322+ makeInstalledMockSnap(dirs.GlobalRootDir, "")
1323 s.i = 0
1324 s.argses = nil
1325 s.errors = nil
1326@@ -98,7 +99,7 @@
1327
1328 func (s *ServiceActorSuite) TestFindServicesNoPackagesNoPattern(c *C) {
1329 // tricky way of hiding the installed package ;)
1330- SetRootDir(c.MkDir())
1331+ dirs.SetRootDir(c.MkDir())
1332 actor, err := FindServices("", "", s.pb)
1333 c.Check(err, IsNil)
1334 c.Assert(actor, NotNil)
1335
1336=== modified file 'snappy/set_test.go'
1337--- snappy/set_test.go 2015-09-29 00:32:37 +0000
1338+++ snappy/set_test.go 2015-09-29 11:44:13 +0000
1339@@ -25,6 +25,7 @@
1340
1341 . "gopkg.in/check.v1"
1342
1343+ "launchpad.net/snappy/dirs"
1344 "launchpad.net/snappy/pkg"
1345 "launchpad.net/snappy/progress"
1346 )
1347@@ -77,13 +78,13 @@
1348 func (s *SnapTestSuite) TestSetActive(c *C) {
1349 makeTwoTestSnaps(c, pkg.TypeApp)
1350
1351- path, err := filepath.EvalSymlinks(filepath.Join(snapAppsDir, fooComposedName, "current"))
1352+ path, err := filepath.EvalSymlinks(filepath.Join(dirs.SnapAppsDir, fooComposedName, "current"))
1353 c.Assert(err, IsNil)
1354- c.Check(path, Equals, filepath.Join(snapAppsDir, fooComposedName, "2.0"))
1355+ c.Check(path, Equals, filepath.Join(dirs.SnapAppsDir, fooComposedName, "2.0"))
1356
1357- path, err = filepath.EvalSymlinks(filepath.Join(snapDataDir, fooComposedName, "current"))
1358+ path, err = filepath.EvalSymlinks(filepath.Join(dirs.SnapDataDir, fooComposedName, "current"))
1359 c.Assert(err, IsNil)
1360- c.Check(path, Equals, filepath.Join(snapDataDir, fooComposedName, "2.0"))
1361+ c.Check(path, Equals, filepath.Join(dirs.SnapDataDir, fooComposedName, "2.0"))
1362
1363 meter := &MockProgressMeter{}
1364
1365@@ -98,8 +99,8 @@
1366
1367 err = makeSnapActiveByNameAndVersion("foo", "1.0", meter)
1368 c.Assert(err, IsNil)
1369- path, _ = filepath.EvalSymlinks(filepath.Join(snapAppsDir, fooComposedName, "current"))
1370- c.Check(path, Equals, filepath.Join(snapAppsDir, fooComposedName, "1.0"))
1371- path, _ = filepath.EvalSymlinks(filepath.Join(snapDataDir, fooComposedName, "current"))
1372- c.Check(path, Equals, filepath.Join(snapDataDir, fooComposedName, "1.0"))
1373+ path, _ = filepath.EvalSymlinks(filepath.Join(dirs.SnapAppsDir, fooComposedName, "current"))
1374+ c.Check(path, Equals, filepath.Join(dirs.SnapAppsDir, fooComposedName, "1.0"))
1375+ path, _ = filepath.EvalSymlinks(filepath.Join(dirs.SnapDataDir, fooComposedName, "current"))
1376+ c.Check(path, Equals, filepath.Join(dirs.SnapDataDir, fooComposedName, "1.0"))
1377 }
1378
1379=== modified file 'snappy/snapp.go'
1380--- snappy/snapp.go 2015-09-29 00:32:37 +0000
1381+++ snappy/snapp.go 2015-09-29 11:44:13 +0000
1382@@ -39,6 +39,7 @@
1383 "gopkg.in/yaml.v2"
1384
1385 "launchpad.net/snappy/clickdeb"
1386+ "launchpad.net/snappy/dirs"
1387 "launchpad.net/snappy/helpers"
1388 "launchpad.net/snappy/logger"
1389 "launchpad.net/snappy/oauth"
1390@@ -584,10 +585,10 @@
1391 return nil, err
1392 }
1393
1394- targetDir := snapAppsDir
1395+ targetDir := dirs.SnapAppsDir
1396 // the "oem" parts are special
1397 if m.Type == pkg.TypeOem {
1398- targetDir = snapOemDir
1399+ targetDir = dirs.SnapOemDir
1400 }
1401
1402 if origin == SideloadedOrigin {
1403@@ -823,7 +824,7 @@
1404 }
1405
1406 fullName := QualifiedName(s)
1407- dataDir := filepath.Join(snapDataDir, fullName, s.Version())
1408+ dataDir := filepath.Join(dirs.SnapDataDir, fullName, s.Version())
1409
1410 var oldPart *SnapPart
1411 if currentActiveDir, _ := filepath.EvalSymlinks(filepath.Join(s.basedir, "..", "current")); currentActiveDir != "" {
1412@@ -849,7 +850,7 @@
1413
1414 // we need to call the external helper so that we can reliable drop
1415 // privs
1416- if err := s.deb.UnpackWithDropPrivs(s.basedir, globalRootDir); err != nil {
1417+ if err := s.deb.UnpackWithDropPrivs(s.basedir, dirs.GlobalRootDir); err != nil {
1418 return "", err
1419 }
1420
1421@@ -926,7 +927,7 @@
1422 return "", err
1423 }
1424
1425- sysd := systemd.New(globalRootDir, inter)
1426+ sysd := systemd.New(dirs.GlobalRootDir, inter)
1427 stopped := make(map[string]time.Duration)
1428 defer func() {
1429 if err != nil {
1430@@ -1007,7 +1008,7 @@
1431 }
1432
1433 if s.Type() == pkg.TypeFramework {
1434- if err := policy.Install(s.Name(), s.basedir, globalRootDir); err != nil {
1435+ if err := policy.Install(s.Name(), s.basedir, dirs.GlobalRootDir); err != nil {
1436 return err
1437 }
1438 }
1439@@ -1036,7 +1037,7 @@
1440 logger.Noticef("Failed to remove %q: %v", currentActiveSymlink, err)
1441 }
1442
1443- dbase := filepath.Join(snapDataDir, QualifiedName(s))
1444+ dbase := filepath.Join(dirs.SnapDataDir, QualifiedName(s))
1445 currentDataSymlink := filepath.Join(dbase, "current")
1446 if err := os.Remove(currentDataSymlink); err != nil && !os.IsNotExist(err) {
1447 logger.Noticef("Failed to remove %q: %v", currentDataSymlink, err)
1448@@ -1083,7 +1084,7 @@
1449 }
1450
1451 if s.Type() == pkg.TypeFramework {
1452- if err := policy.Remove(s.Name(), s.basedir, globalRootDir); err != nil {
1453+ if err := policy.Remove(s.Name(), s.basedir, dirs.GlobalRootDir); err != nil {
1454 return err
1455 }
1456 }
1457@@ -1097,7 +1098,7 @@
1458 logger.Noticef("Failed to remove %q: %v", currentSymlink, err)
1459 }
1460
1461- currentDataSymlink := filepath.Join(snapDataDir, QualifiedName(s), "current")
1462+ currentDataSymlink := filepath.Join(dirs.SnapDataDir, QualifiedName(s), "current")
1463 if err := os.Remove(currentDataSymlink); err != nil && !os.IsNotExist(err) {
1464 logger.Noticef("Failed to remove %q: %v", currentDataSymlink, err)
1465 }
1466@@ -1279,7 +1280,7 @@
1467 var timestampUpdater = helpers.UpdateTimestamp
1468
1469 func updateAppArmorJSONTimestamp(fullName, thing, version string) error {
1470- fn := filepath.Join(snapAppArmorDir, fmt.Sprintf("%s_%s_%s.json", fullName, thing, version))
1471+ fn := filepath.Join(dirs.SnapAppArmorDir, fmt.Sprintf("%s_%s_%s.json", fullName, thing, version))
1472 return timestampUpdater(fn)
1473 }
1474
1475@@ -1591,7 +1592,7 @@
1476 }
1477
1478 func (s *RemoteSnapPart) downloadIcon(pbar progress.Meter) error {
1479- if err := os.MkdirAll(snapIconsDir, 0755); err != nil {
1480+ if err := os.MkdirAll(dirs.SnapIconsDir, 0755); err != nil {
1481 return err
1482 }
1483
1484@@ -1624,7 +1625,7 @@
1485 return err
1486 }
1487
1488- if err := os.MkdirAll(snapMetaDir, 0755); err != nil {
1489+ if err := os.MkdirAll(dirs.SnapMetaDir, 0755); err != nil {
1490 return err
1491 }
1492
1493
1494=== modified file 'snappy/snapp_test.go'
1495--- snappy/snapp_test.go 2015-09-15 20:24:56 +0000
1496+++ snappy/snapp_test.go 2015-09-29 11:44:13 +0000
1497@@ -31,6 +31,7 @@
1498 "strings"
1499
1500 "launchpad.net/snappy/clickdeb"
1501+ "launchpad.net/snappy/dirs"
1502 "launchpad.net/snappy/helpers"
1503 "launchpad.net/snappy/partition"
1504 "launchpad.net/snappy/pkg"
1505@@ -58,18 +59,18 @@
1506 return new(MockPartition)
1507 }
1508
1509- SetRootDir(s.tempdir)
1510+ dirs.SetRootDir(s.tempdir)
1511 policy.SecBase = filepath.Join(s.tempdir, "security")
1512- os.MkdirAll(snapServicesDir, 0755)
1513- os.MkdirAll(snapSeccompDir, 0755)
1514+ os.MkdirAll(dirs.SnapServicesDir, 0755)
1515+ os.MkdirAll(dirs.SnapSeccompDir, 0755)
1516
1517 release.Override(release.Release{Flavor: "core", Series: "15.04"})
1518
1519- clickSystemHooksDir = filepath.Join(s.tempdir, "/usr/share/click/hooks")
1520- os.MkdirAll(clickSystemHooksDir, 0755)
1521+ dirs.ClickSystemHooksDir = filepath.Join(s.tempdir, "/usr/share/click/hooks")
1522+ os.MkdirAll(dirs.ClickSystemHooksDir, 0755)
1523
1524 // create a fake systemd environment
1525- os.MkdirAll(filepath.Join(snapServicesDir, "multi-user.target.wants"), 0755)
1526+ os.MkdirAll(filepath.Join(dirs.SnapServicesDir, "multi-user.target.wants"), 0755)
1527
1528 // we may not have debsig-verify installed (and we don't need it
1529 // for the unittests)
1530@@ -692,12 +693,12 @@
1531 c.Assert(err, IsNil)
1532 c.Assert(installed, HasLen, 1)
1533
1534- iconPath := filepath.Join(snapIconsDir, "foo.bar_1.0.png")
1535+ iconPath := filepath.Join(dirs.SnapIconsDir, "foo.bar_1.0.png")
1536 c.Check(installed[0].Icon(), Equals, iconPath)
1537 c.Check(installed[0].Origin(), Equals, "bar")
1538 c.Check(installed[0].Description(), Equals, "this is a description")
1539
1540- _, err = os.Stat(filepath.Join(snapMetaDir, "foo.bar_1.0.manifest"))
1541+ _, err = os.Stat(filepath.Join(dirs.SnapMetaDir, "foo.bar_1.0.manifest"))
1542 c.Check(err, IsNil)
1543 }
1544
1545@@ -1118,11 +1119,11 @@
1546 c.Assert(err, IsNil)
1547 c.Assert(makeSnapActive(yamlPath), IsNil)
1548
1549- err = os.MkdirAll(snapMetaDir, 0755)
1550+ err = os.MkdirAll(dirs.SnapMetaDir, 0755)
1551 c.Assert(err, IsNil)
1552
1553 data = "name: afoo\nalias: afoo\ndescription: something nice\ndownloadsize: 10\norigin: someplace"
1554- err = ioutil.WriteFile(filepath.Join(snapMetaDir, "afoo_1.manifest"), []byte(data), 0644)
1555+ err = ioutil.WriteFile(filepath.Join(dirs.SnapMetaDir, "afoo_1.manifest"), []byte(data), 0644)
1556 c.Assert(err, IsNil)
1557
1558 snaps, err := ListInstalled()
1559@@ -1192,14 +1193,14 @@
1560 }
1561
1562 func (s *SnapTestSuite) TestRefreshDependentsSecurity(c *C) {
1563- oldDir := snapAppArmorDir
1564+ oldDir := dirs.SnapAppArmorDir
1565 defer func() {
1566- snapAppArmorDir = oldDir
1567+ dirs.SnapAppArmorDir = oldDir
1568 timestampUpdater = helpers.UpdateTimestamp
1569 }()
1570 touched := []string{}
1571- snapAppArmorDir = c.MkDir()
1572- fn := filepath.Join(snapAppArmorDir, "foo."+testOrigin+"_hello_1.0.json")
1573+ dirs.SnapAppArmorDir = c.MkDir()
1574+ fn := filepath.Join(dirs.SnapAppArmorDir, "foo."+testOrigin+"_hello_1.0.json")
1575 c.Assert(os.Symlink(fn, fn), IsNil)
1576 timestampUpdater = func(s string) error {
1577 touched = append(touched, s)
1578@@ -1457,18 +1458,18 @@
1579 m, err := parsePackageYamlData(hardwareYaml, false)
1580 c.Assert(err, IsNil)
1581
1582- snapUdevRulesDir = c.MkDir()
1583+ dirs.SnapUdevRulesDir = c.MkDir()
1584 writeOemHardwareUdevRules(m)
1585
1586- c.Assert(helpers.FileExists(filepath.Join(snapUdevRulesDir, "80-snappy_oem-foo_device-hive-iot-hal.rules")), Equals, true)
1587+ c.Assert(helpers.FileExists(filepath.Join(dirs.SnapUdevRulesDir, "80-snappy_oem-foo_device-hive-iot-hal.rules")), Equals, true)
1588 }
1589
1590 func (s *SnapTestSuite) TestWriteHardwareUdevCleanup(c *C) {
1591 m, err := parsePackageYamlData(hardwareYaml, false)
1592 c.Assert(err, IsNil)
1593
1594- snapUdevRulesDir = c.MkDir()
1595- udevRulesFile := filepath.Join(snapUdevRulesDir, "80-snappy_oem-foo_device-hive-iot-hal.rules")
1596+ dirs.SnapUdevRulesDir = c.MkDir()
1597+ udevRulesFile := filepath.Join(dirs.SnapUdevRulesDir, "80-snappy_oem-foo_device-hive-iot-hal.rules")
1598 c.Assert(ioutil.WriteFile(udevRulesFile, nil, 0644), Equals, nil)
1599 cleanupOemHardwareUdevRules(m)
1600

Subscribers

People subscribed via source and target branches