Merge lp:~chipaca/snappy/trunk-to-15.04 into lp:snappy/15.04

Proposed by John Lenton
Status: Merged
Approved by: Leo Arias
Approved revision: 712
Merged at revision: 712
Proposed branch: lp:~chipaca/snappy/trunk-to-15.04
Merge into: lp:snappy/15.04
Diff against target: 119 lines (+65/-4)
4 files modified
helpers/helpers.go (+4/-0)
helpers/helpers_test.go (+32/-0)
snappy/parts.go (+6/-4)
snappy/parts_test.go (+23/-0)
To merge this branch: bzr merge lp:~chipaca/snappy/trunk-to-15.04
Reviewer Review Type Date Requested Status
Leo Arias (community) Approve
Review via email: mp+272140@code.launchpad.net

Commit message

All the latest trunk, freshly merged just for you.

To post a comment you must log in.
Revision history for this message
Leo Arias (elopio) wrote :

Already reviewed and approved branches.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'helpers/helpers.go'
2--- helpers/helpers.go 2015-09-01 10:00:49 +0000
3+++ helpers/helpers.go 2015-09-23 16:22:16 +0000
4@@ -115,6 +115,10 @@
5
6 // UnpackTar unpacks the given tar file into the target directory
7 func UnpackTar(r io.Reader, targetDir string, fn UnpackTarTransformFunc) error {
8+ // ensure we we extract with the original permissions
9+ oldUmask := syscall.Umask(0)
10+ defer syscall.Umask(oldUmask)
11+
12 return TarIterate(r, func(tr *tar.Reader, hdr *tar.Header) (err error) {
13 // run tar transform func
14 name := hdr.Name
15
16=== modified file 'helpers/helpers_test.go'
17--- helpers/helpers_test.go 2015-08-21 12:14:16 +0000
18+++ helpers/helpers_test.go 2015-09-23 16:22:16 +0000
19@@ -27,6 +27,7 @@
20 "os"
21 "os/exec"
22 "path/filepath"
23+ "syscall"
24 "testing"
25
26 . "gopkg.in/check.v1"
27@@ -483,3 +484,34 @@
28 err := CopyIfDifferent(src, dst)
29 c.Assert(err, NotNil)
30 }
31+
32+func (ts *HTestSuite) TestUnpackPermissions(c *C) {
33+ tarArchive := filepath.Join(c.MkDir(), "foo.tar")
34+
35+ canaryName := "foo"
36+ canaryPerms := os.FileMode(0644)
37+ tmpdir := c.MkDir()
38+ err := ioutil.WriteFile(filepath.Join(tmpdir, canaryName), []byte(nil), canaryPerms)
39+ c.Assert(err, IsNil)
40+
41+ ChDir(tmpdir, func() {
42+ cmd := exec.Command("tar", "cvf", tarArchive, ".")
43+ _, err = cmd.CombinedOutput()
44+ c.Assert(err, IsNil)
45+ })
46+
47+ // set crazy umask
48+ oldUmask := syscall.Umask(0077)
49+ defer syscall.Umask(oldUmask)
50+
51+ // unpack
52+ unpackdir := c.MkDir()
53+ f, err := os.Open(tarArchive)
54+ c.Assert(err, IsNil)
55+ defer f.Close()
56+ UnpackTar(f, unpackdir, nil)
57+
58+ st, err := os.Stat(filepath.Join(unpackdir, canaryName))
59+ c.Assert(err, IsNil)
60+ c.Assert(st.Mode()&os.ModePerm, Equals, canaryPerms)
61+}
62
63=== modified file 'snappy/parts.go'
64--- snappy/parts.go 2015-09-14 23:19:11 +0000
65+++ snappy/parts.go 2015-09-23 16:22:16 +0000
66@@ -249,13 +249,15 @@
67 // ActiveSnapNamesByType returns all installed snap names with the given type
68 var ActiveSnapNamesByType = activeSnapNamesByTypeImpl
69
70-func activeSnapNamesByTypeImpl(snapTs ...pkg.Type) (res []string, err error) {
71+func activeSnapNamesByTypeImpl(snapTs ...pkg.Type) ([]string, error) {
72 installed, err := ActiveSnapsByType(snapTs...)
73- for _, part := range installed {
74- res = append(res, part.Name())
75+ res := make([]string, len(installed))
76+
77+ for i, part := range installed {
78+ res[i] = QualifiedName(part)
79 }
80
81- return res, nil
82+ return res, err
83 }
84
85 // ActiveSnapByName returns all active snaps with the given name
86
87=== modified file 'snappy/parts_test.go'
88--- snappy/parts_test.go 2015-09-14 23:19:11 +0000
89+++ snappy/parts_test.go 2015-09-23 16:22:16 +0000
90@@ -57,6 +57,29 @@
91 c.Assert(parts[0].Name(), Equals, "framework1")
92 }
93
94+func (s *SnapTestSuite) TestActiveSnapNamesByType(c *C) {
95+ yamlPath, err := makeInstalledMockSnap(s.tempdir, `name: app
96+version: 1.10
97+vendor: example.com`)
98+ c.Assert(err, IsNil)
99+ makeSnapActive(yamlPath)
100+
101+ yamlPath, err = makeInstalledMockSnap(s.tempdir, `name: fwk
102+version: 1.0
103+type: framework
104+vendor: example.com`)
105+ c.Assert(err, IsNil)
106+ makeSnapActive(yamlPath)
107+
108+ names, err := ActiveSnapNamesByType(pkg.TypeApp)
109+ c.Check(err, IsNil)
110+ c.Check(names, DeepEquals, []string{"app." + testOrigin})
111+
112+ names, err = ActiveSnapNamesByType(pkg.TypeFramework)
113+ c.Check(err, IsNil)
114+ c.Check(names, DeepEquals, []string{"fwk"})
115+}
116+
117 func (s *SnapTestSuite) TestMetaRepositoryDetails(c *C) {
118 _, err := makeInstalledMockSnap(s.tempdir, "")
119 c.Assert(err, IsNil)

Subscribers

People subscribed via source and target branches

to all changes: