Merge lp:~mvo/snappy/snappy-snapfs-refactor-ftw into lp:~snappy-dev/snappy/snappy-moved-to-github

Proposed by Michael Vogt
Status: Work in progress
Proposed branch: lp:~mvo/snappy/snappy-snapfs-refactor-ftw
Merge into: lp:~snappy-dev/snappy/snappy-moved-to-github
Prerequisite: lp:~mvo/snappy/snappy-snapfs-boot-ok
Diff against target: 588 lines (+191/-80)
11 files modified
pkg/clickdeb/deb.go (+11/-2)
pkg/lightweight/lightweight_test.go (+1/-1)
snappy/click.go (+0/-1)
snappy/kernel.go (+31/-8)
snappy/oem.go (+27/-1)
snappy/os.go (+36/-0)
snappy/purge.go (+1/-1)
snappy/purge_test.go (+1/-1)
snappy/snapp.go (+56/-47)
snappy/snapp_snapfs_test.go (+23/-14)
snappy/snapp_test.go (+4/-4)
To merge this branch: bzr merge lp:~mvo/snappy/snappy-snapfs-refactor-ftw
Reviewer Review Type Date Requested Status
John Lenton (community) Needs Fixing
Review via email: mp+275024@code.launchpad.net
To post a comment you must log in.
786. By Michael Vogt

more snap types

787. By Michael Vogt

start refactor code out of generic and into OemSnap

Revision history for this message
John Lenton (chipaca) :
review: Needs Fixing
Revision history for this message
John Lenton (chipaca) :
788. By Michael Vogt

more SnapIF work

789. By Michael Vogt

move kernel unpack into kernel snap

Revision history for this message
Michael Vogt (mvo) :

Unmerged revisions

789. By Michael Vogt

move kernel unpack into kernel snap

788. By Michael Vogt

more SnapIF work

787. By Michael Vogt

start refactor code out of generic and into OemSnap

786. By Michael Vogt

more snap types

785. By Michael Vogt

start refactor to have OemSnap etc

784. By Michael Vogt

add boot-ok for new-style all-snaps

783. By Michael Vogt

disallow removal of the active kernel and os

782. By Michael Vogt

remove kernel assets in /boot/ on snap removal

781. By Michael Vogt

show a reboot required message (not complete yet)

780. By Michael Vogt

go fmt

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'pkg/clickdeb/deb.go'
--- pkg/clickdeb/deb.go 2015-10-20 14:48:11 +0000
+++ pkg/clickdeb/deb.go 2015-10-20 14:48:11 +0000
@@ -30,6 +30,7 @@
30 "os"30 "os"
31 "os/exec"31 "os/exec"
32 "path/filepath"32 "path/filepath"
33 "runtime"
33 "strings"34 "strings"
34 "time"35 "time"
3536
@@ -127,13 +128,19 @@
127 file *os.File128 file *os.File
128}129}
129130
131func clickDebFinalizer(d *ClickDeb) {
132 d.file.Close()
133}
134
130// Open calls os.Open and uses that file for the backing file.135// Open calls os.Open and uses that file for the backing file.
131func Open(path string) (*ClickDeb, error) {136func Open(path string) (*ClickDeb, error) {
132 f, err := os.Open(path)137 f, err := os.Open(path)
133 if err != nil {138 if err != nil {
134 return nil, err139 return nil, err
135 }140 }
136 return &ClickDeb{f}, nil141 deb := &ClickDeb{f}
142 runtime.SetFinalizer(deb, clickDebFinalizer)
143 return deb, nil
137}144}
138145
139// Create calls os.Create and uses that file for the backing file.146// Create calls os.Create and uses that file for the backing file.
@@ -142,7 +149,9 @@
142 if err != nil {149 if err != nil {
143 return nil, err150 return nil, err
144 }151 }
145 return &ClickDeb{f}, nil152 deb := &ClickDeb{f}
153 runtime.SetFinalizer(deb, clickDebFinalizer)
154 return deb, nil
146}155}
147156
148// Name returns the Name of the backing file157// Name returns the Name of the backing file
149158
=== modified file 'pkg/lightweight/lightweight_test.go'
--- pkg/lightweight/lightweight_test.go 2015-10-10 09:48:49 +0000
+++ pkg/lightweight/lightweight_test.go 2015-10-20 14:48:11 +0000
@@ -388,7 +388,7 @@
388 c.Check(oem.ActiveIndex(), check.Equals, -1)388 c.Check(oem.ActiveIndex(), check.Equals, -1)
389 p, err := oem.Load(0)389 p, err := oem.Load(0)
390 c.Check(err, check.IsNil)390 c.Check(err, check.IsNil)
391 c.Check(p, check.FitsTypeOf, new(snappy.SnapPart))391 c.Check(p, check.FitsTypeOf, new(snappy.OemSnap))
392 c.Check(p.Version(), check.Equals, "3")392 c.Check(p.Version(), check.Equals, "3")
393}393}
394394
395395
=== modified file 'snappy/click.go'
--- snappy/click.go 2015-10-15 07:32:34 +0000
+++ snappy/click.go 2015-10-20 14:48:11 +0000
@@ -771,7 +771,6 @@
771 if err != nil {771 if err != nil {
772 return "", err772 return "", err
773 }773 }
774 defer part.deb.Close()
775774
776 return part.Install(inter, flags)775 return part.Install(inter, flags)
777}776}
778777
=== modified file 'snappy/kernel.go'
--- snappy/kernel.go 2015-10-20 14:48:11 +0000
+++ snappy/kernel.go 2015-10-20 14:48:11 +0000
@@ -25,47 +25,70 @@
2525
26 "launchpad.net/snappy/partition"26 "launchpad.net/snappy/partition"
27 "launchpad.net/snappy/pkg/snapfs"27 "launchpad.net/snappy/pkg/snapfs"
28 "launchpad.net/snappy/progress"
28)29)
2930
30func unpackKernel(s *SnapPart) error {31type KernelSnap struct {
32 SnapPart
33}
34
35// OEM snaps should not be removed as they are a key
36// building block for OEMs. Prunning non active ones
37// is acceptible.
38func (s *KernelSnap) Uninstall(pb progress.Meter) (err error) {
39 if s.IsActive() {
40 return ErrPackageNotRemovable
41 }
42
43 return s.SnapPart.Uninstall(pb)
44}
45
46func (s *KernelSnap) Install(inter progress.Meter, flags InstallFlags) (name string, err error) {
47 // do the generic install
48 name, err = s.SnapPart.Install(inter, flags)
49 if err != nil {
50 return name, err
51 }
52
53 // now do the kernel specific bits
31 bootdir := partition.BootloaderDir()54 bootdir := partition.BootloaderDir()
32 if err := os.MkdirAll(filepath.Join(bootdir, s.Version()), 0755); err !=55 if err := os.MkdirAll(filepath.Join(bootdir, s.Version()), 0755); err !=
33 nil {56 nil {
34 return err57 return name, err
35 }58 }
36 blobName := filepath.Base(snapfs.BlobPath(s.basedir))59 blobName := filepath.Base(snapfs.BlobPath(s.basedir))
37 dstDir := filepath.Join(bootdir, blobName)60 dstDir := filepath.Join(bootdir, blobName)
38 if s.m.Kernel != "" {61 if s.m.Kernel != "" {
39 src := s.m.Kernel62 src := s.m.Kernel
40 if err := s.deb.Unpack(src, dstDir); err != nil {63 if err := s.deb.Unpack(src, dstDir); err != nil {
41 return err64 return name, err
42 }65 }
43 src = filepath.Join(dstDir, s.m.Kernel)66 src = filepath.Join(dstDir, s.m.Kernel)
44 dst := filepath.Join(dstDir, partition.NormalizeKernelInitrdName(s.m.Kernel))67 dst := filepath.Join(dstDir, partition.NormalizeKernelInitrdName(s.m.Kernel))
45 if err := os.Rename(src, dst); err != nil {68 if err := os.Rename(src, dst); err != nil {
46 return err69 return name, err
47 }70 }
48 }71 }
49 if s.m.Initrd != "" {72 if s.m.Initrd != "" {
50 src := s.m.Initrd73 src := s.m.Initrd
51 if err := s.deb.Unpack(src, dstDir); err != nil {74 if err := s.deb.Unpack(src, dstDir); err != nil {
52 return err75 return name, err
53 }76 }
54 src = filepath.Join(dstDir, s.m.Initrd)77 src = filepath.Join(dstDir, s.m.Initrd)
55 dst := filepath.Join(dstDir, partition.NormalizeKernelInitrdName(s.m.Initrd))78 dst := filepath.Join(dstDir, partition.NormalizeKernelInitrdName(s.m.Initrd))
56 if err := os.Rename(src, dst); err != nil {79 if err := os.Rename(src, dst); err != nil {
57 return err80 return name, err
58 }81 }
59 }82 }
60 if s.m.Dtbs != "" {83 if s.m.Dtbs != "" {
61 src := s.m.Dtbs84 src := s.m.Dtbs
62 dst := filepath.Join(dstDir, s.m.Dtbs)85 dst := filepath.Join(dstDir, s.m.Dtbs)
63 if err := s.deb.Unpack(src, dst); err != nil {86 if err := s.deb.Unpack(src, dst); err != nil {
64 return err87 return name, err
65 }88 }
66 }89 }
6790
68 return nil91 return name, nil
69}92}
7093
71func removeKernel(s *SnapPart) error {94func removeKernel(s *SnapPart) error {
7295
=== modified file 'snappy/oem.go'
--- snappy/oem.go 2015-09-25 15:27:11 +0000
+++ snappy/oem.go 2015-10-20 14:48:11 +0000
@@ -34,8 +34,34 @@
34 "launchpad.net/snappy/dirs"34 "launchpad.net/snappy/dirs"
35 "launchpad.net/snappy/logger"35 "launchpad.net/snappy/logger"
36 "launchpad.net/snappy/pkg"36 "launchpad.net/snappy/pkg"
37 "launchpad.net/snappy/progress"
37)38)
3839
40type OemSnap struct {
41 SnapPart
42}
43
44func (s *OemSnap) Install(inter progress.Meter, flags InstallFlags) (name string, err error) {
45 name, err = s.SnapPart.Install(inter, flags)
46 if err != nil {
47 return "", err
48 }
49
50 if err := installOemHardwareUdevRules(s.m); err != nil {
51 return "", err
52 }
53
54 return name, nil
55}
56
57func (s *OemSnap) Uninstall(pb progress.Meter) (err error) {
58 if s.IsActive() {
59 return ErrPackageNotRemovable
60 }
61
62 return s.SnapPart.Uninstall(pb)
63}
64
39// OEM represents the structure inside the package.yaml for the oem component65// OEM represents the structure inside the package.yaml for the oem component
40// of an oem package type.66// of an oem package type.
41type OEM struct {67type OEM struct {
@@ -129,7 +155,7 @@
129func getOemImpl() (*packageYaml, error) {155func getOemImpl() (*packageYaml, error) {
130 oems, _ := ActiveSnapsByType(pkg.TypeOem)156 oems, _ := ActiveSnapsByType(pkg.TypeOem)
131 if len(oems) == 1 {157 if len(oems) == 1 {
132 return oems[0].(*SnapPart).m, nil158 return oems[0].(*OemSnap).m, nil
133 }159 }
134160
135 return nil, errors.New("no oem snap")161 return nil, errors.New("no oem snap")
136162
=== added file 'snappy/os.go'
--- snappy/os.go 1970-01-01 00:00:00 +0000
+++ snappy/os.go 2015-10-20 14:48:11 +0000
@@ -0,0 +1,36 @@
1package snappy
2
3// -*- Mode: Go; indent-tabs-mode: t -*-
4
5/*
6 * Copyright (C) 2014-2015 Canonical Ltd
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 3 as
10 * published by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22import (
23 "launchpad.net/snappy/progress"
24)
25
26type OsSnap struct {
27 SnapPart
28}
29
30func (s *OsSnap) Uninstall(pb progress.Meter) (err error) {
31 if s.IsActive() {
32 return ErrPackageNotRemovable
33 }
34
35 return s.SnapPart.Uninstall(pb)
36}
037
=== modified file 'snappy/purge.go'
--- snappy/purge.go 2015-09-25 15:27:11 +0000
+++ snappy/purge.go 2015-10-20 14:48:11 +0000
@@ -48,7 +48,7 @@
4848
49 purgeActive := flags&DoPurgeActive != 049 purgeActive := flags&DoPurgeActive != 0
5050
51 var active []*SnapPart51 var active []SnapIF
5252
53 for _, datadir := range datadirs {53 for _, datadir := range datadirs {
54 yamlPath := filepath.Join(dirs.SnapAppsDir, datadir.QualifiedName(), datadir.Version, "meta", "package.yaml")54 yamlPath := filepath.Join(dirs.SnapAppsDir, datadir.QualifiedName(), datadir.Version, "meta", "package.yaml")
5555
=== modified file 'snappy/purge_test.go'
--- snappy/purge_test.go 2015-10-10 13:27:50 +0000
+++ snappy/purge_test.go 2015-10-20 14:48:11 +0000
@@ -59,7 +59,7 @@
59 c.Check(inter.notified, HasLen, 0)59 c.Check(inter.notified, HasLen, 0)
60}60}
6161
62func (s *purgeSuite) mkpkg(c *C, args ...string) (dataDir string, part *SnapPart) {62func (s *purgeSuite) mkpkg(c *C, args ...string) (dataDir string, part SnapIF) {
63 version := "1.10"63 version := "1.10"
64 extra := ""64 extra := ""
65 switch len(args) {65 switch len(args) {
6666
=== modified file 'snappy/snapp.go'
--- snappy/snapp.go 2015-10-20 14:48:11 +0000
+++ snappy/snapp.go 2015-10-20 14:48:11 +0000
@@ -209,6 +209,16 @@
209 return nil209 return nil
210}210}
211211
212// FIXME: name suckso
213type SnapIF interface {
214 Part
215 activate(inhibitHooks bool, inter interacter) error
216 deactivate(inhibitHooks bool, inter interacter) error
217 Dir() string
218 remove(inter interacter) error
219 ServiceYamls() []ServiceYaml
220}
221
212// TODO split into payloads per package type composing the common222// TODO split into payloads per package type composing the common
213// elements for all snaps.223// elements for all snaps.
214type packageYaml struct {224type packageYaml struct {
@@ -529,17 +539,16 @@
529}539}
530540
531// NewInstalledSnapPart returns a new SnapPart from the given yamlPath541// NewInstalledSnapPart returns a new SnapPart from the given yamlPath
532func NewInstalledSnapPart(yamlPath, origin string) (*SnapPart, error) {542func NewInstalledSnapPart(yamlPath, origin string) (SnapIF, error) {
533 m, err := parsePackageYamlFile(yamlPath)543 m, err := parsePackageYamlFile(yamlPath)
534 if err != nil {544 if err != nil {
535 return nil, err545 return nil, err
536 }546 }
537547
538 part, err := NewSnapPartFromYaml(yamlPath, origin, m)548 part, err := newSnapPartFromYaml(yamlPath, origin, m, true)
539 if err != nil {549 if err != nil {
540 return nil, err550 return nil, err
541 }551 }
542 part.isInstalled = true
543552
544 return part, nil553 return part, nil
545}554}
@@ -547,7 +556,7 @@
547// NewSnapPartFromSnapFile loads a snap from the given (clickdeb) snap file.556// NewSnapPartFromSnapFile loads a snap from the given (clickdeb) snap file.
548// Caller should call Close on the pkg.557// Caller should call Close on the pkg.
549// TODO: expose that Close.558// TODO: expose that Close.
550func NewSnapPartFromSnapFile(snapFile string, origin string, unauthOk bool) (*SnapPart, error) {559func NewSnapPartFromSnapFile(snapFile string, origin string, unauthOk bool) (SnapIF, error) {
551 d, err := pkg.Open(snapFile)560 d, err := pkg.Open(snapFile)
552 if err != nil {561 if err != nil {
553 return nil, err562 return nil, err
@@ -570,41 +579,45 @@
570 return nil, err579 return nil, err
571 }580 }
572581
573 // FIXME: make a special OemSnap that knows its install dir
574 // instead of having this special case here
575 targetDir := dirs.SnapAppsDir
576 // the "oem" parts are special
577 if m.Type == pkg.TypeOem {
578 targetDir = dirs.SnapOemDir
579 }
580
581 if origin == SideloadedOrigin {582 if origin == SideloadedOrigin {
582 m.Version = helpers.NewSideloadVersion()583 m.Version = helpers.NewSideloadVersion()
583 }584 }
584585
585 fullName := m.qualifiedName(origin)586 fullName := m.qualifiedName(origin)
586 instDir := filepath.Join(targetDir, fullName, m.Version)587 instDir := filepath.Join(dirs.SnapAppsDir, fullName, m.Version)
587588
588 baseSnap := &SnapPart{589 basePart := &SnapPart{
589 basedir: instDir,590 basedir: instDir,
590 origin: origin,591 origin: origin,
591 m: m,592 m: m,
592 deb: d,593 deb: d,
593 }594 }
594595
595 return baseSnap, nil596 // FIXME: duplicated code
597 switch m.Type {
598 case pkg.TypeOem:
599 basePart.basedir = filepath.Join(dirs.SnapOemDir, fullName, m.Version)
600 return &OemSnap{SnapPart: *basePart}, nil
601 case pkg.TypeOS:
602 return &OsSnap{SnapPart: *basePart}, nil
603 case pkg.TypeKernel:
604 return &KernelSnap{SnapPart: *basePart}, nil
605 }
606
607 return basePart, nil
596}608}
597609
598// NewSnapPartFromYaml returns a new SnapPart from the given *packageYaml at yamlPath610// newSnapPartFromYaml returns a new SnapPart from the given *packageYaml at yamlPath
599func NewSnapPartFromYaml(yamlPath, origin string, m *packageYaml) (*SnapPart, error) {611func newSnapPartFromYaml(yamlPath, origin string, m *packageYaml, installed bool) (SnapIF, error) {
600 if _, err := os.Stat(yamlPath); err != nil {612 if _, err := os.Stat(yamlPath); err != nil {
601 return nil, err613 return nil, err
602 }614 }
603615
604 part := &SnapPart{616 part := &SnapPart{
605 basedir: filepath.Dir(filepath.Dir(yamlPath)),617 basedir: filepath.Dir(filepath.Dir(yamlPath)),
606 origin: origin,618 origin: origin,
607 m: m,619 m: m,
620 isInstalled: installed,
608 }621 }
609622
610 // override the package's idea of its version623 // override the package's idea of its version
@@ -656,6 +669,19 @@
656 part.remoteM = &r669 part.remoteM = &r
657 }670 }
658671
672 // FIXME: duplicated code
673 basePart := part
674 switch m.Type {
675 case pkg.TypeOem:
676 fullName := m.qualifiedName(origin)
677 basePart.basedir = filepath.Join(dirs.SnapOemDir, fullName, m.Version)
678 return &OemSnap{SnapPart: *basePart}, nil
679 case pkg.TypeOS:
680 return &OsSnap{SnapPart: *basePart}, nil
681 case pkg.TypeKernel:
682 return &KernelSnap{SnapPart: *basePart}, nil
683 }
684
659 return part, nil685 return part, nil
660}686}
661687
@@ -674,6 +700,10 @@
674 return s.m.Name700 return s.m.Name
675}701}
676702
703func (s *SnapPart) Dir() string {
704 return s.basedir
705}
706
677// Version returns the version707// Version returns the version
678func (s *SnapPart) Version() string {708func (s *SnapPart) Version() string {
679 if s.basedir != "" {709 if s.basedir != "" {
@@ -809,17 +839,10 @@
809 return "", err839 return "", err
810 }840 }
811841
812 // the "oem" parts are special
813 if s.Type() == pkg.TypeOem {
814 if err := installOemHardwareUdevRules(s.m); err != nil {
815 return "", err
816 }
817 }
818
819 fullName := QualifiedName(s)842 fullName := QualifiedName(s)
820 dataDir := filepath.Join(dirs.SnapDataDir, fullName, s.Version())843 dataDir := filepath.Join(dirs.SnapDataDir, fullName, s.Version())
821844
822 var oldPart *SnapPart845 var oldPart SnapIF
823 if currentActiveDir, _ := filepath.EvalSymlinks(filepath.Join(s.basedir, "..", "current")); currentActiveDir != "" {846 if currentActiveDir, _ := filepath.EvalSymlinks(filepath.Join(s.basedir, "..", "current")); currentActiveDir != "" {
824 oldPart, err = NewInstalledSnapPart(filepath.Join(currentActiveDir, "meta", "package.yaml"), s.origin)847 oldPart, err = NewInstalledSnapPart(filepath.Join(currentActiveDir, "meta", "package.yaml"), s.origin)
825 if err != nil {848 if err != nil {
@@ -854,13 +877,6 @@
854 }877 }
855 }878 }
856879
857 // FIXME: move into KernelSnap instead of poluting generic code
858 if s.m.Type == pkg.TypeKernel {
859 if err := unpackKernel(s); err != nil {
860 return "", err
861 }
862 }
863
864 // legacy, the hooks (e.g. apparmor) need this. Once we converted880 // legacy, the hooks (e.g. apparmor) need this. Once we converted
865 // all hooks this can go away881 // all hooks this can go away
866 clickMetaDir := filepath.Join(s.basedir, ".click", "info")882 clickMetaDir := filepath.Join(s.basedir, ".click", "info")
@@ -1160,13 +1176,6 @@
11601176
1161// Uninstall remove the snap from the system1177// Uninstall remove the snap from the system
1162func (s *SnapPart) Uninstall(pb progress.Meter) (err error) {1178func (s *SnapPart) Uninstall(pb progress.Meter) (err error) {
1163 // OEM snaps should not be removed as they are a key
1164 // building block for OEMs. Prunning non active ones
1165 // is acceptible.
1166 if (s.m.Type == pkg.TypeOem || s.m.Type == pkg.TypeKernel || s.m.Type == pkg.TypeOS) && s.IsActive() {
1167 return ErrPackageNotRemovable
1168 }
1169
1170 if IsBuiltInSoftware(s.Name()) && s.IsActive() {1179 if IsBuiltInSoftware(s.Name()) && s.IsActive() {
1171 return ErrPackageNotRemovable1180 return ErrPackageNotRemovable
1172 }1181 }
@@ -1396,12 +1405,12 @@
1396}1405}
13971406
1398// RefreshDependentsSecurity refreshes the security policies of dependent snaps1407// RefreshDependentsSecurity refreshes the security policies of dependent snaps
1399func (s *SnapPart) RefreshDependentsSecurity(oldPart *SnapPart, inter interacter) (err error) {1408func (s *SnapPart) RefreshDependentsSecurity(oldPart SnapIF, inter interacter) (err error) {
1400 oldBaseDir := ""1409 oldBaseDir := ""
1401 if oldPart != nil {1410 if oldPart != nil {
1402 oldBaseDir = oldPart.basedir1411 oldBaseDir = oldPart.Dir()
1403 }1412 }
1404 upPol, upTpl := policy.AppArmorDelta(oldBaseDir, s.basedir, s.Name()+"_")1413 upPol, upTpl := policy.AppArmorDelta(oldBaseDir, s.Dir(), s.Name()+"_")
14051414
1406 deps, err := s.Dependents()1415 deps, err := s.Dependents()
1407 if err != nil {1416 if err != nil {
@@ -2066,7 +2075,7 @@
2066// The returned environment contains additional SNAP_* variables that2075// The returned environment contains additional SNAP_* variables that
2067// are required when calling a meta/hook/ script and that will override2076// are required when calling a meta/hook/ script and that will override
2068// any already existing SNAP_* variables in os.Environment()2077// any already existing SNAP_* variables in os.Environment()
2069func makeSnapHookEnv(part *SnapPart) (env []string) {2078func makeSnapHookEnv(part SnapIF) (env []string) {
2070 desc := struct {2079 desc := struct {
2071 AppName string2080 AppName string
2072 AppArch string2081 AppArch string
@@ -2077,7 +2086,7 @@
2077 }{2086 }{
2078 part.Name(),2087 part.Name(),
2079 helpers.UbuntuArchitecture(),2088 helpers.UbuntuArchitecture(),
2080 part.basedir,2089 part.Dir(),
2081 part.Version(),2090 part.Version(),
2082 QualifiedName(part),2091 QualifiedName(part),
2083 part.Origin(),2092 part.Origin(),
20842093
=== modified file 'snappy/snapp_snapfs_test.go'
--- snappy/snapp_snapfs_test.go 2015-10-20 14:48:11 +0000
+++ snappy/snapp_snapfs_test.go 2015-10-20 14:48:11 +0000
@@ -138,7 +138,7 @@
138 c.Assert(err, IsNil)138 c.Assert(err, IsNil)
139139
140 // ensure the right backend got picked up140 // ensure the right backend got picked up
141 c.Assert(part.deb, FitsTypeOf, &snapfs.Snap{})141 c.Assert(part.(*SnapPart).deb, FitsTypeOf, &snapfs.Snap{})
142}142}
143143
144func (s *SnapfsTestSuite) TestInstallViaSnapfsWorks(c *C) {144func (s *SnapfsTestSuite) TestInstallViaSnapfsWorks(c *C) {
@@ -312,7 +312,7 @@
312 c.Assert(err, IsNil)312 c.Assert(err, IsNil)
313 c.Assert(snap.NeedsReboot(), Equals, false)313 c.Assert(snap.NeedsReboot(), Equals, false)
314314
315 snap.isActive = false315 snap.(*OsSnap).isActive = false
316 mockb.bootvars["snappy_os"] = "ubuntu-core." + testOrigin + "_15.10-1.snap"316 mockb.bootvars["snappy_os"] = "ubuntu-core." + testOrigin + "_15.10-1.snap"
317 c.Assert(snap.NeedsReboot(), Equals, true)317 c.Assert(snap.NeedsReboot(), Equals, true)
318}318}
@@ -325,7 +325,7 @@
325 c.Assert(err, IsNil)325 c.Assert(err, IsNil)
326 c.Assert(snap.NeedsReboot(), Equals, false)326 c.Assert(snap.NeedsReboot(), Equals, false)
327327
328 snap.isActive = false328 snap.(*KernelSnap).isActive = false
329 mockb.bootvars["snappy_kernel"] = "ubuntu-kernel." + testOrigin + "_4.0-1.snap"329 mockb.bootvars["snappy_kernel"] = "ubuntu-kernel." + testOrigin + "_4.0-1.snap"
330 c.Assert(snap.NeedsReboot(), Equals, true)330 c.Assert(snap.NeedsReboot(), Equals, true)
331}331}
@@ -350,15 +350,24 @@
350 c.Assert(helpers.FileExists(kernelAssetsDir), Equals, false)350 c.Assert(helpers.FileExists(kernelAssetsDir), Equals, false)
351}351}
352352
353func (s *SnapfsTestSuite) TestActiveKernelOSNotRemovable(c *C) {353func (s *SnapfsTestSuite) TestActiveKernelNotRemovable(c *C) {
354 for _, yaml := range []string{packageKernel, packageOS} {354 snapYaml, err := makeInstalledMockSnap(dirs.GlobalRootDir, packageKernel)
355 snapYaml, err := makeInstalledMockSnap(dirs.GlobalRootDir, yaml)355 c.Assert(err, IsNil)
356 c.Assert(err, IsNil)356
357357 snap, err := NewInstalledSnapPart(snapYaml, testOrigin)
358 snap, err := NewInstalledSnapPart(snapYaml, testOrigin)358 c.Assert(err, IsNil)
359 c.Assert(err, IsNil)359
360360 snap.(*KernelSnap).isActive = true
361 snap.isActive = true361 c.Assert(snap.Uninstall(&MockProgressMeter{}), Equals, ErrPackageNotRemovable)
362 c.Assert(snap.Uninstall(&MockProgressMeter{}), Equals, ErrPackageNotRemovable)362}
363 }363
364func (s *SnapfsTestSuite) TestActiveOSNotRemovable(c *C) {
365 snapYaml, err := makeInstalledMockSnap(dirs.GlobalRootDir, packageOS)
366 c.Assert(err, IsNil)
367
368 snap, err := NewInstalledSnapPart(snapYaml, testOrigin)
369 c.Assert(err, IsNil)
370
371 snap.(*OsSnap).isActive = true
372 c.Assert(snap.Uninstall(&MockProgressMeter{}), Equals, ErrPackageNotRemovable)
364}373}
365374
=== modified file 'snappy/snapp_test.go'
--- snappy/snapp_test.go 2015-10-20 07:03:39 +0000
+++ snappy/snapp_test.go 2015-10-20 14:48:11 +0000
@@ -152,11 +152,11 @@
152 c.Assert(services[0].Name, Equals, "svc1")152 c.Assert(services[0].Name, Equals, "svc1")
153153
154 // ensure we get valid Date()154 // ensure we get valid Date()
155 st, err := os.Stat(snap.basedir)155 st, err := os.Stat(snap.Dir())
156 c.Assert(err, IsNil)156 c.Assert(err, IsNil)
157 c.Assert(snap.Date(), Equals, st.ModTime())157 c.Assert(snap.Date(), Equals, st.ModTime())
158158
159 c.Assert(snap.basedir, Equals, filepath.Join(s.tempdir, "apps", helloAppComposedName, "1.10"))159 c.Assert(snap.Dir(), Equals, filepath.Join(s.tempdir, "apps", helloAppComposedName, "1.10"))
160 c.Assert(snap.InstalledSize(), Not(Equals), -1)160 c.Assert(snap.InstalledSize(), Not(Equals), -1)
161}161}
162162
@@ -825,11 +825,11 @@
825 c.Assert(services[1].Description, Equals, "Service #2")825 c.Assert(services[1].Description, Equals, "Service #2")
826826
827 // ensure we get valid Date()827 // ensure we get valid Date()
828 st, err := os.Stat(snap.basedir)828 st, err := os.Stat(snap.Dir())
829 c.Assert(err, IsNil)829 c.Assert(err, IsNil)
830 c.Assert(snap.Date(), Equals, st.ModTime())830 c.Assert(snap.Date(), Equals, st.ModTime())
831831
832 c.Assert(snap.basedir, Equals, filepath.Join(s.tempdir, "apps", helloAppComposedName, "1.10"))832 c.Assert(snap.Dir(), Equals, filepath.Join(s.tempdir, "apps", helloAppComposedName, "1.10"))
833 c.Assert(snap.InstalledSize(), Not(Equals), -1)833 c.Assert(snap.InstalledSize(), Not(Equals), -1)
834}834}
835835

Subscribers

People subscribed via source and target branches