Merge lp:~sergiusens/snappy/frameworkPath into lp:~snappy-dev/snappy/snappy-moved-to-github

Proposed by Sergio Schvezov
Status: Work in progress
Proposed branch: lp:~sergiusens/snappy/frameworkPath
Merge into: lp:~snappy-dev/snappy/snappy-moved-to-github
Diff against target: 235 lines (+73/-36)
6 files modified
debian/ubuntu-snappy.dirs (+1/-0)
snappy/click_test.go (+24/-12)
snappy/dirs.go (+31/-8)
snappy/parts.go (+3/-0)
snappy/purge.go (+13/-11)
snappy/snapp.go (+1/-5)
To merge this branch: bzr merge lp:~sergiusens/snappy/frameworkPath
Reviewer Review Type Date Requested Status
Leo Arias (community) Needs Fixing
Federico Gimenez (community) continuous-integration Approve
Jamie Strandboge (community) Needs Information
Michael Vogt (community) Approve
Snappy Tarmac continuous-integration Pending
Review via email: mp+260202@code.launchpad.net

Commit message

Use /frameworks for framework snaps

Description of the change

Notice that this requires security/apparmor work.

To post a comment you must log in.
Revision history for this message
Michael Vogt (mvo) wrote :

Thanks, this looks good.

review: Approve
Revision history for this message
Michael Vogt (mvo) wrote :

Does more need to change for this to land, i.e. do we need apparmor changes in lock-step?

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

On Wed, May 27, 2015 at 06:40:01AM -0000, Michael Vogt wrote:
> Does more need to change for this to land, i.e. do we need apparmor changes in lock-step?

Not sure if in lockstep, but the apparmor changes would need to land
before this, reason for adding jdstrand as a reviewer.

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

I've not looked at the code changes, but this states that it needs apparmor work. What is needed, adjustments to handle /frameworks instead of just /apps? If so, I think this should be sufficient in click-apparmor's click.py:

=== modified file 'src/apparmor/click.py'
--- src/apparmor/click.py 2015-04-15 21:32:33 +0000
+++ src/apparmor/click.py 2015-05-27 19:56:41 +0000
@@ -542,7 +542,7 @@
     # snappy hardcodes these and doing this allows snappy images to not require
     # click
     if os.path.exists("/usr/bin/snappy"):
- return "{%s}" % ",".join(["/apps", "/oem"])
+ return "{%s}" % ",".join(["/apps", "/oem", "/frameworks"])

     from gi.repository import Click

review: Needs Information
Revision history for this message
Jamie Strandboge (jdstrand) wrote :

Oh, and I *hate* 'if os.path.exists("/usr/bin/snappy")' - is there a better way to determine if this is an actual snappy system?

lp:~sergiusens/snappy/frameworkPath updated
472. By Sergio Schvezov

trunkpdate

473. By Sergio Schvezov

adding /frameworks to 'dirs'

474. By Sergio Schvezov

Adding /oem and /frameworks to purge list

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

> I've not looked at the code changes, but this states that it needs apparmor
> work. What is needed, adjustments to handle /frameworks instead of just /apps?
> If so, I think this should be sufficient in click-apparmor's click.py:
>
> === modified file 'src/apparmor/click.py'
> --- src/apparmor/click.py 2015-04-15 21:32:33 +0000
> +++ src/apparmor/click.py 2015-05-27 19:56:41 +0000
> @@ -542,7 +542,7 @@
> # snappy hardcodes these and doing this allows snappy images to not
> require
> # click
> if os.path.exists("/usr/bin/snappy"):
> - return "{%s}" % ",".join(["/apps", "/oem"])
> + return "{%s}" % ",".join(["/apps", "/oem", "/frameworks"])
>
> from gi.repository import Click

With this installation works fine but the profile symlinks are wrong:

(amd64)ubuntu@localhost:~$ ls /var/lib/apparmor/snappy/profiles/ -l
total 0
lrwxrwxrwx 1 root ubuntu 36 Jun 3 19:10 webdm_snappyd_0.8 -> /apps/webdm/0.8/meta/snappyd.profile

that's a broken link; who creates the symlink these days? Snappy or apparmor?

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

snappy creates the symlink in /var/lib/apparmor/clicks, and apparmor creates the profile in /var/lib/apparmor/profiles based on the symlink.

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

Oh, webdm uses aa-profile-hook, not aa-clickapparmor. In that case, snappy creates the symlink in /var/lib/apparmor/snappy/profiles, then apparmor (aa-profilehook) creates the profile in /var/lib/apparmor/profiles.

(Gosh it will be nice to get this cleaned up)

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

ah, stale files, actually no link is being created.

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

ugh, this was related to the bug Chipaca mentioned and is ready for review here: https://code.launchpad.net/~chipaca/snappy/mangle/+merge/260934

When applying https://code.launchpad.net/~sergiusens/click-apparmor/snappyFameworksDir/+merge/261032 we should be good.

Revision history for this message
John Lenton (chipaca) wrote :

You've resurrected agreerator, which points to a bad merge; fix that.

Please also consider changing targetDirForType() to a method of type. This is more work, because you'd have to add something like SetRootDir to pkg, and call it from snappy's SetRootDir, so only do it if you're feeling fancy.

I suspect this is going to conflict with some of the branches i've had up for review for a few days now... sigh.

Revision history for this message
Federico Gimenez (fgimenez) wrote :

PASSED: Continuous integration, rev:474
http://10.55.60.183:8080/job/snappy-rolling-ci/28/
Executed test runs:

Click here to trigger a rebuild:
http://10.55.60.183:8080/job/snappy-rolling-ci/28/rebuild

review: Approve (continuous-integration)
Revision history for this message
Leo Arias (elopio) wrote :

this has a conflict with trunk.

review: Needs Fixing

Unmerged revisions

474. By Sergio Schvezov

Adding /oem and /frameworks to purge list

473. By Sergio Schvezov

adding /frameworks to 'dirs'

472. By Sergio Schvezov

trunkpdate

471. By Sergio Schvezov

Use /frameworks for framework snaps

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/ubuntu-snappy.dirs'
2--- debian/ubuntu-snappy.dirs 2015-04-15 22:08:10 +0000
3+++ debian/ubuntu-snappy.dirs 2015-06-03 19:51:29 +0000
4@@ -1,2 +1,3 @@
5 /apps
6+/frameworks
7 /oem
8
9=== modified file 'snappy/click_test.go'
10--- snappy/click_test.go 2015-06-03 14:03:45 +0000
11+++ snappy/click_test.go 2015-06-03 19:51:29 +0000
12@@ -245,6 +245,19 @@
13 c.Assert(err, NotNil)
14 }
15
16+type agreerator struct {
17+ y bool
18+ intro string
19+ license string
20+}
21+
22+func (a *agreerator) Agreed(intro, license string) bool {
23+ a.intro = intro
24+ a.license = license
25+ return a.y
26+}
27+func (a *agreerator) Notify(string) {}
28+
29 // if the snap asks for accepting a license, and an agreer isn't provided,
30 // install fails
31 func (s *SnapTestSuite) TestLocalSnapInstallMissingAccepterFails(c *C) {
32@@ -428,8 +441,8 @@
33 policy.SecBase = c.MkDir()
34
35 s.buildFramework(c)
36- appdir := filepath.Join(s.tempdir, "apps", "hello", "1.0.1")
37- c.Assert(removeClick(appdir, nil), IsNil)
38+ fwDir := filepath.Join(s.tempdir, "frameworks", "hello", "1.0.1")
39+ c.Assert(removeClick(fwDir, nil), IsNil)
40 }
41
42 func (s *SnapTestSuite) TestSnapRemovePackagePolicyWeirdClickManifest(c *C) {
43@@ -438,13 +451,12 @@
44 policy.SecBase = c.MkDir()
45
46 s.buildFramework(c)
47- appdir := filepath.Join(s.tempdir, "apps", "hello", "1.0.1")
48- // c.Assert(removeClick(appdir, nil), IsNil)
49+ fwDir := filepath.Join(s.tempdir, "frameworks", "hello", "1.0.1")
50
51- manifestFile := filepath.Join(appdir, ".click", "info", "hello.manifest")
52+ manifestFile := filepath.Join(fwDir, ".click", "info", "hello.manifest")
53 c.Assert(ioutil.WriteFile(manifestFile, []byte(`{"name": "xyzzy","type":"framework"}`), 0644), IsNil)
54
55- c.Assert(removeClick(appdir, nil), IsNil)
56+ c.Assert(removeClick(fwDir, nil), IsNil)
57 }
58
59 func (s *SnapTestSuite) TestLocalOemSnapInstall(c *C) {
60@@ -915,12 +927,12 @@
61 c.Check(cmdlog, DeepEquals, []string{"stop", "show", "stop", "show", "start", "start"})
62
63 // check it got set active
64- content, err := ioutil.ReadFile(filepath.Join(snapAppsDir, "fmk", "current", "meta", "package.yaml"))
65+ content, err := ioutil.ReadFile(filepath.Join(snapFrameworksDir, "fmk", "current", "meta", "package.yaml"))
66 c.Assert(err, IsNil)
67 c.Assert(strings.Contains(string(content), "version: 2"), Equals, true)
68
69 // just in case (cf. the following tests)
70- _, err = os.Stat(filepath.Join(snapAppsDir, "fmk", "2"))
71+ _, err = os.Stat(filepath.Join(snapFrameworksDir, "fmk", "2"))
72 c.Assert(err, IsNil)
73
74 }
75@@ -944,12 +956,12 @@
76 c.Check(cmdlog, DeepEquals, []string{"stop", "show", "stop", "start"})
77
78 // check it got rolled back
79- content, err := ioutil.ReadFile(filepath.Join(snapAppsDir, "fmk", "current", "meta", "package.yaml"))
80+ content, err := ioutil.ReadFile(filepath.Join(snapFrameworksDir, "fmk", "current", "meta", "package.yaml"))
81 c.Assert(err, IsNil)
82 c.Assert(strings.Contains(string(content), "version: 1"), Equals, true)
83
84 // no leftovers from the failed install
85- _, err = os.Stat(filepath.Join(snapAppsDir, "fmk", "2"))
86+ _, err = os.Stat(filepath.Join(snapFrameworksDir, "fmk", "2"))
87 c.Assert(err, NotNil)
88 }
89
90@@ -975,12 +987,12 @@
91 })
92
93 // check it got rolled back
94- content, err := ioutil.ReadFile(filepath.Join(snapAppsDir, "fmk", "current", "meta", "package.yaml"))
95+ content, err := ioutil.ReadFile(filepath.Join(snapFrameworksDir, "fmk", "current", "meta", "package.yaml"))
96 c.Assert(err, IsNil)
97 c.Assert(strings.Contains(string(content), "version: 1"), Equals, true)
98
99 // no leftovers from the failed install
100- _, err = os.Stat(filepath.Join(snapAppsDir, "fmk", "2"))
101+ _, err = os.Stat(filepath.Join(snapFrameworksDir, "fmk", "2"))
102 c.Assert(err, NotNil)
103
104 }
105
106=== modified file 'snappy/dirs.go'
107--- snappy/dirs.go 2015-05-15 13:33:27 +0000
108+++ snappy/dirs.go 2015-06-03 19:51:29 +0000
109@@ -19,19 +19,24 @@
110
111 package snappy
112
113-import "path/filepath"
114+import (
115+ "path/filepath"
116+
117+ "launchpad.net/snappy/pkg"
118+)
119
120 // the various file paths
121 var (
122 globalRootDir string
123
124- snapAppsDir string
125- snapOemDir string
126- snapDataDir string
127- snapDataHomeGlob string
128- snapAppArmorDir string
129- snapSeccompDir string
130- snapUdevRulesDir string
131+ snapAppsDir string
132+ snapFrameworksDir string
133+ snapOemDir string
134+ snapDataDir string
135+ snapDataHomeGlob string
136+ snapAppArmorDir string
137+ snapSeccompDir string
138+ snapUdevRulesDir string
139
140 snapBinariesDir string
141 snapServicesDir string
142@@ -47,6 +52,7 @@
143 globalRootDir = rootdir
144
145 snapAppsDir = filepath.Join(rootdir, "/apps")
146+ snapFrameworksDir = filepath.Join(rootdir, "/frameworks")
147 snapOemDir = filepath.Join(rootdir, "/oem")
148 snapDataDir = filepath.Join(rootdir, "/var/lib/apps")
149 snapDataHomeGlob = filepath.Join(rootdir, "/home/*/apps/")
150@@ -63,3 +69,20 @@
151
152 snapUdevRulesDir = filepath.Join(rootdir, "/etc/udev/rules.d")
153 }
154+
155+func targetDirForType(t pkg.Type) string {
156+ switch t {
157+ case pkg.TypeApp:
158+ return snapAppsDir
159+ case pkg.TypeOem:
160+ return snapOemDir
161+ case pkg.TypeFramework:
162+ return snapFrameworksDir
163+ default:
164+ return snapAppsDir
165+ }
166+}
167+
168+func allTargetDirs() []string {
169+ return []string{snapAppsDir, snapFrameworksDir, snapOemDir}
170+}
171
172=== modified file 'snappy/parts.go'
173--- snappy/parts.go 2015-05-20 17:24:29 +0000
174+++ snappy/parts.go 2015-06-03 19:51:29 +0000
175@@ -139,6 +139,9 @@
176 if repo := NewLocalSnapRepository(snapAppsDir); repo != nil {
177 m.all = append(m.all, repo)
178 }
179+ if repo := NewLocalSnapRepository(snapFrameworksDir); repo != nil {
180+ m.all = append(m.all, repo)
181+ }
182 if repo := NewLocalSnapRepository(snapOemDir); repo != nil {
183 m.all = append(m.all, repo)
184 }
185
186=== modified file 'snappy/purge.go'
187--- snappy/purge.go 2015-05-20 17:24:29 +0000
188+++ snappy/purge.go 2015-06-03 19:51:29 +0000
189@@ -50,17 +50,19 @@
190 var active []*SnapPart
191
192 for _, datadir := range datadirs {
193- yamlPath := filepath.Join(snapAppsDir, datadir.QualifiedName(), datadir.Version, "meta", "package.yaml")
194- part, err := NewInstalledSnapPart(yamlPath, datadir.Origin)
195- if err != nil {
196- // no such part installed
197- continue
198- }
199- if part.IsActive() {
200- if !purgeActive {
201- return ErrStillActive
202- }
203- active = append(active, part)
204+ for _, snapDir := range allTargetDirs() {
205+ yamlPath := filepath.Join(snapDir, datadir.QualifiedName(), datadir.Version, "meta", "package.yaml")
206+ part, err := NewInstalledSnapPart(yamlPath, datadir.Origin)
207+ if err != nil {
208+ // no such part installed
209+ continue
210+ }
211+ if part.IsActive() {
212+ if !purgeActive {
213+ return ErrStillActive
214+ }
215+ active = append(active, part)
216+ }
217 }
218 }
219
220
221=== modified file 'snappy/snapp.go'
222--- snappy/snapp.go 2015-05-29 13:22:14 +0000
223+++ snappy/snapp.go 2015-06-03 19:51:29 +0000
224@@ -484,11 +484,7 @@
225 return nil, err
226 }
227
228- targetDir := snapAppsDir
229- // the "oem" parts are special
230- if m.Type == pkg.TypeOem {
231- targetDir = snapOemDir
232- }
233+ targetDir := targetDirForType(m.Type)
234 fullName := m.qualifiedName(origin)
235 instDir := filepath.Join(targetDir, fullName, m.Version)
236

Subscribers

People subscribed via source and target branches