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
=== added directory 'dirs'
=== renamed file 'snappy/dirs.go' => 'dirs/dirs.go'
--- snappy/dirs.go 2015-06-30 12:36:00 +0000
+++ dirs/dirs.go 2015-09-29 11:44:13 +0000
@@ -17,58 +17,58 @@
17 *17 *
18 */18 */
1919
20package snappy20package dirs
2121
22import "path/filepath"22import "path/filepath"
2323
24// the various file paths24// the various file paths
25var (25var (
26 globalRootDir string26 GlobalRootDir string
2727
28 snapAppsDir string28 SnapAppsDir string
29 snapOemDir string29 SnapOemDir string
30 snapDataDir string30 SnapDataDir string
31 snapDataHomeGlob string31 SnapDataHomeGlob string
32 snapAppArmorDir string32 SnapAppArmorDir string
33 snapSeccompDir string33 SnapSeccompDir string
34 snapUdevRulesDir string34 SnapUdevRulesDir string
35 localeDir string35 LocaleDir string
36 snapIconsDir string36 SnapIconsDir string
37 snapMetaDir string37 SnapMetaDir string
3838
39 snapBinariesDir string39 SnapBinariesDir string
40 snapServicesDir string40 SnapServicesDir string
41 snapBusPolicyDir string41 SnapBusPolicyDir string
4242
43 clickSystemHooksDir string43 ClickSystemHooksDir string
44 cloudMetaDataFile string44 CloudMetaDataFile string
45
46 SnappyDir = filepath.Join("var", "lib", "snappy")
45)47)
4648
47var snappyDir = filepath.Join("var", "lib", "snappy")
48
49// SetRootDir allows settings a new global root directory, this is useful49// SetRootDir allows settings a new global root directory, this is useful
50// for e.g. chroot operations50// for e.g. chroot operations
51func SetRootDir(rootdir string) {51func SetRootDir(rootdir string) {
52 globalRootDir = rootdir52 GlobalRootDir = rootdir
5353
54 snapAppsDir = filepath.Join(rootdir, "/apps")54 SnapAppsDir = filepath.Join(rootdir, "/apps")
55 snapOemDir = filepath.Join(rootdir, "/oem")55 SnapOemDir = filepath.Join(rootdir, "/oem")
56 snapDataDir = filepath.Join(rootdir, "/var/lib/apps")56 SnapDataDir = filepath.Join(rootdir, "/var/lib/apps")
57 snapDataHomeGlob = filepath.Join(rootdir, "/home/*/apps/")57 SnapDataHomeGlob = filepath.Join(rootdir, "/home/*/apps/")
58 snapAppArmorDir = filepath.Join(rootdir, "/var/lib/apparmor/clicks")58 SnapAppArmorDir = filepath.Join(rootdir, "/var/lib/apparmor/clicks")
59 snapSeccompDir = filepath.Join(rootdir, snappyDir, "seccomp", "profiles")59 SnapSeccompDir = filepath.Join(rootdir, SnappyDir, "seccomp", "profiles")
60 snapIconsDir = filepath.Join(rootdir, snappyDir, "icons")60 SnapIconsDir = filepath.Join(rootdir, SnappyDir, "icons")
61 snapMetaDir = filepath.Join(rootdir, snappyDir, "meta")61 SnapMetaDir = filepath.Join(rootdir, SnappyDir, "meta")
6262
63 snapBinariesDir = filepath.Join(snapAppsDir, "bin")63 SnapBinariesDir = filepath.Join(SnapAppsDir, "bin")
64 snapServicesDir = filepath.Join(rootdir, "/etc/systemd/system")64 SnapServicesDir = filepath.Join(rootdir, "/etc/systemd/system")
65 snapBusPolicyDir = filepath.Join(rootdir, "/etc/dbus-1/system.d")65 SnapBusPolicyDir = filepath.Join(rootdir, "/etc/dbus-1/system.d")
6666
67 clickSystemHooksDir = filepath.Join(rootdir, "/usr/share/click/hooks")67 ClickSystemHooksDir = filepath.Join(rootdir, "/usr/share/click/hooks")
6868
69 cloudMetaDataFile = filepath.Join(rootdir, "/var/lib/cloud/seed/nocloud-net/meta-data")69 CloudMetaDataFile = filepath.Join(rootdir, "/var/lib/cloud/seed/nocloud-net/meta-data")
7070
71 snapUdevRulesDir = filepath.Join(rootdir, "/etc/udev/rules.d")71 SnapUdevRulesDir = filepath.Join(rootdir, "/etc/udev/rules.d")
7272
73 localeDir = filepath.Join(rootdir, "/usr/share/locale")73 LocaleDir = filepath.Join(rootdir, "/usr/share/locale")
74}74}
7575
=== modified file 'snappy/click.go'
--- snappy/click.go 2015-09-15 14:53:38 +0000
+++ snappy/click.go 2015-09-29 11:44:13 +0000
@@ -42,6 +42,7 @@
42 "time"42 "time"
4343
44 "launchpad.net/snappy/clickdeb"44 "launchpad.net/snappy/clickdeb"
45 "launchpad.net/snappy/dirs"
45 "launchpad.net/snappy/helpers"46 "launchpad.net/snappy/helpers"
46 "launchpad.net/snappy/i18n"47 "launchpad.net/snappy/i18n"
47 "launchpad.net/snappy/logger"48 "launchpad.net/snappy/logger"
@@ -154,7 +155,7 @@
154func systemClickHooks() (hooks map[string]clickHook, err error) {155func systemClickHooks() (hooks map[string]clickHook, err error) {
155 hooks = make(map[string]clickHook)156 hooks = make(map[string]clickHook)
156157
157 hookFiles, err := filepath.Glob(filepath.Join(clickSystemHooksDir, "*.hook"))158 hookFiles, err := filepath.Glob(filepath.Join(dirs.ClickSystemHooksDir, "*.hook"))
158 if err != nil {159 if err != nil {
159 return nil, err160 return nil, err
160 }161 }
@@ -206,7 +207,7 @@
206 continue207 continue
207 }208 }
208209
209 dst := filepath.Join(globalRootDir, expandHookPattern(m.qualifiedName(origin), app, m.Version, systemHook.pattern))210 dst := filepath.Join(dirs.GlobalRootDir, expandHookPattern(m.qualifiedName(origin), app, m.Version, systemHook.pattern))
210211
211 if _, err := os.Stat(dst); err == nil {212 if _, err := os.Stat(dst); err == nil {
212 if err := os.Remove(dst); err != nil {213 if err := os.Remove(dst); err != nil {
@@ -274,7 +275,7 @@
274 binName = fmt.Sprintf("%s.%s", m.Name, filepath.Base(binary.Name))275 binName = fmt.Sprintf("%s.%s", m.Name, filepath.Base(binary.Name))
275 }276 }
276277
277 return filepath.Join(snapBinariesDir, binName)278 return filepath.Join(dirs.SnapBinariesDir, binName)
278}279}
279280
280func binPathForBinary(pkgPath string, binary Binary) string {281func binPathForBinary(pkgPath string, binary Binary) string {
@@ -434,7 +435,7 @@
434 socketFileName = filepath.Base(generateSocketFileName(m, service))435 socketFileName = filepath.Base(generateSocketFileName(m, service))
435 }436 }
436437
437 return systemd.New(globalRootDir, nil).GenServiceFile(438 return systemd.New(dirs.GlobalRootDir, nil).GenServiceFile(
438 &systemd.ServiceDescription{439 &systemd.ServiceDescription{
439 AppName: m.Name,440 AppName: m.Name,
440 ServiceName: service.Name,441 ServiceName: service.Name,
@@ -462,7 +463,7 @@
462463
463 serviceFileName := filepath.Base(generateServiceFileName(m, service))464 serviceFileName := filepath.Base(generateServiceFileName(m, service))
464465
465 return systemd.New(globalRootDir, nil).GenSocketFile(466 return systemd.New(dirs.GlobalRootDir, nil).GenSocketFile(
466 &systemd.ServiceDescription{467 &systemd.ServiceDescription{
467 ServiceFileName: serviceFileName,468 ServiceFileName: serviceFileName,
468 ListenStream: service.ListenStream,469 ListenStream: service.ListenStream,
@@ -473,15 +474,15 @@
473}474}
474475
475func generateServiceFileName(m *packageYaml, service ServiceYaml) string {476func generateServiceFileName(m *packageYaml, service ServiceYaml) string {
476 return filepath.Join(snapServicesDir, fmt.Sprintf("%s_%s_%s.service", m.Name, service.Name, m.Version))477 return filepath.Join(dirs.SnapServicesDir, fmt.Sprintf("%s_%s_%s.service", m.Name, service.Name, m.Version))
477}478}
478479
479func generateSocketFileName(m *packageYaml, service ServiceYaml) string {480func generateSocketFileName(m *packageYaml, service ServiceYaml) string {
480 return filepath.Join(snapServicesDir, fmt.Sprintf("%s_%s_%s.socket", m.Name, service.Name, m.Version))481 return filepath.Join(dirs.SnapServicesDir, fmt.Sprintf("%s_%s_%s.socket", m.Name, service.Name, m.Version))
481}482}
482483
483func generateBusPolicyFileName(m *packageYaml, service ServiceYaml) string {484func generateBusPolicyFileName(m *packageYaml, service ServiceYaml) string {
484 return filepath.Join(snapBusPolicyDir, fmt.Sprintf("%s_%s_%s.conf", m.Name, service.Name, m.Version))485 return filepath.Join(dirs.SnapBusPolicyDir, fmt.Sprintf("%s_%s_%s.conf", m.Name, service.Name, m.Version))
485}486}
486487
487// takes a directory and removes the global root, this is needed488// takes a directory and removes the global root, this is needed
@@ -490,11 +491,11 @@
490var stripGlobalRootDir = stripGlobalRootDirImpl491var stripGlobalRootDir = stripGlobalRootDirImpl
491492
492func stripGlobalRootDirImpl(dir string) string {493func stripGlobalRootDirImpl(dir string) string {
493 if globalRootDir == "/" {494 if dirs.GlobalRootDir == "/" {
494 return dir495 return dir
495 }496 }
496497
497 return dir[len(globalRootDir):]498 return dir[len(dirs.GlobalRootDir):]
498}499}
499500
500func (m *packageYaml) addPackageServices(baseDir string, inhibitHooks bool, inter interacter) error {501func (m *packageYaml) addPackageServices(baseDir string, inhibitHooks bool, inter interacter) error {
@@ -549,7 +550,7 @@
549 //550 //
550 // *but* always run enable (which just sets a symlink)551 // *but* always run enable (which just sets a symlink)
551 serviceName := filepath.Base(generateServiceFileName(m, service))552 serviceName := filepath.Base(generateServiceFileName(m, service))
552 sysd := systemd.New(globalRootDir, inter)553 sysd := systemd.New(dirs.GlobalRootDir, inter)
553 if !inhibitHooks {554 if !inhibitHooks {
554 if err := sysd.DaemonReload(); err != nil {555 if err := sysd.DaemonReload(); err != nil {
555 return err556 return err
@@ -586,7 +587,7 @@
586}587}
587588
588func (m *packageYaml) removePackageServices(baseDir string, inter interacter) error {589func (m *packageYaml) removePackageServices(baseDir string, inter interacter) error {
589 sysd := systemd.New(globalRootDir, inter)590 sysd := systemd.New(dirs.GlobalRootDir, inter)
590 for _, service := range m.ServiceYamls {591 for _, service := range m.ServiceYamls {
591 serviceName := filepath.Base(generateServiceFileName(m, service))592 serviceName := filepath.Base(generateServiceFileName(m, service))
592 if err := sysd.Disable(serviceName); err != nil {593 if err := sysd.Disable(serviceName); err != nil {
@@ -628,7 +629,7 @@
628}629}
629630
630func (m *packageYaml) addPackageBinaries(baseDir string) error {631func (m *packageYaml) addPackageBinaries(baseDir string) error {
631 if err := os.MkdirAll(snapBinariesDir, 0755); err != nil {632 if err := os.MkdirAll(dirs.SnapBinariesDir, 0755); err != nil {
632 return err633 return err
633 }634 }
634635
@@ -673,7 +674,7 @@
673 return err674 return err
674 }675 }
675676
676 fn := filepath.Join(snapSeccompDir, profileName)677 fn := filepath.Join(dirs.SnapSeccompDir, profileName)
677 if err := ioutil.WriteFile(fn, content, 0644); err != nil {678 if err := ioutil.WriteFile(fn, content, 0644); err != nil {
678 return err679 return err
679 }680 }
@@ -706,7 +707,7 @@
706 if err != nil {707 if err != nil {
707 return err708 return err
708 }709 }
709 fn := filepath.Join(snapSeccompDir, profileName)710 fn := filepath.Join(dirs.SnapSeccompDir, profileName)
710 if err := os.Remove(fn); err != nil && !os.IsNotExist(err) {711 if err := os.Remove(fn); err != nil && !os.IsNotExist(err) {
711 return err712 return err
712 }713 }
@@ -799,15 +800,15 @@
799// snapDataDirs returns the list of data directories for the given snap version800// snapDataDirs returns the list of data directories for the given snap version
800func snapDataDirs(fullName, version string) ([]string, error) {801func snapDataDirs(fullName, version string) ([]string, error) {
801 // collect the directories, homes first802 // collect the directories, homes first
802 dirs, err := filepath.Glob(filepath.Join(snapDataHomeGlob, fullName, version))803 found, err := filepath.Glob(filepath.Join(dirs.SnapDataHomeGlob, fullName, version))
803 if err != nil {804 if err != nil {
804 return nil, err805 return nil, err
805 }806 }
806 // then system data807 // then system data
807 systemPath := filepath.Join(snapDataDir, fullName, version)808 systemPath := filepath.Join(dirs.SnapDataDir, fullName, version)
808 dirs = append(dirs, systemPath)809 found = append(found, systemPath)
809810
810 return dirs, nil811 return found, nil
811}812}
812813
813// Copy all data for "fullName" from "oldVersion" to "newVersion"814// Copy all data for "fullName" from "oldVersion" to "newVersion"
814815
=== modified file 'snappy/click_test.go'
--- snappy/click_test.go 2015-09-15 20:24:56 +0000
+++ snappy/click_test.go 2015-09-29 11:44:13 +0000
@@ -32,6 +32,7 @@
32 . "gopkg.in/check.v1"32 . "gopkg.in/check.v1"
3333
34 "launchpad.net/snappy/clickdeb"34 "launchpad.net/snappy/clickdeb"
35 "launchpad.net/snappy/dirs"
35 "launchpad.net/snappy/helpers"36 "launchpad.net/snappy/helpers"
36 "launchpad.net/snappy/pkg"37 "launchpad.net/snappy/pkg"
37 "launchpad.net/snappy/policy"38 "launchpad.net/snappy/policy"
@@ -78,10 +79,10 @@
78 hookName, err := cfg.Get("hook", "Hook-Name")79 hookName, err := cfg.Get("hook", "Hook-Name")
79 c.Assert(err, IsNil)80 c.Assert(err, IsNil)
8081
81 if _, err := os.Stat(clickSystemHooksDir); err != nil {82 if _, err := os.Stat(dirs.ClickSystemHooksDir); err != nil {
82 os.MkdirAll(clickSystemHooksDir, 0755)83 os.MkdirAll(dirs.ClickSystemHooksDir, 0755)
83 }84 }
84 ioutil.WriteFile(filepath.Join(clickSystemHooksDir, hookName+".hook"), []byte(hookContent), 0644)85 ioutil.WriteFile(filepath.Join(dirs.ClickSystemHooksDir, hookName+".hook"), []byte(hookContent), 0644)
85}86}
8687
87func (s *SnapTestSuite) TestReadClickHookFile(c *C) {88func (s *SnapTestSuite) TestReadClickHookFile(c *C) {
@@ -89,7 +90,7 @@
89User: root90User: root
90Exec: /usr/lib/click-systemd/systemd-clickhook91Exec: /usr/lib/click-systemd/systemd-clickhook
91Pattern: /var/lib/systemd/click/${id}`)92Pattern: /var/lib/systemd/click/${id}`)
92 hook, err := readClickHookFile(filepath.Join(clickSystemHooksDir, "systemd.hook"))93 hook, err := readClickHookFile(filepath.Join(dirs.ClickSystemHooksDir, "systemd.hook"))
93 c.Assert(err, IsNil)94 c.Assert(err, IsNil)
94 c.Assert(hook.name, Equals, "systemd")95 c.Assert(hook.name, Equals, "systemd")
95 c.Assert(hook.user, Equals, "root")96 c.Assert(hook.user, Equals, "root")
@@ -99,7 +100,7 @@
99 // click allows non-existing "Hook-Name" and uses the filename then100 // click allows non-existing "Hook-Name" and uses the filename then
100 makeClickHook(c, `Hook-Name: apparmor101 makeClickHook(c, `Hook-Name: apparmor
101Pattern: /var/lib/apparmor/click/${id}`)102Pattern: /var/lib/apparmor/click/${id}`)
102 hook, err = readClickHookFile(filepath.Join(clickSystemHooksDir, "apparmor.hook"))103 hook, err = readClickHookFile(filepath.Join(dirs.ClickSystemHooksDir, "apparmor.hook"))
103 c.Assert(err, IsNil)104 c.Assert(err, IsNil)
104 c.Assert(hook.name, Equals, "apparmor")105 c.Assert(hook.name, Equals, "apparmor")
105}106}
@@ -179,7 +180,7 @@
179 c.Assert(err, IsNil)180 c.Assert(err, IsNil)
180 c.Check(name, Equals, "foo")181 c.Check(name, Equals, "foo")
181182
182 baseDir := filepath.Join(snapAppsDir, fooComposedName, "1.0")183 baseDir := filepath.Join(dirs.SnapAppsDir, fooComposedName, "1.0")
183 contentFile := filepath.Join(baseDir, "bin", "foo")184 contentFile := filepath.Join(baseDir, "bin", "foo")
184 content, err := ioutil.ReadFile(contentFile)185 content, err := ioutil.ReadFile(contentFile)
185 c.Assert(err, IsNil)186 c.Assert(err, IsNil)
@@ -589,7 +590,7 @@
589}590}
590591
591func (s *SnapTestSuite) TestClickCopyData(c *C) {592func (s *SnapTestSuite) TestClickCopyData(c *C) {
592 snapDataHomeGlob = filepath.Join(s.tempdir, "home", "*", "apps")593 dirs.SnapDataHomeGlob = filepath.Join(s.tempdir, "home", "*", "apps")
593 homeDir := filepath.Join(s.tempdir, "home", "user1", "apps")594 homeDir := filepath.Join(s.tempdir, "home", "user1", "apps")
594 appDir := "foo." + testOrigin595 appDir := "foo." + testOrigin
595 homeData := filepath.Join(homeDir, appDir, "1.0")596 homeData := filepath.Join(homeDir, appDir, "1.0")
@@ -605,7 +606,7 @@
605 snapFile := makeTestSnapPackage(c, packageYaml+"version: 1.0")606 snapFile := makeTestSnapPackage(c, packageYaml+"version: 1.0")
606 _, err = installClick(snapFile, AllowUnauthenticated, nil, testOrigin)607 _, err = installClick(snapFile, AllowUnauthenticated, nil, testOrigin)
607 c.Assert(err, IsNil)608 c.Assert(err, IsNil)
608 canaryDataFile := filepath.Join(snapDataDir, appDir, "1.0", "canary.txt")609 canaryDataFile := filepath.Join(dirs.SnapDataDir, appDir, "1.0", "canary.txt")
609 err = ioutil.WriteFile(canaryDataFile, canaryData, 0644)610 err = ioutil.WriteFile(canaryDataFile, canaryData, 0644)
610 c.Assert(err, IsNil)611 c.Assert(err, IsNil)
611 err = ioutil.WriteFile(filepath.Join(homeData, "canary.home"), canaryData, 0644)612 err = ioutil.WriteFile(filepath.Join(homeData, "canary.home"), canaryData, 0644)
@@ -614,7 +615,7 @@
614 snapFile = makeTestSnapPackage(c, packageYaml+"version: 2.0")615 snapFile = makeTestSnapPackage(c, packageYaml+"version: 2.0")
615 _, err = installClick(snapFile, AllowUnauthenticated, nil, testOrigin)616 _, err = installClick(snapFile, AllowUnauthenticated, nil, testOrigin)
616 c.Assert(err, IsNil)617 c.Assert(err, IsNil)
617 newCanaryDataFile := filepath.Join(snapDataDir, appDir, "2.0", "canary.txt")618 newCanaryDataFile := filepath.Join(dirs.SnapDataDir, appDir, "2.0", "canary.txt")
618 content, err := ioutil.ReadFile(newCanaryDataFile)619 content, err := ioutil.ReadFile(newCanaryDataFile)
619 c.Assert(err, IsNil)620 c.Assert(err, IsNil)
620 c.Assert(content, DeepEquals, canaryData)621 c.Assert(content, DeepEquals, canaryData)
@@ -629,7 +630,7 @@
629// system data gets copied630// system data gets copied
630func (s *SnapTestSuite) TestClickCopyDataNoUserHomes(c *C) {631func (s *SnapTestSuite) TestClickCopyDataNoUserHomes(c *C) {
631 // this home dir path does not exist632 // this home dir path does not exist
632 snapDataHomeGlob = filepath.Join(s.tempdir, "no-such-home", "*", "apps")633 dirs.SnapDataHomeGlob = filepath.Join(s.tempdir, "no-such-home", "*", "apps")
633634
634 packageYaml := `name: foo635 packageYaml := `name: foo
635icon: foo.svg636icon: foo.svg
@@ -639,14 +640,14 @@
639 snapFile := makeTestSnapPackage(c, packageYaml+"version: 1.0")640 snapFile := makeTestSnapPackage(c, packageYaml+"version: 1.0")
640 _, err := installClick(snapFile, AllowUnauthenticated, nil, testOrigin)641 _, err := installClick(snapFile, AllowUnauthenticated, nil, testOrigin)
641 c.Assert(err, IsNil)642 c.Assert(err, IsNil)
642 canaryDataFile := filepath.Join(snapDataDir, appDir, "1.0", "canary.txt")643 canaryDataFile := filepath.Join(dirs.SnapDataDir, appDir, "1.0", "canary.txt")
643 err = ioutil.WriteFile(canaryDataFile, []byte(""), 0644)644 err = ioutil.WriteFile(canaryDataFile, []byte(""), 0644)
644 c.Assert(err, IsNil)645 c.Assert(err, IsNil)
645646
646 snapFile = makeTestSnapPackage(c, packageYaml+"version: 2.0")647 snapFile = makeTestSnapPackage(c, packageYaml+"version: 2.0")
647 _, err = installClick(snapFile, AllowUnauthenticated, nil, testOrigin)648 _, err = installClick(snapFile, AllowUnauthenticated, nil, testOrigin)
648 c.Assert(err, IsNil)649 c.Assert(err, IsNil)
649 _, err = os.Stat(filepath.Join(snapDataDir, appDir, "2.0", "canary.txt"))650 _, err = os.Stat(filepath.Join(dirs.SnapDataDir, appDir, "2.0", "canary.txt"))
650 c.Assert(err, IsNil)651 c.Assert(err, IsNil)
651}652}
652653
@@ -675,14 +676,14 @@
675 snapFile := makeTestSnapPackage(c, packageYaml+"version: 1.0")676 snapFile := makeTestSnapPackage(c, packageYaml+"version: 1.0")
676 _, err := installClick(snapFile, AllowUnauthenticated, nil, testOrigin)677 _, err := installClick(snapFile, AllowUnauthenticated, nil, testOrigin)
677 c.Assert(err, IsNil)678 c.Assert(err, IsNil)
678 canaryDataFile := filepath.Join(snapDataDir, appDir, "1.0", "canary.txt")679 canaryDataFile := filepath.Join(dirs.SnapDataDir, appDir, "1.0", "canary.txt")
679 err = ioutil.WriteFile(canaryDataFile, []byte(""), 0644)680 err = ioutil.WriteFile(canaryDataFile, []byte(""), 0644)
680 c.Assert(err, IsNil)681 c.Assert(err, IsNil)
681682
682 snapFile = makeTestSnapPackage(c, packageYaml+"version: 2.0")683 snapFile = makeTestSnapPackage(c, packageYaml+"version: 2.0")
683 _, err = installClick(snapFile, AllowUnauthenticated, nil, testOrigin)684 _, err = installClick(snapFile, AllowUnauthenticated, nil, testOrigin)
684 c.Assert(err, IsNil)685 c.Assert(err, IsNil)
685 _, err = os.Stat(filepath.Join(snapDataDir, appDir, "2.0", "canary.txt"))686 _, err = os.Stat(filepath.Join(dirs.SnapDataDir, appDir, "2.0", "canary.txt"))
686 c.Assert(err, IsNil)687 c.Assert(err, IsNil)
687688
688 // read the hook trace file, this shows that 1.0 was active, then689 // read the hook trace file, this shows that 1.0 was active, then
@@ -720,7 +721,7 @@
720 snapFile := makeTestSnapPackage(c, packageYaml+"version: 1.0")721 snapFile := makeTestSnapPackage(c, packageYaml+"version: 1.0")
721 _, err := installClick(snapFile, AllowUnauthenticated, nil, testOrigin)722 _, err := installClick(snapFile, AllowUnauthenticated, nil, testOrigin)
722 c.Assert(err, IsNil)723 c.Assert(err, IsNil)
723 canaryDataFile := filepath.Join(snapDataDir, appDir, "1.0", "canary.txt")724 canaryDataFile := filepath.Join(dirs.SnapDataDir, appDir, "1.0", "canary.txt")
724 err = ioutil.WriteFile(canaryDataFile, []byte(""), 0644)725 err = ioutil.WriteFile(canaryDataFile, []byte(""), 0644)
725 c.Assert(err, IsNil)726 c.Assert(err, IsNil)
726727
@@ -730,12 +731,12 @@
730731
731 // installing 2.0 will fail in the hooks,732 // installing 2.0 will fail in the hooks,
732 // so ensure we fall back to v1.0733 // so ensure we fall back to v1.0
733 content, err := ioutil.ReadFile(filepath.Join(snapAppsDir, appDir, "current", "meta", "package.yaml"))734 content, err := ioutil.ReadFile(filepath.Join(dirs.SnapAppsDir, appDir, "current", "meta", "package.yaml"))
734 c.Assert(err, IsNil)735 c.Assert(err, IsNil)
735 c.Assert(strings.Contains(string(content), "version: 1.0"), Equals, true)736 c.Assert(strings.Contains(string(content), "version: 1.0"), Equals, true)
736737
737 // no leftovers from the failed install738 // no leftovers from the failed install
738 _, err = os.Stat(filepath.Join(snapAppsDir, fooComposedName, "2.0"))739 _, err = os.Stat(filepath.Join(dirs.SnapAppsDir, fooComposedName, "2.0"))
739 c.Assert(err, NotNil)740 c.Assert(err, NotNil)
740}741}
741742
@@ -846,11 +847,11 @@
846847
847 // ensure that the binary wrapper file go generated with the right848 // ensure that the binary wrapper file go generated with the right
848 // name849 // name
849 binaryWrapper := filepath.Join(snapBinariesDir, "foo.bar")850 binaryWrapper := filepath.Join(dirs.SnapBinariesDir, "foo.bar")
850 c.Assert(helpers.FileExists(binaryWrapper), Equals, true)851 c.Assert(helpers.FileExists(binaryWrapper), Equals, true)
851852
852 // and that it gets removed on remove853 // and that it gets removed on remove
853 snapDir := filepath.Join(snapAppsDir, "foo.mvo", "1.0")854 snapDir := filepath.Join(dirs.SnapAppsDir, "foo.mvo", "1.0")
854 yamlPath := filepath.Join(snapDir, "meta", "package.yaml")855 yamlPath := filepath.Join(snapDir, "meta", "package.yaml")
855 part, err := NewInstalledSnapPart(yamlPath, testOrigin)856 part, err := NewInstalledSnapPart(yamlPath, testOrigin)
856 c.Assert(err, IsNil)857 c.Assert(err, IsNil)
@@ -873,8 +874,8 @@
873874
874 // ensure that the binary wrapper file go generated with the right875 // ensure that the binary wrapper file go generated with the right
875 // path876 // path
876 oldSnapBin := filepath.Join(snapAppsDir[len(globalRootDir):], "foo.mvo", "1.0", "bin", "bar")877 oldSnapBin := filepath.Join(dirs.SnapAppsDir[len(dirs.GlobalRootDir):], "foo.mvo", "1.0", "bin", "bar")
877 binaryWrapper := filepath.Join(snapBinariesDir, "foo.bar")878 binaryWrapper := filepath.Join(dirs.SnapBinariesDir, "foo.bar")
878 content, err := ioutil.ReadFile(binaryWrapper)879 content, err := ioutil.ReadFile(binaryWrapper)
879 c.Assert(err, IsNil)880 c.Assert(err, IsNil)
880 c.Assert(strings.Contains(string(content), oldSnapBin), Equals, true)881 c.Assert(strings.Contains(string(content), oldSnapBin), Equals, true)
@@ -883,7 +884,7 @@
883 snapFile = makeTestSnapPackage(c, packageYaml+"version: 2.0")884 snapFile = makeTestSnapPackage(c, packageYaml+"version: 2.0")
884 _, err = installClick(snapFile, AllowUnauthenticated, nil, "mvo")885 _, err = installClick(snapFile, AllowUnauthenticated, nil, "mvo")
885 c.Assert(err, IsNil)886 c.Assert(err, IsNil)
886 newSnapBin := filepath.Join(snapAppsDir[len(globalRootDir):], "foo.mvo", "2.0", "bin", "bar")887 newSnapBin := filepath.Join(dirs.SnapAppsDir[len(dirs.GlobalRootDir):], "foo.mvo", "2.0", "bin", "bar")
887 content, err = ioutil.ReadFile(binaryWrapper)888 content, err = ioutil.ReadFile(binaryWrapper)
888 c.Assert(err, IsNil)889 c.Assert(err, IsNil)
889 c.Assert(strings.Contains(string(content), newSnapBin), Equals, true)890 c.Assert(strings.Contains(string(content), newSnapBin), Equals, true)
@@ -901,7 +902,7 @@
901 _, err := installClick(snapFile, AllowUnauthenticated, nil, "mvo")902 _, err := installClick(snapFile, AllowUnauthenticated, nil, "mvo")
902 c.Assert(err, IsNil)903 c.Assert(err, IsNil)
903904
904 servicesFile := filepath.Join(snapServicesDir, "foo_service_1.0.service")905 servicesFile := filepath.Join(dirs.SnapServicesDir, "foo_service_1.0.service")
905 c.Assert(helpers.FileExists(servicesFile), Equals, true)906 c.Assert(helpers.FileExists(servicesFile), Equals, true)
906 st, err := os.Stat(servicesFile)907 st, err := os.Stat(servicesFile)
907 c.Assert(err, IsNil)908 c.Assert(err, IsNil)
@@ -909,7 +910,7 @@
909 c.Assert(st.Mode().String(), Equals, "-rw-r--r--")910 c.Assert(st.Mode().String(), Equals, "-rw-r--r--")
910911
911 // and that it gets removed on remove912 // and that it gets removed on remove
912 snapDir := filepath.Join(snapAppsDir, "foo.mvo", "1.0")913 snapDir := filepath.Join(dirs.SnapAppsDir, "foo.mvo", "1.0")
913 yamlPath := filepath.Join(snapDir, "meta", "package.yaml")914 yamlPath := filepath.Join(snapDir, "meta", "package.yaml")
914 part, err := NewInstalledSnapPart(yamlPath, testOrigin)915 part, err := NewInstalledSnapPart(yamlPath, testOrigin)
915 c.Assert(err, IsNil)916 c.Assert(err, IsNil)
@@ -945,8 +946,8 @@
945 _, err = installClick(snapFile, AllowUnauthenticated, inter, testOrigin)946 _, err = installClick(snapFile, AllowUnauthenticated, inter, testOrigin)
946 c.Assert(err, IsNil)947 c.Assert(err, IsNil)
947948
948 c.Assert(helpers.FileExists(filepath.Join(snapServicesDir, "foo_svc1_1.0.service")), Equals, true)949 c.Assert(helpers.FileExists(filepath.Join(dirs.SnapServicesDir, "foo_svc1_1.0.service")), Equals, true)
949 c.Assert(helpers.FileExists(filepath.Join(snapServicesDir, "foo_svc2_1.0.service")), Equals, true)950 c.Assert(helpers.FileExists(filepath.Join(dirs.SnapServicesDir, "foo_svc2_1.0.service")), Equals, true)
950951
951 return fmkYaml, inter952 return fmkYaml, inter
952}953}
@@ -966,12 +967,12 @@
966 c.Check(cmdlog, DeepEquals, []string{"stop", "show", "stop", "show", "start", "start"})967 c.Check(cmdlog, DeepEquals, []string{"stop", "show", "stop", "show", "start", "start"})
967968
968 // check it got set active969 // check it got set active
969 content, err := ioutil.ReadFile(filepath.Join(snapAppsDir, "fmk", "current", "meta", "package.yaml"))970 content, err := ioutil.ReadFile(filepath.Join(dirs.SnapAppsDir, "fmk", "current", "meta", "package.yaml"))
970 c.Assert(err, IsNil)971 c.Assert(err, IsNil)
971 c.Assert(strings.Contains(string(content), "version: 2"), Equals, true)972 c.Assert(strings.Contains(string(content), "version: 2"), Equals, true)
972973
973 // just in case (cf. the following tests)974 // just in case (cf. the following tests)
974 _, err = os.Stat(filepath.Join(snapAppsDir, "fmk", "2"))975 _, err = os.Stat(filepath.Join(dirs.SnapAppsDir, "fmk", "2"))
975 c.Assert(err, IsNil)976 c.Assert(err, IsNil)
976977
977}978}
@@ -995,12 +996,12 @@
995 c.Check(cmdlog, DeepEquals, []string{"stop", "show", "stop", "start"})996 c.Check(cmdlog, DeepEquals, []string{"stop", "show", "stop", "start"})
996997
997 // check it got rolled back998 // check it got rolled back
998 content, err := ioutil.ReadFile(filepath.Join(snapAppsDir, "fmk", "current", "meta", "package.yaml"))999 content, err := ioutil.ReadFile(filepath.Join(dirs.SnapAppsDir, "fmk", "current", "meta", "package.yaml"))
999 c.Assert(err, IsNil)1000 c.Assert(err, IsNil)
1000 c.Assert(strings.Contains(string(content), "version: 1"), Equals, true)1001 c.Assert(strings.Contains(string(content), "version: 1"), Equals, true)
10011002
1002 // no leftovers from the failed install1003 // no leftovers from the failed install
1003 _, err = os.Stat(filepath.Join(snapAppsDir, "fmk", "2"))1004 _, err = os.Stat(filepath.Join(dirs.SnapAppsDir, "fmk", "2"))
1004 c.Assert(err, NotNil)1005 c.Assert(err, NotNil)
1005}1006}
10061007
@@ -1026,12 +1027,12 @@
1026 })1027 })
10271028
1028 // check it got rolled back1029 // check it got rolled back
1029 content, err := ioutil.ReadFile(filepath.Join(snapAppsDir, "fmk", "current", "meta", "package.yaml"))1030 content, err := ioutil.ReadFile(filepath.Join(dirs.SnapAppsDir, "fmk", "current", "meta", "package.yaml"))
1030 c.Assert(err, IsNil)1031 c.Assert(err, IsNil)
1031 c.Assert(strings.Contains(string(content), "version: 1"), Equals, true)1032 c.Assert(strings.Contains(string(content), "version: 1"), Equals, true)
10321033
1033 // no leftovers from the failed install1034 // no leftovers from the failed install
1034 _, err = os.Stat(filepath.Join(snapAppsDir, "fmk", "2"))1035 _, err = os.Stat(filepath.Join(dirs.SnapAppsDir, "fmk", "2"))
1035 c.Assert(err, NotNil)1036 c.Assert(err, NotNil)
10361037
1037}1038}
@@ -1126,7 +1127,7 @@
1126 // ensure that even with a global rootdir the paths in the generated1127 // ensure that even with a global rootdir the paths in the generated
1127 // .services file are setup correctly (i.e. that the global root1128 // .services file are setup correctly (i.e. that the global root
1128 // is stripped)1129 // is stripped)
1129 c.Assert(globalRootDir, Not(Equals), "/")1130 c.Assert(dirs.GlobalRootDir, Not(Equals), "/")
11301131
1131 yamlFile, err := makeInstalledMockSnap(s.tempdir, "")1132 yamlFile, err := makeInstalledMockSnap(s.tempdir, "")
1132 c.Assert(err, IsNil)1133 c.Assert(err, IsNil)
@@ -1195,7 +1196,7 @@
1195 // ensure that even with a global rootdir the paths in the generated1196 // ensure that even with a global rootdir the paths in the generated
1196 // .services file are setup correctly (i.e. that the global root1197 // .services file are setup correctly (i.e. that the global root
1197 // is stripped)1198 // is stripped)
1198 c.Assert(globalRootDir, Not(Equals), "/")1199 c.Assert(dirs.GlobalRootDir, Not(Equals), "/")
11991200
1200 yamlFile, err := makeInstalledMockSnap(s.tempdir, "")1201 yamlFile, err := makeInstalledMockSnap(s.tempdir, "")
1201 c.Assert(err, IsNil)1202 c.Assert(err, IsNil)
@@ -1490,14 +1491,14 @@
1490`), false)1491`), false)
1491 c.Assert(err, IsNil)1492 c.Assert(err, IsNil)
14921493
1493 snapSeccompDir = c.MkDir()1494 dirs.SnapSeccompDir = c.MkDir()
1494 err = m.addSecurityPolicy("/apps/foo.mvo/1.0/")1495 err = m.addSecurityPolicy("/apps/foo.mvo/1.0/")
1495 c.Assert(err, IsNil)1496 c.Assert(err, IsNil)
14961497
1497 binSeccompContent, err := ioutil.ReadFile(filepath.Join(snapSeccompDir, "foo.mvo_foo_1.0"))1498 binSeccompContent, err := ioutil.ReadFile(filepath.Join(dirs.SnapSeccompDir, "foo.mvo_foo_1.0"))
1498 c.Assert(string(binSeccompContent), Equals, scFilterGenFakeResult)1499 c.Assert(string(binSeccompContent), Equals, scFilterGenFakeResult)
14991500
1500 serviceSeccompContent, err := ioutil.ReadFile(filepath.Join(snapSeccompDir, "foo.mvo_bar_1.0"))1501 serviceSeccompContent, err := ioutil.ReadFile(filepath.Join(dirs.SnapSeccompDir, "foo.mvo_bar_1.0"))
1501 c.Assert(string(serviceSeccompContent), Equals, scFilterGenFakeResult)1502 c.Assert(string(serviceSeccompContent), Equals, scFilterGenFakeResult)
15021503
1503}1504}
@@ -1514,9 +1515,9 @@
1514`), false)1515`), false)
1515 c.Assert(err, IsNil)1516 c.Assert(err, IsNil)
15161517
1517 snapSeccompDir = c.MkDir()1518 dirs.SnapSeccompDir = c.MkDir()
1518 binSeccomp := filepath.Join(snapSeccompDir, "foo.mvo_foo_1.0")1519 binSeccomp := filepath.Join(dirs.SnapSeccompDir, "foo.mvo_foo_1.0")
1519 serviceSeccomp := filepath.Join(snapSeccompDir, "foo.mvo_bar_1.0")1520 serviceSeccomp := filepath.Join(dirs.SnapSeccompDir, "foo.mvo_bar_1.0")
1520 c.Assert(helpers.FileExists(binSeccomp), Equals, false)1521 c.Assert(helpers.FileExists(binSeccomp), Equals, false)
1521 c.Assert(helpers.FileExists(serviceSeccomp), Equals, false)1522 c.Assert(helpers.FileExists(serviceSeccomp), Equals, false)
15221523
15231524
=== modified file 'snappy/datadir.go'
--- snappy/datadir.go 2015-05-20 17:24:29 +0000
+++ snappy/datadir.go 2015-09-29 11:44:13 +0000
@@ -22,6 +22,8 @@
22import (22import (
23 "path/filepath"23 "path/filepath"
24 "strings"24 "strings"
25
26 "launchpad.net/snappy/dirs"
25)27)
2628
27// A SnapDataDir represents a single data directory for a version of a package29// A SnapDataDir represents a single data directory for a version of a package
@@ -102,5 +104,5 @@
102104
103// DataDirs returns the list of all SnapDataDirs in the system.105// DataDirs returns the list of all SnapDataDirs in the system.
104func DataDirs(spec string) []SnapDataDir {106func DataDirs(spec string) []SnapDataDir {
105 return append(data1(spec, snapDataHomeGlob), data1(spec, snapDataDir)...)107 return append(data1(spec, dirs.SnapDataHomeGlob), data1(spec, dirs.SnapDataDir)...)
106}108}
107109
=== modified file 'snappy/datadir_test.go'
--- snappy/datadir_test.go 2015-06-02 20:46:07 +0000
+++ snappy/datadir_test.go 2015-09-29 11:44:13 +0000
@@ -25,6 +25,8 @@
25 "strings"25 "strings"
2626
27 . "gopkg.in/check.v1"27 . "gopkg.in/check.v1"
28
29 "launchpad.net/snappy/dirs"
28)30)
2931
30type DataDirSuite struct{}32type DataDirSuite struct{}
@@ -32,14 +34,14 @@
32var _ = Suite(&DataDirSuite{})34var _ = Suite(&DataDirSuite{})
3335
34func (s *DataDirSuite) SetUpTest(c *C) {36func (s *DataDirSuite) SetUpTest(c *C) {
35 SetRootDir(c.MkDir())37 dirs.SetRootDir(c.MkDir())
36}38}
3739
38func (s *DataDirSuite) TestSystemDataDirs(c *C) {40func (s *DataDirSuite) TestSystemDataDirs(c *C) {
39 c.Assert(os.MkdirAll(filepath.Join(snapDataDir, "foo.bar", "v1"), 0755), IsNil)41 c.Assert(os.MkdirAll(filepath.Join(dirs.SnapDataDir, "foo.bar", "v1"), 0755), IsNil)
40 dds := DataDirs("foo")42 dds := DataDirs("foo")
41 c.Check(dds, DeepEquals, []SnapDataDir{{43 c.Check(dds, DeepEquals, []SnapDataDir{{
42 Base: snapDataDir,44 Base: dirs.SnapDataDir,
43 Name: "foo",45 Name: "foo",
44 Origin: "bar",46 Origin: "bar",
45 Version: "v1",47 Version: "v1",
@@ -52,10 +54,10 @@
52}54}
5355
54func (s *DataDirSuite) TestDataDirsFramework(c *C) {56func (s *DataDirSuite) TestDataDirsFramework(c *C) {
55 c.Assert(os.MkdirAll(filepath.Join(snapDataDir, "foo", "v1"), 0755), IsNil)57 c.Assert(os.MkdirAll(filepath.Join(dirs.SnapDataDir, "foo", "v1"), 0755), IsNil)
56 dds := DataDirs("foo")58 dds := DataDirs("foo")
57 c.Check(dds, DeepEquals, []SnapDataDir{{59 c.Check(dds, DeepEquals, []SnapDataDir{{
58 Base: snapDataDir,60 Base: dirs.SnapDataDir,
59 Name: "foo",61 Name: "foo",
60 Origin: "",62 Origin: "",
61 Version: "v1",63 Version: "v1",
@@ -64,11 +66,11 @@
64}66}
6567
66func (s *DataDirSuite) TestHomeDataDirs(c *C) {68func (s *DataDirSuite) TestHomeDataDirs(c *C) {
67 home := strings.Replace(snapDataHomeGlob, "*", "user1", -1)69 home := strings.Replace(dirs.SnapDataHomeGlob, "*", "user1", -1)
68 c.Assert(os.MkdirAll(filepath.Join(home, "foo.bar", "v1"), 0755), IsNil)70 c.Assert(os.MkdirAll(filepath.Join(home, "foo.bar", "v1"), 0755), IsNil)
69 dds := DataDirs("foo")71 dds := DataDirs("foo")
70 c.Check(dds, DeepEquals, []SnapDataDir{{72 c.Check(dds, DeepEquals, []SnapDataDir{{
71 Base: snapDataHomeGlob,73 Base: dirs.SnapDataHomeGlob,
72 Name: "foo",74 Name: "foo",
73 Origin: "bar",75 Origin: "bar",
74 Version: "v1",76 Version: "v1",
@@ -76,39 +78,39 @@
76}78}
7779
78func (s *DataDirSuite) TestEverywhichwhereDataDirs(c *C) {80func (s *DataDirSuite) TestEverywhichwhereDataDirs(c *C) {
79 home := strings.Replace(snapDataHomeGlob, "*", "user1", -1)81 home := strings.Replace(dirs.SnapDataHomeGlob, "*", "user1", -1)
80 c.Assert(os.MkdirAll(filepath.Join(home, "foo.bar", "v0"), 0755), IsNil)82 c.Assert(os.MkdirAll(filepath.Join(home, "foo.bar", "v0"), 0755), IsNil)
81 c.Assert(os.MkdirAll(filepath.Join(home, "foo.bar", "v1"), 0755), IsNil)83 c.Assert(os.MkdirAll(filepath.Join(home, "foo.bar", "v1"), 0755), IsNil)
82 c.Assert(os.MkdirAll(filepath.Join(snapDataDir, "foo.xyzzy", "v1"), 0755), IsNil)84 c.Assert(os.MkdirAll(filepath.Join(dirs.SnapDataDir, "foo.xyzzy", "v1"), 0755), IsNil)
83 c.Assert(os.MkdirAll(filepath.Join(snapDataDir, "foo", "v3"), 0755), IsNil)85 c.Assert(os.MkdirAll(filepath.Join(dirs.SnapDataDir, "foo", "v3"), 0755), IsNil)
84 dds := DataDirs("foo")86 dds := DataDirs("foo")
85 c.Assert(dds, HasLen, 4)87 c.Assert(dds, HasLen, 4)
86 hi := 088 hi := 0
87 si := 289 si := 2
88 if dds[0].Base == snapDataDir {90 if dds[0].Base == dirs.SnapDataDir {
89 si = 091 si = 0
90 hi = 292 hi = 2
91 }93 }
92 c.Check(dds[hi], DeepEquals, SnapDataDir{94 c.Check(dds[hi], DeepEquals, SnapDataDir{
93 Base: snapDataHomeGlob,95 Base: dirs.SnapDataHomeGlob,
94 Name: "foo",96 Name: "foo",
95 Origin: "bar",97 Origin: "bar",
96 Version: "v0",98 Version: "v0",
97 })99 })
98 c.Check(dds[hi+1], DeepEquals, SnapDataDir{100 c.Check(dds[hi+1], DeepEquals, SnapDataDir{
99 Base: snapDataHomeGlob,101 Base: dirs.SnapDataHomeGlob,
100 Name: "foo",102 Name: "foo",
101 Origin: "bar",103 Origin: "bar",
102 Version: "v1",104 Version: "v1",
103 })105 })
104 c.Check(dds[si], DeepEquals, SnapDataDir{106 c.Check(dds[si], DeepEquals, SnapDataDir{
105 Base: snapDataDir,107 Base: dirs.SnapDataDir,
106 Name: "foo",108 Name: "foo",
107 Origin: "",109 Origin: "",
108 Version: "v3",110 Version: "v3",
109 })111 })
110 c.Check(dds[si+1], DeepEquals, SnapDataDir{112 c.Check(dds[si+1], DeepEquals, SnapDataDir{
111 Base: snapDataDir,113 Base: dirs.SnapDataDir,
112 Name: "foo",114 Name: "foo",
113 Origin: "xyzzy",115 Origin: "xyzzy",
114 Version: "v1",116 Version: "v1",
115117
=== modified file 'snappy/globals.go'
--- snappy/globals.go 2015-05-15 13:33:27 +0000
+++ snappy/globals.go 2015-09-29 11:44:13 +0000
@@ -22,6 +22,7 @@
22import (22import (
23 "os"23 "os"
2424
25 "launchpad.net/snappy/dirs"
25 "launchpad.net/snappy/release"26 "launchpad.net/snappy/release"
26)27)
2728
@@ -32,9 +33,9 @@
32 root = "/"33 root = "/"
33 }34 }
3435
35 SetRootDir(root)36 dirs.SetRootDir(root)
3637
37 // we don't need to care for the error here to take into account when38 // we don't need to care for the error here to take into account when
38 // initialized on a non snappy system39 // initialized on a non snappy system
39 release.Setup(globalRootDir)40 release.Setup(dirs.GlobalRootDir)
40}41}
4142
=== modified file 'snappy/hwaccess.go'
--- snappy/hwaccess.go 2015-09-25 12:49:25 +0000
+++ snappy/hwaccess.go 2015-09-29 11:44:13 +0000
@@ -29,6 +29,7 @@
29 "path/filepath"29 "path/filepath"
30 "strings"30 "strings"
3131
32 "launchpad.net/snappy/dirs"
32 "launchpad.net/snappy/helpers"33 "launchpad.net/snappy/helpers"
33)34)
3435
@@ -43,7 +44,7 @@
4344
44// return the json filename to add to the security json45// return the json filename to add to the security json
45func getHWAccessJSONFile(snapname string) string {46func getHWAccessJSONFile(snapname string) string {
46 return filepath.Join(snapAppArmorDir, fmt.Sprintf("%s.json.additional", snapname))47 return filepath.Join(dirs.SnapAppArmorDir, fmt.Sprintf("%s.json.additional", snapname))
47}48}
4849
49// Return true if the device string is a valid device50// Return true if the device string is a valid device
@@ -113,7 +114,7 @@
113114
114func udevRulesPathForPart(partid string) string {115func udevRulesPathForPart(partid string) string {
115 // use 70- here so that its read before the OEM rules116 // use 70- here so that its read before the OEM rules
116 return filepath.Join(snapUdevRulesDir, fmt.Sprintf("70-snappy_hwassign_%s.rules", partid))117 return filepath.Join(dirs.SnapUdevRulesDir, fmt.Sprintf("70-snappy_hwassign_%s.rules", partid))
117}118}
118119
119func addUdevRuleForSnap(snapname, newRule string) error {120func addUdevRuleForSnap(snapname, newRule string) error {
@@ -137,7 +138,7 @@
137}138}
138139
139func writeUdevRuleForDeviceCgroup(snapname, device string) error {140func writeUdevRuleForDeviceCgroup(snapname, device string) error {
140 os.MkdirAll(snapUdevRulesDir, 0755)141 os.MkdirAll(dirs.SnapUdevRulesDir, 0755)
141142
142 // the device cgroup/launcher etc support only the apps level,143 // the device cgroup/launcher etc support only the apps level,
143 // not a binary/service or version, so if we get a full144 // not a binary/service or version, so if we get a full
@@ -168,7 +169,7 @@
168 }169 }
169170
170 // check if there is anything apparmor related to add to171 // check if there is anything apparmor related to add to
171 globExpr := filepath.Join(snapAppArmorDir, fmt.Sprintf("%s_*.json", snapname))172 globExpr := filepath.Join(dirs.SnapAppArmorDir, fmt.Sprintf("%s_*.json", snapname))
172 matches, err := filepath.Glob(globExpr)173 matches, err := filepath.Glob(globExpr)
173 if err != nil {174 if err != nil {
174 return err175 return err
175176
=== modified file 'snappy/hwaccess_test.go'
--- snappy/hwaccess_test.go 2015-09-22 15:27:35 +0000
+++ snappy/hwaccess_test.go 2015-09-29 11:44:13 +0000
@@ -23,9 +23,10 @@
23 "io/ioutil"23 "io/ioutil"
24 "path/filepath"24 "path/filepath"
2525
26 . "gopkg.in/check.v1"
27
28 "launchpad.net/snappy/dirs"
26 "launchpad.net/snappy/helpers"29 "launchpad.net/snappy/helpers"
27
28 . "gopkg.in/check.v1"
29)30)
3031
31func mockRegenerateAppArmorRules() *bool {32func mockRegenerateAppArmorRules() *bool {
@@ -43,7 +44,7 @@
4344
44 err := AddHWAccess("hello-app", "/dev/ttyUSB0")45 err := AddHWAccess("hello-app", "/dev/ttyUSB0")
45 c.Assert(err, IsNil)46 c.Assert(err, IsNil)
46 content, err := ioutil.ReadFile(filepath.Join(snapAppArmorDir, "hello-app.json.additional"))47 content, err := ioutil.ReadFile(filepath.Join(dirs.SnapAppArmorDir, "hello-app.json.additional"))
47 c.Assert(err, IsNil)48 c.Assert(err, IsNil)
48 c.Assert(string(content), Equals, `{49 c.Assert(string(content), Equals, `{
49 "write_path": [50 "write_path": [
@@ -76,7 +77,7 @@
76 err = AddHWAccess("hello-app", "/sys/devices/gpio1")77 err = AddHWAccess("hello-app", "/sys/devices/gpio1")
77 c.Assert(err, IsNil)78 c.Assert(err, IsNil)
7879
79 content, err := ioutil.ReadFile(filepath.Join(snapAppArmorDir, "hello-app.json.additional"))80 content, err := ioutil.ReadFile(filepath.Join(dirs.SnapAppArmorDir, "hello-app.json.additional"))
80 c.Assert(err, IsNil)81 c.Assert(err, IsNil)
81 c.Assert(string(content), Equals, `{82 c.Assert(string(content), Equals, `{
82 "write_path": [83 "write_path": [
@@ -160,7 +161,7 @@
160161
161 // check that the udev rules file got created162 // check that the udev rules file got created
162 udevRulesFilename := "70-snappy_hwassign_hello-app.rules"163 udevRulesFilename := "70-snappy_hwassign_hello-app.rules"
163 c.Assert(helpers.FileExists(filepath.Join(snapUdevRulesDir, udevRulesFilename)), Equals, true)164 c.Assert(helpers.FileExists(filepath.Join(dirs.SnapUdevRulesDir, udevRulesFilename)), Equals, true)
164165
165 writePaths, err := ListHWAccess("hello-app")166 writePaths, err := ListHWAccess("hello-app")
166 c.Assert(err, IsNil)167 c.Assert(err, IsNil)
@@ -176,10 +177,10 @@
176 c.Assert(writePaths, HasLen, 0)177 c.Assert(writePaths, HasLen, 0)
177178
178 // check that the udev rules file got removed on unassign179 // check that the udev rules file got removed on unassign
179 c.Assert(helpers.FileExists(filepath.Join(snapUdevRulesDir, udevRulesFilename)), Equals, false)180 c.Assert(helpers.FileExists(filepath.Join(dirs.SnapUdevRulesDir, udevRulesFilename)), Equals, false)
180181
181 // check the json.additional got cleaned out182 // check the json.additional got cleaned out
182 content, err := ioutil.ReadFile(filepath.Join(snapAppArmorDir, "hello-app.json.additional"))183 content, err := ioutil.ReadFile(filepath.Join(dirs.SnapAppArmorDir, "hello-app.json.additional"))
183 c.Assert(err, IsNil)184 c.Assert(err, IsNil)
184 c.Assert(string(content), Equals, "{}\n")185 c.Assert(string(content), Equals, "{}\n")
185}186}
@@ -196,7 +197,7 @@
196 c.Assert(writePaths, DeepEquals, []string{"/dev/bar", "/dev/bar*"})197 c.Assert(writePaths, DeepEquals, []string{"/dev/bar", "/dev/bar*"})
197198
198 // check the file only lists udevReadGlob once199 // check the file only lists udevReadGlob once
199 content, err := ioutil.ReadFile(filepath.Join(snapAppArmorDir, "hello-app.json.additional"))200 content, err := ioutil.ReadFile(filepath.Join(dirs.SnapAppArmorDir, "hello-app.json.additional"))
200 c.Assert(err, IsNil)201 c.Assert(err, IsNil)
201 c.Assert(string(content), Equals, `{202 c.Assert(string(content), Equals, `{
202 "write_path": [203 "write_path": [
@@ -210,7 +211,7 @@
210`)211`)
211212
212 // check the udev rule file contains all the rules213 // check the udev rule file contains all the rules
213 content, err = ioutil.ReadFile(filepath.Join(snapUdevRulesDir, "70-snappy_hwassign_hello-app.rules"))214 content, err = ioutil.ReadFile(filepath.Join(dirs.SnapUdevRulesDir, "70-snappy_hwassign_hello-app.rules"))
214 c.Assert(err, IsNil)215 c.Assert(err, IsNil)
215 c.Assert(string(content), Equals, `216 c.Assert(string(content), Equals, `
216KERNEL=="bar", TAG:="snappy-assign", ENV{SNAPPY_APP}:="hello-app"217KERNEL=="bar", TAG:="snappy-assign", ENV{SNAPPY_APP}:="hello-app"
@@ -226,7 +227,7 @@
226 c.Assert(writePaths, DeepEquals, []string{"/dev/bar*"})227 c.Assert(writePaths, DeepEquals, []string{"/dev/bar*"})
227228
228 // check udevReadGlob is still there229 // check udevReadGlob is still there
229 content, err = ioutil.ReadFile(filepath.Join(snapAppArmorDir, "hello-app.json.additional"))230 content, err = ioutil.ReadFile(filepath.Join(dirs.SnapAppArmorDir, "hello-app.json.additional"))
230 c.Assert(err, IsNil)231 c.Assert(err, IsNil)
231 c.Assert(string(content), Equals, `{232 c.Assert(string(content), Equals, `{
232 "write_path": [233 "write_path": [
@@ -238,7 +239,7 @@
238}239}
239`)240`)
240 // check the udevReadGlob Udev rule is still there241 // check the udevReadGlob Udev rule is still there
241 content, err = ioutil.ReadFile(filepath.Join(snapUdevRulesDir, "70-snappy_hwassign_hello-app.rules"))242 content, err = ioutil.ReadFile(filepath.Join(dirs.SnapUdevRulesDir, "70-snappy_hwassign_hello-app.rules"))
242 c.Assert(err, IsNil)243 c.Assert(err, IsNil)
243 c.Assert(string(content), Equals, `KERNEL=="bar*", TAG:="snappy-assign", ENV{SNAPPY_APP}:="hello-app"244 c.Assert(string(content), Equals, `KERNEL=="bar*", TAG:="snappy-assign", ENV{SNAPPY_APP}:="hello-app"
244`)245`)
@@ -280,7 +281,7 @@
280 err := writeUdevRuleForDeviceCgroup(snapapp, "/dev/ttyS0")281 err := writeUdevRuleForDeviceCgroup(snapapp, "/dev/ttyS0")
281 c.Assert(err, IsNil)282 c.Assert(err, IsNil)
282283
283 got, err := ioutil.ReadFile(filepath.Join(snapUdevRulesDir, "70-snappy_hwassign_foo-app.rules"))284 got, err := ioutil.ReadFile(filepath.Join(dirs.SnapUdevRulesDir, "70-snappy_hwassign_foo-app.rules"))
284 c.Assert(err, IsNil)285 c.Assert(err, IsNil)
285 c.Assert(string(got), Equals, `286 c.Assert(string(got), Equals, `
286KERNEL=="ttyS0", TAG:="snappy-assign", ENV{SNAPPY_APP}:="foo-app"287KERNEL=="ttyS0", TAG:="snappy-assign", ENV{SNAPPY_APP}:="foo-app"
@@ -299,8 +300,8 @@
299 c.Check(*regenerateAppArmorRulesWasCalled, Equals, false)300 c.Check(*regenerateAppArmorRulesWasCalled, Equals, false)
300 c.Check(RemoveAllHWAccess("hello-app"), IsNil)301 c.Check(RemoveAllHWAccess("hello-app"), IsNil)
301302
302 c.Check(helpers.FileExists(filepath.Join(snapUdevRulesDir, "70-snappy_hwassign_foo-app.rules")), Equals, false)303 c.Check(helpers.FileExists(filepath.Join(dirs.SnapUdevRulesDir, "70-snappy_hwassign_foo-app.rules")), Equals, false)
303 c.Check(helpers.FileExists(filepath.Join(snapAppArmorDir, "hello-app.json.additional")), Equals, false)304 c.Check(helpers.FileExists(filepath.Join(dirs.SnapAppArmorDir, "hello-app.json.additional")), Equals, false)
304 c.Check(*regenerateAppArmorRulesWasCalled, Equals, true)305 c.Check(*regenerateAppArmorRulesWasCalled, Equals, true)
305}306}
306307
307308
=== modified file 'snappy/install_test.go'
--- snappy/install_test.go 2015-09-29 00:32:37 +0000
+++ snappy/install_test.go 2015-09-29 11:44:13 +0000
@@ -30,6 +30,8 @@
30 "path/filepath"30 "path/filepath"
3131
32 . "gopkg.in/check.v1"32 . "gopkg.in/check.v1"
33
34 "launchpad.net/snappy/dirs"
33 "launchpad.net/snappy/partition"35 "launchpad.net/snappy/partition"
34 "launchpad.net/snappy/progress"36 "launchpad.net/snappy/progress"
35)37)
@@ -50,7 +52,7 @@
50}52}
5153
52func (s *SnapTestSuite) installThree(c *C, flags InstallFlags) {54func (s *SnapTestSuite) installThree(c *C, flags InstallFlags) {
53 snapDataHomeGlob = filepath.Join(s.tempdir, "home", "*", "apps")55 dirs.SnapDataHomeGlob = filepath.Join(s.tempdir, "home", "*", "apps")
54 homeDir := filepath.Join(s.tempdir, "home", "user1", "apps")56 homeDir := filepath.Join(s.tempdir, "home", "user1", "apps")
55 homeData := filepath.Join(homeDir, "foo", "1.0")57 homeData := filepath.Join(homeDir, "foo", "1.0")
56 err := os.MkdirAll(homeData, 0755)58 err := os.MkdirAll(homeData, 0755)
@@ -77,12 +79,12 @@
77func (s *SnapTestSuite) TestClickInstallGCSimple(c *C) {79func (s *SnapTestSuite) TestClickInstallGCSimple(c *C) {
78 s.installThree(c, AllowUnauthenticated|DoInstallGC)80 s.installThree(c, AllowUnauthenticated|DoInstallGC)
7981
80 globs, err := filepath.Glob(filepath.Join(snapAppsDir, "foo.sideload", "*"))82 globs, err := filepath.Glob(filepath.Join(dirs.SnapAppsDir, "foo.sideload", "*"))
81 c.Check(err, IsNil)83 c.Check(err, IsNil)
82 c.Check(globs, HasLen, 2+1) // +1 for "current"84 c.Check(globs, HasLen, 2+1) // +1 for "current"
8385
84 // gc should leave one more data than app86 // gc should leave one more data than app
85 globs, err = filepath.Glob(filepath.Join(snapDataDir, "foo.sideload", "*"))87 globs, err = filepath.Glob(filepath.Join(dirs.SnapDataDir, "foo.sideload", "*"))
86 c.Check(err, IsNil)88 c.Check(err, IsNil)
87 c.Check(globs, HasLen, 3+1) // +1 for "current"89 c.Check(globs, HasLen, 3+1) // +1 for "current"
88}90}
@@ -91,11 +93,11 @@
91func (s *SnapTestSuite) TestClickInstallGCSuppressed(c *C) {93func (s *SnapTestSuite) TestClickInstallGCSuppressed(c *C) {
92 s.installThree(c, AllowUnauthenticated)94 s.installThree(c, AllowUnauthenticated)
9395
94 globs, err := filepath.Glob(filepath.Join(snapAppsDir, "foo.sideload", "*"))96 globs, err := filepath.Glob(filepath.Join(dirs.SnapAppsDir, "foo.sideload", "*"))
95 c.Assert(err, IsNil)97 c.Assert(err, IsNil)
96 c.Assert(globs, HasLen, 3+1) // +1 for "current"98 c.Assert(globs, HasLen, 3+1) // +1 for "current"
9799
98 globs, err = filepath.Glob(filepath.Join(snapDataDir, "foo.sideload", "*"))100 globs, err = filepath.Glob(filepath.Join(dirs.SnapDataDir, "foo.sideload", "*"))
99 c.Check(err, IsNil)101 c.Check(err, IsNil)
100 c.Check(globs, HasLen, 3+1) // +1 for "current"102 c.Check(globs, HasLen, 3+1) // +1 for "current"
101}103}
102104
=== modified file 'snappy/oem.go'
--- snappy/oem.go 2015-07-01 14:48:33 +0000
+++ snappy/oem.go 2015-09-29 11:44:13 +0000
@@ -31,6 +31,7 @@
31 "path/filepath"31 "path/filepath"
32 "strings"32 "strings"
3333
34 "launchpad.net/snappy/dirs"
34 "launchpad.net/snappy/logger"35 "launchpad.net/snappy/logger"
35 "launchpad.net/snappy/pkg"36 "launchpad.net/snappy/pkg"
36)37)
@@ -141,7 +142,7 @@
141 }142 }
142143
143 fileList := make(map[string]string)144 fileList := make(map[string]string)
144 oemPath := filepath.Join(snapOemDir, oem.Name, oem.Version)145 oemPath := filepath.Join(dirs.SnapOemDir, oem.Name, oem.Version)
145146
146 for _, asset := range oem.OEM.Hardware.BootAssets.Files {147 for _, asset := range oem.OEM.Hardware.BootAssets.Files {
147 orig := filepath.Join(oemPath, asset.Path)148 orig := filepath.Join(oemPath, asset.Path)
@@ -184,7 +185,7 @@
184}185}
185186
186func cleanupOemHardwareUdevRules(m *packageYaml) error {187func cleanupOemHardwareUdevRules(m *packageYaml) error {
187 oldFiles, err := filepath.Glob(filepath.Join(snapUdevRulesDir, fmt.Sprintf("80-snappy_%s_*.rules", m.Name)))188 oldFiles, err := filepath.Glob(filepath.Join(dirs.SnapUdevRulesDir, fmt.Sprintf("80-snappy_%s_*.rules", m.Name)))
188 if err != nil {189 if err != nil {
189 return err190 return err
190 }191 }
@@ -195,7 +196,7 @@
195196
196 // cleanup the additional files197 // cleanup the additional files
197 for _, h := range m.OEM.Hardware.Assign {198 for _, h := range m.OEM.Hardware.Assign {
198 jsonAdditionalPath := filepath.Join(snapAppArmorDir, fmt.Sprintf("%s.json.additional", h.PartID))199 jsonAdditionalPath := filepath.Join(dirs.SnapAppArmorDir, fmt.Sprintf("%s.json.additional", h.PartID))
199 err = os.Remove(jsonAdditionalPath)200 err = os.Remove(jsonAdditionalPath)
200 if err != nil && !os.IsNotExist(err) {201 if err != nil && !os.IsNotExist(err) {
201 logger.Noticef("Failed to remove %q: %v", jsonAdditionalPath, err)202 logger.Noticef("Failed to remove %q: %v", jsonAdditionalPath, err)
@@ -206,7 +207,7 @@
206}207}
207208
208func writeOemHardwareUdevRules(m *packageYaml) error {209func writeOemHardwareUdevRules(m *packageYaml) error {
209 os.MkdirAll(snapUdevRulesDir, 0755)210 os.MkdirAll(dirs.SnapUdevRulesDir, 0755)
210211
211 // cleanup212 // cleanup
212 if err := cleanupOemHardwareUdevRules(m); err != nil {213 if err := cleanupOemHardwareUdevRules(m); err != nil {
@@ -218,7 +219,7 @@
218 if err != nil {219 if err != nil {
219 return err220 return err
220 }221 }
221 outfile := filepath.Join(snapUdevRulesDir, fmt.Sprintf("80-snappy_%s_%s.rules", m.Name, h.PartID))222 outfile := filepath.Join(dirs.SnapUdevRulesDir, fmt.Sprintf("80-snappy_%s_%s.rules", m.Name, h.PartID))
222 if err := ioutil.WriteFile(outfile, []byte(rulesContent), 0644); err != nil {223 if err := ioutil.WriteFile(outfile, []byte(rulesContent), 0644); err != nil {
223 return err224 return err
224 }225 }
@@ -262,12 +263,12 @@
262// and the ubuntu-core-launcher is then used to generate a confinement263// and the ubuntu-core-launcher is then used to generate a confinement
263// based on the devices cgroup.264// based on the devices cgroup.
264func writeApparmorAdditionalFile(m *packageYaml) error {265func writeApparmorAdditionalFile(m *packageYaml) error {
265 if err := os.MkdirAll(snapAppArmorDir, 0755); err != nil {266 if err := os.MkdirAll(dirs.SnapAppArmorDir, 0755); err != nil {
266 return err267 return err
267 }268 }
268269
269 for _, h := range m.OEM.Hardware.Assign {270 for _, h := range m.OEM.Hardware.Assign {
270 jsonAdditionalPath := filepath.Join(snapAppArmorDir, fmt.Sprintf("%s.json.additional", h.PartID))271 jsonAdditionalPath := filepath.Join(dirs.SnapAppArmorDir, fmt.Sprintf("%s.json.additional", h.PartID))
271 if err := ioutil.WriteFile(jsonAdditionalPath, []byte(apparmorAdditionalContent), 0644); err != nil {272 if err := ioutil.WriteFile(jsonAdditionalPath, []byte(apparmorAdditionalContent), 0644); err != nil {
272 return err273 return err
273 }274 }
274275
=== modified file 'snappy/oem_test.go'
--- snappy/oem_test.go 2015-09-15 20:24:56 +0000
+++ snappy/oem_test.go 2015-09-29 11:44:13 +0000
@@ -26,9 +26,10 @@
26 "io/ioutil"26 "io/ioutil"
27 "path/filepath"27 "path/filepath"
2828
29 . "gopkg.in/check.v1"
30
31 "launchpad.net/snappy/dirs"
29 "launchpad.net/snappy/helpers"32 "launchpad.net/snappy/helpers"
30
31 . "gopkg.in/check.v1"
32)33)
3334
34type OemSuite struct {35type OemSuite struct {
@@ -72,7 +73,7 @@
72 err = writeApparmorAdditionalFile(m)73 err = writeApparmorAdditionalFile(m)
73 c.Assert(err, IsNil)74 c.Assert(err, IsNil)
7475
75 content, err := ioutil.ReadFile(filepath.Join(snapAppArmorDir, "device-hive-iot-hal.json.additional"))76 content, err := ioutil.ReadFile(filepath.Join(dirs.SnapAppArmorDir, "device-hive-iot-hal.json.additional"))
76 c.Assert(err, IsNil)77 c.Assert(err, IsNil)
77 c.Assert(string(content), Equals, apparmorAdditionalContent)78 c.Assert(string(content), Equals, apparmorAdditionalContent)
78}79}
@@ -84,7 +85,7 @@
84 err = writeApparmorAdditionalFile(m)85 err = writeApparmorAdditionalFile(m)
85 c.Assert(err, IsNil)86 c.Assert(err, IsNil)
8687
87 additionalFile := filepath.Join(snapAppArmorDir, "device-hive-iot-hal.json.additional")88 additionalFile := filepath.Join(dirs.SnapAppArmorDir, "device-hive-iot-hal.json.additional")
88 c.Assert(helpers.FileExists(additionalFile), Equals, true)89 c.Assert(helpers.FileExists(additionalFile), Equals, true)
8990
90 err = cleanupOemHardwareUdevRules(m)91 err = cleanupOemHardwareUdevRules(m)
9192
=== modified file 'snappy/parts.go'
--- snappy/parts.go 2015-09-23 11:42:22 +0000
+++ snappy/parts.go 2015-09-29 11:44:13 +0000
@@ -27,6 +27,7 @@
27 "strings"27 "strings"
28 "time"28 "time"
2929
30 "launchpad.net/snappy/dirs"
30 "launchpad.net/snappy/pkg"31 "launchpad.net/snappy/pkg"
31 "launchpad.net/snappy/progress"32 "launchpad.net/snappy/progress"
32)33)
@@ -139,10 +140,10 @@
139 if repo := NewSystemImageRepository(); repo != nil {140 if repo := NewSystemImageRepository(); repo != nil {
140 m.all = append(m.all, repo)141 m.all = append(m.all, repo)
141 }142 }
142 if repo := NewLocalSnapRepository(snapAppsDir); repo != nil {143 if repo := NewLocalSnapRepository(dirs.SnapAppsDir); repo != nil {
143 m.all = append(m.all, repo)144 m.all = append(m.all, repo)
144 }145 }
145 if repo := NewLocalSnapRepository(snapOemDir); repo != nil {146 if repo := NewLocalSnapRepository(dirs.SnapOemDir); repo != nil {
146 m.all = append(m.all, repo)147 m.all = append(m.all, repo)
147 }148 }
148149
@@ -347,10 +348,10 @@
347// iconPath returns the would be path for the local icon348// iconPath returns the would be path for the local icon
348func iconPath(s Part) string {349func iconPath(s Part) string {
349 // TODO: care about extension ever being different than png350 // TODO: care about extension ever being different than png
350 return filepath.Join(snapIconsDir, fmt.Sprintf("%s_%s.png", QualifiedName(s), s.Version()))351 return filepath.Join(dirs.SnapIconsDir, fmt.Sprintf("%s_%s.png", QualifiedName(s), s.Version()))
351}352}
352353
353// manifestPath returns the would be path for the store manifest meta data354// manifestPath returns the would be path for the store manifest meta data
354func manifestPath(s Part) string {355func manifestPath(s Part) string {
355 return filepath.Join(snapMetaDir, fmt.Sprintf("%s_%s.manifest", QualifiedName(s), s.Version()))356 return filepath.Join(dirs.SnapMetaDir, fmt.Sprintf("%s_%s.manifest", QualifiedName(s), s.Version()))
356}357}
357358
=== modified file 'snappy/parts_test.go'
--- snappy/parts_test.go 2015-09-23 11:42:22 +0000
+++ snappy/parts_test.go 2015-09-29 11:44:13 +0000
@@ -26,6 +26,7 @@
2626
27 . "gopkg.in/check.v1"27 . "gopkg.in/check.v1"
2828
29 "launchpad.net/snappy/dirs"
29 "launchpad.net/snappy/pkg"30 "launchpad.net/snappy/pkg"
30 "launchpad.net/snappy/progress"31 "launchpad.net/snappy/progress"
31)32)
@@ -96,7 +97,7 @@
9697
97func (s *SnapTestSuite) TestFindSnapsByNameNotAvailable(c *C) {98func (s *SnapTestSuite) TestFindSnapsByNameNotAvailable(c *C) {
98 _, err := makeInstalledMockSnap(s.tempdir, "")99 _, err := makeInstalledMockSnap(s.tempdir, "")
99 repo := NewLocalSnapRepository(snapAppsDir)100 repo := NewLocalSnapRepository(dirs.SnapAppsDir)
100 installed, err := repo.Installed()101 installed, err := repo.Installed()
101 c.Assert(err, IsNil)102 c.Assert(err, IsNil)
102103
@@ -106,7 +107,7 @@
106107
107func (s *SnapTestSuite) TestFindSnapsByNameFound(c *C) {108func (s *SnapTestSuite) TestFindSnapsByNameFound(c *C) {
108 _, err := makeInstalledMockSnap(s.tempdir, "")109 _, err := makeInstalledMockSnap(s.tempdir, "")
109 repo := NewLocalSnapRepository(snapAppsDir)110 repo := NewLocalSnapRepository(dirs.SnapAppsDir)
110 installed, err := repo.Installed()111 installed, err := repo.Installed()
111 c.Assert(err, IsNil)112 c.Assert(err, IsNil)
112 c.Assert(installed, HasLen, 1)113 c.Assert(installed, HasLen, 1)
@@ -118,7 +119,7 @@
118119
119func (s *SnapTestSuite) TestFindSnapsByNameWithOrigin(c *C) {120func (s *SnapTestSuite) TestFindSnapsByNameWithOrigin(c *C) {
120 _, err := makeInstalledMockSnap(s.tempdir, "")121 _, err := makeInstalledMockSnap(s.tempdir, "")
121 repo := NewLocalSnapRepository(snapAppsDir)122 repo := NewLocalSnapRepository(dirs.SnapAppsDir)
122 installed, err := repo.Installed()123 installed, err := repo.Installed()
123 c.Assert(err, IsNil)124 c.Assert(err, IsNil)
124 c.Assert(installed, HasLen, 1)125 c.Assert(installed, HasLen, 1)
@@ -130,7 +131,7 @@
130131
131func (s *SnapTestSuite) TestFindSnapsByNameWithOriginNotThere(c *C) {132func (s *SnapTestSuite) TestFindSnapsByNameWithOriginNotThere(c *C) {
132 _, err := makeInstalledMockSnap(s.tempdir, "")133 _, err := makeInstalledMockSnap(s.tempdir, "")
133 repo := NewLocalSnapRepository(snapAppsDir)134 repo := NewLocalSnapRepository(dirs.SnapAppsDir)
134 installed, err := repo.Installed()135 installed, err := repo.Installed()
135 c.Assert(err, IsNil)136 c.Assert(err, IsNil)
136 c.Assert(installed, HasLen, 1)137 c.Assert(installed, HasLen, 1)
@@ -162,7 +163,7 @@
162163
163func (s *SnapTestSuite) TestFindSnapsByNameAndVersion(c *C) {164func (s *SnapTestSuite) TestFindSnapsByNameAndVersion(c *C) {
164 _, err := makeInstalledMockSnap(s.tempdir, "")165 _, err := makeInstalledMockSnap(s.tempdir, "")
165 repo := NewLocalSnapRepository(snapAppsDir)166 repo := NewLocalSnapRepository(dirs.SnapAppsDir)
166 installed, err := repo.Installed()167 installed, err := repo.Installed()
167 c.Assert(err, IsNil)168 c.Assert(err, IsNil)
168169
@@ -185,7 +186,7 @@
185186
186func (s *SnapTestSuite) TestFindSnapsByNameAndVersionFmk(c *C) {187func (s *SnapTestSuite) TestFindSnapsByNameAndVersionFmk(c *C) {
187 _, err := makeInstalledMockSnap(s.tempdir, "name: fmk\ntype: framework\nversion: 1\nvendor: foo")188 _, err := makeInstalledMockSnap(s.tempdir, "name: fmk\ntype: framework\nversion: 1\nvendor: foo")
188 repo := NewLocalSnapRepository(snapAppsDir)189 repo := NewLocalSnapRepository(dirs.SnapAppsDir)
189 installed, err := repo.Installed()190 installed, err := repo.Installed()
190 c.Assert(err, IsNil)191 c.Assert(err, IsNil)
191192
192193
=== modified file 'snappy/purge.go'
--- snappy/purge.go 2015-05-29 12:08:46 +0000
+++ snappy/purge.go 2015-09-29 11:44:13 +0000
@@ -23,6 +23,7 @@
23 "fmt"23 "fmt"
24 "path/filepath"24 "path/filepath"
2525
26 "launchpad.net/snappy/dirs"
26 "launchpad.net/snappy/progress"27 "launchpad.net/snappy/progress"
27)28)
2829
@@ -50,7 +51,7 @@
50 var active []*SnapPart51 var active []*SnapPart
5152
52 for _, datadir := range datadirs {53 for _, datadir := range datadirs {
53 yamlPath := filepath.Join(snapAppsDir, datadir.QualifiedName(), datadir.Version, "meta", "package.yaml")54 yamlPath := filepath.Join(dirs.SnapAppsDir, datadir.QualifiedName(), datadir.Version, "meta", "package.yaml")
54 part, err := NewInstalledSnapPart(yamlPath, datadir.Origin)55 part, err := NewInstalledSnapPart(yamlPath, datadir.Origin)
55 if err != nil {56 if err != nil {
56 // no such part installed57 // no such part installed
5758
=== modified file 'snappy/purge_test.go'
--- snappy/purge_test.go 2015-09-29 00:32:37 +0000
+++ snappy/purge_test.go 2015-09-29 11:44:13 +0000
@@ -27,6 +27,7 @@
2727
28 . "gopkg.in/check.v1"28 . "gopkg.in/check.v1"
2929
30 "launchpad.net/snappy/dirs"
30 "launchpad.net/snappy/helpers"31 "launchpad.net/snappy/helpers"
31 "launchpad.net/snappy/systemd"32 "launchpad.net/snappy/systemd"
32)33)
@@ -39,13 +40,13 @@
3940
40func (s *purgeSuite) SetUpTest(c *C) {41func (s *purgeSuite) SetUpTest(c *C) {
41 s.tempdir = c.MkDir()42 s.tempdir = c.MkDir()
42 SetRootDir(s.tempdir)43 dirs.SetRootDir(s.tempdir)
43 os.MkdirAll(filepath.Join(snapServicesDir, "multi-user.target.wants"), 0755)44 os.MkdirAll(filepath.Join(dirs.SnapServicesDir, "multi-user.target.wants"), 0755)
44 systemd.SystemctlCmd = func(cmd ...string) ([]byte, error) {45 systemd.SystemctlCmd = func(cmd ...string) ([]byte, error) {
45 return []byte("ActiveState=inactive\n"), nil46 return []byte("ActiveState=inactive\n"), nil
46 }47 }
4748
48 snapSeccompDir = c.MkDir()49 dirs.SnapSeccompDir = c.MkDir()
49 runScFilterGen = mockRunScFilterGen50 runScFilterGen = mockRunScFilterGen
50}51}
5152
@@ -78,7 +79,7 @@
78 c.Assert(os.MkdirAll(filepath.Join(pkgdir, ".click", "info"), 0755), IsNil)79 c.Assert(os.MkdirAll(filepath.Join(pkgdir, ".click", "info"), 0755), IsNil)
79 c.Assert(ioutil.WriteFile(filepath.Join(pkgdir, ".click", "info", app+".manifest"), []byte(`{"name": "`+app+`"}`), 0644), IsNil)80 c.Assert(ioutil.WriteFile(filepath.Join(pkgdir, ".click", "info", app+".manifest"), []byte(`{"name": "`+app+`"}`), 0644), IsNil)
8081
81 dataDir = filepath.Join(snapDataDir, app, version)82 dataDir = filepath.Join(dirs.SnapDataDir, app, version)
82 c.Assert(os.MkdirAll(dataDir, 0755), IsNil)83 c.Assert(os.MkdirAll(dataDir, 0755), IsNil)
83 canaryDataFile := filepath.Join(dataDir, "canary.txt")84 canaryDataFile := filepath.Join(dataDir, "canary.txt")
84 err = ioutil.WriteFile(canaryDataFile, []byte(""), 0644)85 err = ioutil.WriteFile(canaryDataFile, []byte(""), 0644)
8586
=== modified file 'snappy/security.go'
--- snappy/security.go 2015-09-15 12:55:09 +0000
+++ snappy/security.go 2015-09-29 11:44:13 +0000
@@ -30,6 +30,7 @@
3030
31 "gopkg.in/yaml.v2"31 "gopkg.in/yaml.v2"
3232
33 "launchpad.net/snappy/dirs"
33 "launchpad.net/snappy/logger"34 "launchpad.net/snappy/logger"
34 "launchpad.net/snappy/pkg"35 "launchpad.net/snappy/pkg"
35)36)
@@ -138,7 +139,7 @@
138 return content, err139 return content, err
139 }140 }
140141
141 os.MkdirAll(snapSeccompDir, 0755)142 os.MkdirAll(dirs.SnapSeccompDir, 0755)
142143
143 // defaults144 // defaults
144 policyVendor := defaultPolicyVendor145 policyVendor := defaultPolicyVendor
@@ -187,7 +188,7 @@
187 // Build up the command line188 // Build up the command line
188 args := []string{189 args := []string{
189 "sc-filtergen",190 "sc-filtergen",
190 fmt.Sprintf("--include-policy-dir=%s", filepath.Dir(snapSeccompDir)),191 fmt.Sprintf("--include-policy-dir=%s", filepath.Dir(dirs.SnapSeccompDir)),
191 fmt.Sprintf("--policy-vendor=%s", policyVendor),192 fmt.Sprintf("--policy-vendor=%s", policyVendor),
192 fmt.Sprintf("--policy-version=%.2f", policyVersion),193 fmt.Sprintf("--policy-version=%.2f", policyVersion),
193 fmt.Sprintf("--template=%s", template),194 fmt.Sprintf("--template=%s", template),
194195
=== modified file 'snappy/security_test.go'
--- snappy/security_test.go 2015-09-15 20:24:56 +0000
+++ snappy/security_test.go 2015-09-29 11:44:13 +0000
@@ -27,6 +27,7 @@
2727
28 . "gopkg.in/check.v1"28 . "gopkg.in/check.v1"
2929
30 "launchpad.net/snappy/dirs"
30 "launchpad.net/snappy/pkg"31 "launchpad.net/snappy/pkg"
31)32)
3233
@@ -216,7 +217,7 @@
216 // sc-filtergen is called with mostly defaults217 // sc-filtergen is called with mostly defaults
217 c.Assert(a.scFilterGenCall, DeepEquals, []string{218 c.Assert(a.scFilterGenCall, DeepEquals, []string{
218 "sc-filtergen",219 "sc-filtergen",
219 fmt.Sprintf("--include-policy-dir=%s", filepath.Dir(snapSeccompDir)),220 fmt.Sprintf("--include-policy-dir=%s", filepath.Dir(dirs.SnapSeccompDir)),
220 "--policy-vendor=ubuntu-core",221 "--policy-vendor=ubuntu-core",
221 "--policy-version=15.04",222 "--policy-version=15.04",
222 "--template=something",223 "--template=something",
@@ -237,7 +238,7 @@
237 // sc-filtergen is called with mostly defaults238 // sc-filtergen is called with mostly defaults
238 c.Assert(a.scFilterGenCall, DeepEquals, []string{239 c.Assert(a.scFilterGenCall, DeepEquals, []string{
239 "sc-filtergen",240 "sc-filtergen",
240 fmt.Sprintf("--include-policy-dir=%s", filepath.Dir(snapSeccompDir)),241 fmt.Sprintf("--include-policy-dir=%s", filepath.Dir(dirs.SnapSeccompDir)),
241 "--policy-vendor=ubuntu-core",242 "--policy-vendor=ubuntu-core",
242 "--policy-version=15.04",243 "--policy-version=15.04",
243 "--template=something",244 "--template=something",
@@ -269,7 +270,7 @@
269 // sc-filtergen is called with custom seccomp options270 // sc-filtergen is called with custom seccomp options
270 c.Assert(a.scFilterGenCall, DeepEquals, []string{271 c.Assert(a.scFilterGenCall, DeepEquals, []string{
271 "sc-filtergen",272 "sc-filtergen",
272 fmt.Sprintf("--include-policy-dir=%s", filepath.Dir(snapSeccompDir)),273 fmt.Sprintf("--include-policy-dir=%s", filepath.Dir(dirs.SnapSeccompDir)),
273 "--policy-vendor=policy-vendor",274 "--policy-vendor=policy-vendor",
274 "--policy-version=18.10",275 "--policy-version=18.10",
275 "--template=security-template",276 "--template=security-template",
276277
=== modified file 'snappy/service.go'
--- snappy/service.go 2015-09-15 00:56:26 +0000
+++ snappy/service.go 2015-09-29 11:44:13 +0000
@@ -24,6 +24,7 @@
24 "path/filepath"24 "path/filepath"
25 "time"25 "time"
2626
27 "launchpad.net/snappy/dirs"
27 "launchpad.net/snappy/i18n"28 "launchpad.net/snappy/i18n"
28 "launchpad.net/snappy/progress"29 "launchpad.net/snappy/progress"
29 "launchpad.net/snappy/systemd"30 "launchpad.net/snappy/systemd"
@@ -105,7 +106,7 @@
105 return &serviceActor{106 return &serviceActor{
106 svcs: svcs,107 svcs: svcs,
107 pb: pb,108 pb: pb,
108 sysd: systemd.New(globalRootDir, pb),109 sysd: systemd.New(dirs.GlobalRootDir, pb),
109 }, nil110 }, nil
110}111}
111112
112113
=== modified file 'snappy/service_test.go'
--- snappy/service_test.go 2015-09-14 12:29:15 +0000
+++ snappy/service_test.go 2015-09-29 11:44:13 +0000
@@ -21,13 +21,14 @@
2121
22import (22import (
23 "errors"23 "errors"
24 "os"
25 "path/filepath"
2426
25 . "gopkg.in/check.v1"27 . "gopkg.in/check.v1"
2628
29 "launchpad.net/snappy/dirs"
27 "launchpad.net/snappy/progress"30 "launchpad.net/snappy/progress"
28 "launchpad.net/snappy/systemd"31 "launchpad.net/snappy/systemd"
29 "os"
30 "path/filepath"
31)32)
3233
33type ServiceActorSuite struct {34type ServiceActorSuite struct {
@@ -74,12 +75,12 @@
74 // force UTC timezone, for reproducible timestamps75 // force UTC timezone, for reproducible timestamps
75 os.Setenv("TZ", "")76 os.Setenv("TZ", "")
7677
77 SetRootDir(c.MkDir())78 dirs.SetRootDir(c.MkDir())
78 // TODO: this mkdir hack is so enable doesn't fail; remove when enable is the same as the rest79 // TODO: this mkdir hack is so enable doesn't fail; remove when enable is the same as the rest
79 c.Assert(os.MkdirAll(filepath.Join(globalRootDir, "/etc/systemd/system/multi-user.target.wants"), 0755), IsNil)80 c.Assert(os.MkdirAll(filepath.Join(dirs.GlobalRootDir, "/etc/systemd/system/multi-user.target.wants"), 0755), IsNil)
80 systemd.SystemctlCmd = s.myRun81 systemd.SystemctlCmd = s.myRun
81 systemd.JournalctlCmd = s.myJctl82 systemd.JournalctlCmd = s.myJctl
82 makeInstalledMockSnap(globalRootDir, "")83 makeInstalledMockSnap(dirs.GlobalRootDir, "")
83 s.i = 084 s.i = 0
84 s.argses = nil85 s.argses = nil
85 s.errors = nil86 s.errors = nil
@@ -98,7 +99,7 @@
9899
99func (s *ServiceActorSuite) TestFindServicesNoPackagesNoPattern(c *C) {100func (s *ServiceActorSuite) TestFindServicesNoPackagesNoPattern(c *C) {
100 // tricky way of hiding the installed package ;)101 // tricky way of hiding the installed package ;)
101 SetRootDir(c.MkDir())102 dirs.SetRootDir(c.MkDir())
102 actor, err := FindServices("", "", s.pb)103 actor, err := FindServices("", "", s.pb)
103 c.Check(err, IsNil)104 c.Check(err, IsNil)
104 c.Assert(actor, NotNil)105 c.Assert(actor, NotNil)
105106
=== modified file 'snappy/set_test.go'
--- snappy/set_test.go 2015-09-29 00:32:37 +0000
+++ snappy/set_test.go 2015-09-29 11:44:13 +0000
@@ -25,6 +25,7 @@
2525
26 . "gopkg.in/check.v1"26 . "gopkg.in/check.v1"
2727
28 "launchpad.net/snappy/dirs"
28 "launchpad.net/snappy/pkg"29 "launchpad.net/snappy/pkg"
29 "launchpad.net/snappy/progress"30 "launchpad.net/snappy/progress"
30)31)
@@ -77,13 +78,13 @@
77func (s *SnapTestSuite) TestSetActive(c *C) {78func (s *SnapTestSuite) TestSetActive(c *C) {
78 makeTwoTestSnaps(c, pkg.TypeApp)79 makeTwoTestSnaps(c, pkg.TypeApp)
7980
80 path, err := filepath.EvalSymlinks(filepath.Join(snapAppsDir, fooComposedName, "current"))81 path, err := filepath.EvalSymlinks(filepath.Join(dirs.SnapAppsDir, fooComposedName, "current"))
81 c.Assert(err, IsNil)82 c.Assert(err, IsNil)
82 c.Check(path, Equals, filepath.Join(snapAppsDir, fooComposedName, "2.0"))83 c.Check(path, Equals, filepath.Join(dirs.SnapAppsDir, fooComposedName, "2.0"))
8384
84 path, err = filepath.EvalSymlinks(filepath.Join(snapDataDir, fooComposedName, "current"))85 path, err = filepath.EvalSymlinks(filepath.Join(dirs.SnapDataDir, fooComposedName, "current"))
85 c.Assert(err, IsNil)86 c.Assert(err, IsNil)
86 c.Check(path, Equals, filepath.Join(snapDataDir, fooComposedName, "2.0"))87 c.Check(path, Equals, filepath.Join(dirs.SnapDataDir, fooComposedName, "2.0"))
8788
88 meter := &MockProgressMeter{}89 meter := &MockProgressMeter{}
8990
@@ -98,8 +99,8 @@
9899
99 err = makeSnapActiveByNameAndVersion("foo", "1.0", meter)100 err = makeSnapActiveByNameAndVersion("foo", "1.0", meter)
100 c.Assert(err, IsNil)101 c.Assert(err, IsNil)
101 path, _ = filepath.EvalSymlinks(filepath.Join(snapAppsDir, fooComposedName, "current"))102 path, _ = filepath.EvalSymlinks(filepath.Join(dirs.SnapAppsDir, fooComposedName, "current"))
102 c.Check(path, Equals, filepath.Join(snapAppsDir, fooComposedName, "1.0"))103 c.Check(path, Equals, filepath.Join(dirs.SnapAppsDir, fooComposedName, "1.0"))
103 path, _ = filepath.EvalSymlinks(filepath.Join(snapDataDir, fooComposedName, "current"))104 path, _ = filepath.EvalSymlinks(filepath.Join(dirs.SnapDataDir, fooComposedName, "current"))
104 c.Check(path, Equals, filepath.Join(snapDataDir, fooComposedName, "1.0"))105 c.Check(path, Equals, filepath.Join(dirs.SnapDataDir, fooComposedName, "1.0"))
105}106}
106107
=== modified file 'snappy/snapp.go'
--- snappy/snapp.go 2015-09-29 00:32:37 +0000
+++ snappy/snapp.go 2015-09-29 11:44:13 +0000
@@ -39,6 +39,7 @@
39 "gopkg.in/yaml.v2"39 "gopkg.in/yaml.v2"
4040
41 "launchpad.net/snappy/clickdeb"41 "launchpad.net/snappy/clickdeb"
42 "launchpad.net/snappy/dirs"
42 "launchpad.net/snappy/helpers"43 "launchpad.net/snappy/helpers"
43 "launchpad.net/snappy/logger"44 "launchpad.net/snappy/logger"
44 "launchpad.net/snappy/oauth"45 "launchpad.net/snappy/oauth"
@@ -584,10 +585,10 @@
584 return nil, err585 return nil, err
585 }586 }
586587
587 targetDir := snapAppsDir588 targetDir := dirs.SnapAppsDir
588 // the "oem" parts are special589 // the "oem" parts are special
589 if m.Type == pkg.TypeOem {590 if m.Type == pkg.TypeOem {
590 targetDir = snapOemDir591 targetDir = dirs.SnapOemDir
591 }592 }
592593
593 if origin == SideloadedOrigin {594 if origin == SideloadedOrigin {
@@ -823,7 +824,7 @@
823 }824 }
824825
825 fullName := QualifiedName(s)826 fullName := QualifiedName(s)
826 dataDir := filepath.Join(snapDataDir, fullName, s.Version())827 dataDir := filepath.Join(dirs.SnapDataDir, fullName, s.Version())
827828
828 var oldPart *SnapPart829 var oldPart *SnapPart
829 if currentActiveDir, _ := filepath.EvalSymlinks(filepath.Join(s.basedir, "..", "current")); currentActiveDir != "" {830 if currentActiveDir, _ := filepath.EvalSymlinks(filepath.Join(s.basedir, "..", "current")); currentActiveDir != "" {
@@ -849,7 +850,7 @@
849850
850 // we need to call the external helper so that we can reliable drop851 // we need to call the external helper so that we can reliable drop
851 // privs852 // privs
852 if err := s.deb.UnpackWithDropPrivs(s.basedir, globalRootDir); err != nil {853 if err := s.deb.UnpackWithDropPrivs(s.basedir, dirs.GlobalRootDir); err != nil {
853 return "", err854 return "", err
854 }855 }
855856
@@ -926,7 +927,7 @@
926 return "", err927 return "", err
927 }928 }
928929
929 sysd := systemd.New(globalRootDir, inter)930 sysd := systemd.New(dirs.GlobalRootDir, inter)
930 stopped := make(map[string]time.Duration)931 stopped := make(map[string]time.Duration)
931 defer func() {932 defer func() {
932 if err != nil {933 if err != nil {
@@ -1007,7 +1008,7 @@
1007 }1008 }
10081009
1009 if s.Type() == pkg.TypeFramework {1010 if s.Type() == pkg.TypeFramework {
1010 if err := policy.Install(s.Name(), s.basedir, globalRootDir); err != nil {1011 if err := policy.Install(s.Name(), s.basedir, dirs.GlobalRootDir); err != nil {
1011 return err1012 return err
1012 }1013 }
1013 }1014 }
@@ -1036,7 +1037,7 @@
1036 logger.Noticef("Failed to remove %q: %v", currentActiveSymlink, err)1037 logger.Noticef("Failed to remove %q: %v", currentActiveSymlink, err)
1037 }1038 }
10381039
1039 dbase := filepath.Join(snapDataDir, QualifiedName(s))1040 dbase := filepath.Join(dirs.SnapDataDir, QualifiedName(s))
1040 currentDataSymlink := filepath.Join(dbase, "current")1041 currentDataSymlink := filepath.Join(dbase, "current")
1041 if err := os.Remove(currentDataSymlink); err != nil && !os.IsNotExist(err) {1042 if err := os.Remove(currentDataSymlink); err != nil && !os.IsNotExist(err) {
1042 logger.Noticef("Failed to remove %q: %v", currentDataSymlink, err)1043 logger.Noticef("Failed to remove %q: %v", currentDataSymlink, err)
@@ -1083,7 +1084,7 @@
1083 }1084 }
10841085
1085 if s.Type() == pkg.TypeFramework {1086 if s.Type() == pkg.TypeFramework {
1086 if err := policy.Remove(s.Name(), s.basedir, globalRootDir); err != nil {1087 if err := policy.Remove(s.Name(), s.basedir, dirs.GlobalRootDir); err != nil {
1087 return err1088 return err
1088 }1089 }
1089 }1090 }
@@ -1097,7 +1098,7 @@
1097 logger.Noticef("Failed to remove %q: %v", currentSymlink, err)1098 logger.Noticef("Failed to remove %q: %v", currentSymlink, err)
1098 }1099 }
10991100
1100 currentDataSymlink := filepath.Join(snapDataDir, QualifiedName(s), "current")1101 currentDataSymlink := filepath.Join(dirs.SnapDataDir, QualifiedName(s), "current")
1101 if err := os.Remove(currentDataSymlink); err != nil && !os.IsNotExist(err) {1102 if err := os.Remove(currentDataSymlink); err != nil && !os.IsNotExist(err) {
1102 logger.Noticef("Failed to remove %q: %v", currentDataSymlink, err)1103 logger.Noticef("Failed to remove %q: %v", currentDataSymlink, err)
1103 }1104 }
@@ -1279,7 +1280,7 @@
1279var timestampUpdater = helpers.UpdateTimestamp1280var timestampUpdater = helpers.UpdateTimestamp
12801281
1281func updateAppArmorJSONTimestamp(fullName, thing, version string) error {1282func updateAppArmorJSONTimestamp(fullName, thing, version string) error {
1282 fn := filepath.Join(snapAppArmorDir, fmt.Sprintf("%s_%s_%s.json", fullName, thing, version))1283 fn := filepath.Join(dirs.SnapAppArmorDir, fmt.Sprintf("%s_%s_%s.json", fullName, thing, version))
1283 return timestampUpdater(fn)1284 return timestampUpdater(fn)
1284}1285}
12851286
@@ -1591,7 +1592,7 @@
1591}1592}
15921593
1593func (s *RemoteSnapPart) downloadIcon(pbar progress.Meter) error {1594func (s *RemoteSnapPart) downloadIcon(pbar progress.Meter) error {
1594 if err := os.MkdirAll(snapIconsDir, 0755); err != nil {1595 if err := os.MkdirAll(dirs.SnapIconsDir, 0755); err != nil {
1595 return err1596 return err
1596 }1597 }
15971598
@@ -1624,7 +1625,7 @@
1624 return err1625 return err
1625 }1626 }
16261627
1627 if err := os.MkdirAll(snapMetaDir, 0755); err != nil {1628 if err := os.MkdirAll(dirs.SnapMetaDir, 0755); err != nil {
1628 return err1629 return err
1629 }1630 }
16301631
16311632
=== modified file 'snappy/snapp_test.go'
--- snappy/snapp_test.go 2015-09-15 20:24:56 +0000
+++ snappy/snapp_test.go 2015-09-29 11:44:13 +0000
@@ -31,6 +31,7 @@
31 "strings"31 "strings"
3232
33 "launchpad.net/snappy/clickdeb"33 "launchpad.net/snappy/clickdeb"
34 "launchpad.net/snappy/dirs"
34 "launchpad.net/snappy/helpers"35 "launchpad.net/snappy/helpers"
35 "launchpad.net/snappy/partition"36 "launchpad.net/snappy/partition"
36 "launchpad.net/snappy/pkg"37 "launchpad.net/snappy/pkg"
@@ -58,18 +59,18 @@
58 return new(MockPartition)59 return new(MockPartition)
59 }60 }
6061
61 SetRootDir(s.tempdir)62 dirs.SetRootDir(s.tempdir)
62 policy.SecBase = filepath.Join(s.tempdir, "security")63 policy.SecBase = filepath.Join(s.tempdir, "security")
63 os.MkdirAll(snapServicesDir, 0755)64 os.MkdirAll(dirs.SnapServicesDir, 0755)
64 os.MkdirAll(snapSeccompDir, 0755)65 os.MkdirAll(dirs.SnapSeccompDir, 0755)
6566
66 release.Override(release.Release{Flavor: "core", Series: "15.04"})67 release.Override(release.Release{Flavor: "core", Series: "15.04"})
6768
68 clickSystemHooksDir = filepath.Join(s.tempdir, "/usr/share/click/hooks")69 dirs.ClickSystemHooksDir = filepath.Join(s.tempdir, "/usr/share/click/hooks")
69 os.MkdirAll(clickSystemHooksDir, 0755)70 os.MkdirAll(dirs.ClickSystemHooksDir, 0755)
7071
71 // create a fake systemd environment72 // create a fake systemd environment
72 os.MkdirAll(filepath.Join(snapServicesDir, "multi-user.target.wants"), 0755)73 os.MkdirAll(filepath.Join(dirs.SnapServicesDir, "multi-user.target.wants"), 0755)
7374
74 // we may not have debsig-verify installed (and we don't need it75 // we may not have debsig-verify installed (and we don't need it
75 // for the unittests)76 // for the unittests)
@@ -692,12 +693,12 @@
692 c.Assert(err, IsNil)693 c.Assert(err, IsNil)
693 c.Assert(installed, HasLen, 1)694 c.Assert(installed, HasLen, 1)
694695
695 iconPath := filepath.Join(snapIconsDir, "foo.bar_1.0.png")696 iconPath := filepath.Join(dirs.SnapIconsDir, "foo.bar_1.0.png")
696 c.Check(installed[0].Icon(), Equals, iconPath)697 c.Check(installed[0].Icon(), Equals, iconPath)
697 c.Check(installed[0].Origin(), Equals, "bar")698 c.Check(installed[0].Origin(), Equals, "bar")
698 c.Check(installed[0].Description(), Equals, "this is a description")699 c.Check(installed[0].Description(), Equals, "this is a description")
699700
700 _, err = os.Stat(filepath.Join(snapMetaDir, "foo.bar_1.0.manifest"))701 _, err = os.Stat(filepath.Join(dirs.SnapMetaDir, "foo.bar_1.0.manifest"))
701 c.Check(err, IsNil)702 c.Check(err, IsNil)
702}703}
703704
@@ -1118,11 +1119,11 @@
1118 c.Assert(err, IsNil)1119 c.Assert(err, IsNil)
1119 c.Assert(makeSnapActive(yamlPath), IsNil)1120 c.Assert(makeSnapActive(yamlPath), IsNil)
11201121
1121 err = os.MkdirAll(snapMetaDir, 0755)1122 err = os.MkdirAll(dirs.SnapMetaDir, 0755)
1122 c.Assert(err, IsNil)1123 c.Assert(err, IsNil)
11231124
1124 data = "name: afoo\nalias: afoo\ndescription: something nice\ndownloadsize: 10\norigin: someplace"1125 data = "name: afoo\nalias: afoo\ndescription: something nice\ndownloadsize: 10\norigin: someplace"
1125 err = ioutil.WriteFile(filepath.Join(snapMetaDir, "afoo_1.manifest"), []byte(data), 0644)1126 err = ioutil.WriteFile(filepath.Join(dirs.SnapMetaDir, "afoo_1.manifest"), []byte(data), 0644)
1126 c.Assert(err, IsNil)1127 c.Assert(err, IsNil)
11271128
1128 snaps, err := ListInstalled()1129 snaps, err := ListInstalled()
@@ -1192,14 +1193,14 @@
1192}1193}
11931194
1194func (s *SnapTestSuite) TestRefreshDependentsSecurity(c *C) {1195func (s *SnapTestSuite) TestRefreshDependentsSecurity(c *C) {
1195 oldDir := snapAppArmorDir1196 oldDir := dirs.SnapAppArmorDir
1196 defer func() {1197 defer func() {
1197 snapAppArmorDir = oldDir1198 dirs.SnapAppArmorDir = oldDir
1198 timestampUpdater = helpers.UpdateTimestamp1199 timestampUpdater = helpers.UpdateTimestamp
1199 }()1200 }()
1200 touched := []string{}1201 touched := []string{}
1201 snapAppArmorDir = c.MkDir()1202 dirs.SnapAppArmorDir = c.MkDir()
1202 fn := filepath.Join(snapAppArmorDir, "foo."+testOrigin+"_hello_1.0.json")1203 fn := filepath.Join(dirs.SnapAppArmorDir, "foo."+testOrigin+"_hello_1.0.json")
1203 c.Assert(os.Symlink(fn, fn), IsNil)1204 c.Assert(os.Symlink(fn, fn), IsNil)
1204 timestampUpdater = func(s string) error {1205 timestampUpdater = func(s string) error {
1205 touched = append(touched, s)1206 touched = append(touched, s)
@@ -1457,18 +1458,18 @@
1457 m, err := parsePackageYamlData(hardwareYaml, false)1458 m, err := parsePackageYamlData(hardwareYaml, false)
1458 c.Assert(err, IsNil)1459 c.Assert(err, IsNil)
14591460
1460 snapUdevRulesDir = c.MkDir()1461 dirs.SnapUdevRulesDir = c.MkDir()
1461 writeOemHardwareUdevRules(m)1462 writeOemHardwareUdevRules(m)
14621463
1463 c.Assert(helpers.FileExists(filepath.Join(snapUdevRulesDir, "80-snappy_oem-foo_device-hive-iot-hal.rules")), Equals, true)1464 c.Assert(helpers.FileExists(filepath.Join(dirs.SnapUdevRulesDir, "80-snappy_oem-foo_device-hive-iot-hal.rules")), Equals, true)
1464}1465}
14651466
1466func (s *SnapTestSuite) TestWriteHardwareUdevCleanup(c *C) {1467func (s *SnapTestSuite) TestWriteHardwareUdevCleanup(c *C) {
1467 m, err := parsePackageYamlData(hardwareYaml, false)1468 m, err := parsePackageYamlData(hardwareYaml, false)
1468 c.Assert(err, IsNil)1469 c.Assert(err, IsNil)
14691470
1470 snapUdevRulesDir = c.MkDir()1471 dirs.SnapUdevRulesDir = c.MkDir()
1471 udevRulesFile := filepath.Join(snapUdevRulesDir, "80-snappy_oem-foo_device-hive-iot-hal.rules")1472 udevRulesFile := filepath.Join(dirs.SnapUdevRulesDir, "80-snappy_oem-foo_device-hive-iot-hal.rules")
1472 c.Assert(ioutil.WriteFile(udevRulesFile, nil, 0644), Equals, nil)1473 c.Assert(ioutil.WriteFile(udevRulesFile, nil, 0644), Equals, nil)
1473 cleanupOemHardwareUdevRules(m)1474 cleanupOemHardwareUdevRules(m)
14741475

Subscribers

People subscribed via source and target branches