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

Proposed by Sergio Schvezov
Status: Needs review
Proposed branch: lp:~sergiusens/snappy/rollYourOwnCorePersonal
Merge into: lp:~snappy-dev/snappy/snappy-moved-to-github
Diff against target: 220 lines (+50/-34)
6 files modified
cmd/snappy/cmd_info.go (+2/-11)
release/release.go (+19/-10)
release/release_test.go (+10/-10)
snappy/snapp_test.go (+1/-1)
snappy/systemimage.go (+3/-2)
snappy/systemimage_test.go (+15/-0)
To merge this branch: bzr merge lp:~sergiusens/snappy/rollYourOwnCorePersonal
Reviewer Review Type Date Requested Status
Federico Gimenez (community) continuous-integration Approve
Michael Vogt (community) Needs Information
Snappy Tarmac continuous-integration Pending
Review via email: mp+264405@code.launchpad.net

Commit message

Snappy to expose the core package as personal or core depending on the release

Description of the change

This will affect snappy config (and maybe oem packages that define configs) so releases for snaps may have to be split up after this

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

Thanks, this looks good! I have some question inline, probably mostly my own ignorance.

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

On Mon, Jul 13, 2015 at 07:04:25AM -0000, Michael Vogt wrote:
> Review: Needs Information
>
> Thanks, this looks good! I have some question inline, probably mostly my own ignorance.
>
> Diff comments:
>
> > === modified file 'cmd/snappy/cmd_info.go'
> > --- cmd/snappy/cmd_info.go 2015-07-01 14:56:49 +0000
> > +++ cmd/snappy/cmd_info.go 2015-07-10 11:47:46 +0000
> > @@ -90,22 +91,12 @@
> > return nil
> > }
> >
> > -func ubuntuCoreChannel() string {
> > - parts, err := snappy.ActiveSnapsByType(pkg.TypeCore)
> > - if len(parts) == 1 && err == nil {
> > - return parts[0].Channel()
> > - }
> > -
> > - return "unknown"
> > -}
> > -
> > func info() error {
> > - release := ubuntuCoreChannel()
> > frameworks, _ := snappy.ActiveSnapNamesByType(pkg.TypeFramework)
> > apps, _ := snappy.ActiveSnapNamesByType(pkg.TypeApp)
> >
> > // TRANSLATORS: the %s release string
> > - fmt.Printf(i18n.G("release: %s\n"), release)
> > + fmt.Printf(i18n.G("release: %s\n"), release.String())
>
> This is nice (i.e. that all the code above gets killed :)
>

\o/

> > // TRANSLATORS: the %s an architecture string
> > fmt.Printf(i18n.G("architecture: %s\n"), snappy.Architecture())
> > // TRANSLATORS: the %s is a comma separated list of framework names
> >
> > === modified file 'release/release.go'
> > --- release/release.go 2015-05-15 13:33:27 +0000
> > +++ release/release.go 2015-07-10 11:47:46 +0000
> > @@ -51,9 +51,18 @@
> > return rel.String()
> > }
> >
> > +// Flavor returns the flavor for the release.
> > +func Flavor() string {
> > + return rel.flavor
> > +}
> > +
> > // Override sets up the release using a Release
> > -func Override(r Release) {
> > - rel = r
> > +func Override(flavor, series, channel string) {
>
> What the purpose of this function? AFAICT its only used in systemimage_test.go. Or is it there to allow overrides in the future? If thats the case, why will we need "overrides"? It seems like the channel.ini gives us the "ubuntu-{core,personal}" information as part of its Setup (or am I missing something)?
>

You forget about u-d-f and obtaining the first oem snap that has all the
info we need ;-)

> > + rel = Release{
> > + flavor: flavor,
> > + series: series,
> > + channel: channel,
> > + }
> > }
> >
> > // Setup is used to initialiaze the release information for the system
> >
> > === modified file 'snappy/systemimage.go'
> > --- snappy/systemimage.go 2015-07-01 14:48:33 +0000
> > +++ snappy/systemimage.go 2015-07-10 11:47:46 +0000
> > @@ -97,7 +98,7 @@
> >
> > // Name returns the name
> > func (s *SystemImagePart) Name() string {
> > - return systemImagePartName
> > + return fmt.Sprintf("ubuntu-%s", release.Flavor())
>
> Yay for this! Makes me wonder if we should move the "ubuntu-" string into release as well so that systemimage.go is a bit more agonstic about (but really minor minor).
>

Maybe so, but we also need to be backwards compatible here; if we can,
I'm all for it!

> > }
> >
> > // Origin returns the origin ("ubuntu")
>
>
> --
> https://code.launchpad.net/~sergiusens/snappy/rollYourOwnCorePersonal/+merge/264405
> You are the owner of lp:~sergiusens/snappy/rollYourOwnCorePersonal.

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

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

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

review: Approve (continuous-integration)

Unmerged revisions

570. By Sergio Schvezov

Snappy to expose the core package as personal or core depending on the release

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'cmd/snappy/cmd_info.go'
--- cmd/snappy/cmd_info.go 2015-07-01 14:56:49 +0000
+++ cmd/snappy/cmd_info.go 2015-07-10 11:47:46 +0000
@@ -26,6 +26,7 @@
26 "launchpad.net/snappy/i18n"26 "launchpad.net/snappy/i18n"
27 "launchpad.net/snappy/logger"27 "launchpad.net/snappy/logger"
28 "launchpad.net/snappy/pkg"28 "launchpad.net/snappy/pkg"
29 "launchpad.net/snappy/release"
29 "launchpad.net/snappy/snappy"30 "launchpad.net/snappy/snappy"
30)31)
3132
@@ -90,22 +91,12 @@
90 return nil91 return nil
91}92}
9293
93func ubuntuCoreChannel() string {
94 parts, err := snappy.ActiveSnapsByType(pkg.TypeCore)
95 if len(parts) == 1 && err == nil {
96 return parts[0].Channel()
97 }
98
99 return "unknown"
100}
101
102func info() error {94func info() error {
103 release := ubuntuCoreChannel()
104 frameworks, _ := snappy.ActiveSnapNamesByType(pkg.TypeFramework)95 frameworks, _ := snappy.ActiveSnapNamesByType(pkg.TypeFramework)
105 apps, _ := snappy.ActiveSnapNamesByType(pkg.TypeApp)96 apps, _ := snappy.ActiveSnapNamesByType(pkg.TypeApp)
10697
107 // TRANSLATORS: the %s release string98 // TRANSLATORS: the %s release string
108 fmt.Printf(i18n.G("release: %s\n"), release)99 fmt.Printf(i18n.G("release: %s\n"), release.String())
109 // TRANSLATORS: the %s an architecture string100 // TRANSLATORS: the %s an architecture string
110 fmt.Printf(i18n.G("architecture: %s\n"), snappy.Architecture())101 fmt.Printf(i18n.G("architecture: %s\n"), snappy.Architecture())
111 // TRANSLATORS: the %s is a comma separated list of framework names102 // TRANSLATORS: the %s is a comma separated list of framework names
112103
=== modified file 'release/release.go'
--- release/release.go 2015-05-15 13:33:27 +0000
+++ release/release.go 2015-07-10 11:47:46 +0000
@@ -30,9 +30,9 @@
3030
31// Release contains a structure with the release information31// Release contains a structure with the release information
32type Release struct {32type Release struct {
33 Flavor string33 flavor string
34 Series string34 series string
35 Channel string35 channel string
36}36}
3737
38var rel Release38var rel Release
@@ -43,7 +43,7 @@
4343
44// setLegacy is a helper to set the default initial release of 15.04-core44// setLegacy is a helper to set the default initial release of 15.04-core
45func setLegacy() {45func setLegacy() {
46 rel = Release{Flavor: "core", Series: "15.04"}46 rel = Release{flavor: "core", series: "15.04"}
47}47}
4848
49// String returns the release information in a string49// String returns the release information in a string
@@ -51,9 +51,18 @@
51 return rel.String()51 return rel.String()
52}52}
5353
54// Flavor returns the flavor for the release.
55func Flavor() string {
56 return rel.flavor
57}
58
54// Override sets up the release using a Release59// Override sets up the release using a Release
55func Override(r Release) {60func Override(flavor, series, channel string) {
56 rel = r61 rel = Release{
62 flavor: flavor,
63 series: series,
64 channel: channel,
65 }
57}66}
5867
59// Setup is used to initialiaze the release information for the system68// Setup is used to initialiaze the release information for the system
@@ -84,9 +93,9 @@
84 }93 }
8594
86 rel = Release{95 rel = Release{
87 Flavor: strings.Trim(channelParts[0], "ubuntu-"),96 flavor: strings.Trim(channelParts[0], "ubuntu-"),
88 Series: channelParts[1],97 series: channelParts[1],
89 Channel: channelParts[2],98 channel: channelParts[2],
90 }99 }
91100
92 return nil101 return nil
@@ -95,5 +104,5 @@
95// String returns the release information in a string which is valid to104// String returns the release information in a string which is valid to
96// set for the store http headers.105// set for the store http headers.
97func (r Release) String() string {106func (r Release) String() string {
98 return fmt.Sprintf("%s-%s", r.Series, r.Flavor)107 return fmt.Sprintf("%s-%s", r.series, r.flavor)
99}108}
100109
=== modified file 'release/release_test.go'
--- release/release_test.go 2015-06-02 20:53:10 +0000
+++ release/release_test.go 2015-07-10 11:47:46 +0000
@@ -59,17 +59,17 @@
5959
60 c.Assert(Setup(s.root), IsNil)60 c.Assert(Setup(s.root), IsNil)
61 c.Check(String(), Equals, "15.04-core")61 c.Check(String(), Equals, "15.04-core")
62 c.Check(rel.Flavor, Equals, "core")62 c.Check(rel.flavor, Equals, "core")
63 c.Check(rel.Series, Equals, "15.04")63 c.Check(rel.series, Equals, "15.04")
64 c.Check(rel.Channel, Equals, "edge")64 c.Check(rel.channel, Equals, "edge")
65}65}
6666
67func (s *ReleaseTestSuite) TestOverride(c *C) {67func (s *ReleaseTestSuite) TestOverride(c *C) {
68 Override(Release{Flavor: "personal", Series: "10.06", Channel: "beta"})68 Override("personal", "10.06", "beta")
69 c.Check(String(), Equals, "10.06-personal")69 c.Check(String(), Equals, "10.06-personal")
70 c.Check(rel.Flavor, Equals, "personal")70 c.Check(rel.flavor, Equals, "personal")
71 c.Check(rel.Series, Equals, "10.06")71 c.Check(rel.series, Equals, "10.06")
72 c.Check(rel.Channel, Equals, "beta")72 c.Check(rel.channel, Equals, "beta")
73}73}
7474
75func (s *ReleaseTestSuite) TestSetupLegacyChannels(c *C) {75func (s *ReleaseTestSuite) TestSetupLegacyChannels(c *C) {
@@ -77,9 +77,9 @@
7777
78 c.Assert(Setup(s.root), IsNil)78 c.Assert(Setup(s.root), IsNil)
79 c.Check(String(), Equals, "15.04-core")79 c.Check(String(), Equals, "15.04-core")
80 c.Check(rel.Flavor, Equals, "core")80 c.Check(rel.flavor, Equals, "core")
81 c.Check(rel.Series, Equals, "15.04")81 c.Check(rel.series, Equals, "15.04")
82 c.Check(rel.Channel, Equals, "")82 c.Check(rel.channel, Equals, "")
83}83}
8484
85func (s *ReleaseTestSuite) TestNoChannelErrors(c *C) {85func (s *ReleaseTestSuite) TestNoChannelErrors(c *C) {
8686
=== modified file 'snappy/snapp_test.go'
--- snappy/snapp_test.go 2015-06-30 02:32:37 +0000
+++ snappy/snapp_test.go 2015-07-10 11:47:46 +0000
@@ -63,7 +63,7 @@
63 os.MkdirAll(snapServicesDir, 0755)63 os.MkdirAll(snapServicesDir, 0755)
64 os.MkdirAll(snapSeccompDir, 0755)64 os.MkdirAll(snapSeccompDir, 0755)
6565
66 release.Override(release.Release{Flavor: "core", Series: "15.04"})66 release.Override("core", "15.04", "")
6767
68 clickSystemHooksDir = filepath.Join(s.tempdir, "/usr/share/click/hooks")68 clickSystemHooksDir = filepath.Join(s.tempdir, "/usr/share/click/hooks")
69 os.MkdirAll(clickSystemHooksDir, 0755)69 os.MkdirAll(clickSystemHooksDir, 0755)
7070
=== modified file 'snappy/systemimage.go'
--- snappy/systemimage.go 2015-07-01 14:48:33 +0000
+++ snappy/systemimage.go 2015-07-10 11:47:46 +0000
@@ -37,6 +37,7 @@
37 "launchpad.net/snappy/pkg"37 "launchpad.net/snappy/pkg"
38 "launchpad.net/snappy/progress"38 "launchpad.net/snappy/progress"
39 "launchpad.net/snappy/provisioning"39 "launchpad.net/snappy/provisioning"
40 "launchpad.net/snappy/release"
40)41)
4142
42const (43const (
@@ -97,7 +98,7 @@
9798
98// Name returns the name99// Name returns the name
99func (s *SystemImagePart) Name() string {100func (s *SystemImagePart) Name() string {
100 return systemImagePartName101 return fmt.Sprintf("ubuntu-%s", release.Flavor())
101}102}
102103
103// Origin returns the origin ("ubuntu")104// Origin returns the origin ("ubuntu")
@@ -234,7 +235,7 @@
234 if err = s.partition.ToggleNextBoot(); err != nil {235 if err = s.partition.ToggleNextBoot(); err != nil {
235 return "", err236 return "", err
236 }237 }
237 return systemImagePartName, nil238 return s.Name(), nil
238}239}
239240
240// Ensure the expected version update was applied to the expected partition.241// Ensure the expected version update was applied to the expected partition.
241242
=== modified file 'snappy/systemimage_test.go'
--- snappy/systemimage_test.go 2015-07-01 14:48:33 +0000
+++ snappy/systemimage_test.go 2015-07-10 11:47:46 +0000
@@ -30,6 +30,7 @@
3030
31 "launchpad.net/snappy/partition"31 "launchpad.net/snappy/partition"
32 "launchpad.net/snappy/provisioning"32 "launchpad.net/snappy/provisioning"
33 "launchpad.net/snappy/release"
3334
34 . "gopkg.in/check.v1"35 . "gopkg.in/check.v1"
35)36)
@@ -146,6 +147,20 @@
146 c.Assert(parts[0].DownloadSize(), Equals, int64(123166488))147 c.Assert(parts[0].DownloadSize(), Equals, int64(123166488))
147}148}
148149
150func (s *SITestSuite) TestUpdateHasUpdateForPersonal(c *C) {
151 // change name
152 release.Override("personal", "rolling", "edge")
153
154 // add a update
155 mockSystemImageIndexJSON = fmt.Sprintf(mockSystemImageIndexJSONTemplate, "2")
156 parts, err := s.systemImage.Updates()
157 c.Assert(err, IsNil)
158 c.Assert(parts, HasLen, 1)
159 c.Assert(parts[0].Name(), Equals, "ubuntu-personal")
160 c.Assert(parts[0].Version(), Equals, "2")
161 c.Assert(parts[0].DownloadSize(), Equals, int64(123166488))
162}
163
149type MockPartition struct {164type MockPartition struct {
150 toggleNextBootCalled bool165 toggleNextBootCalled bool
151 markBootSuccessfulCalled bool166 markBootSuccessfulCalled bool

Subscribers

People subscribed via source and target branches