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