summaryrefslogtreecommitdiff
diff options
authorJames Hunt <james.hunt@ubuntu.com>2015-03-17 11:59:45 +0000
committerJames Hunt <james.hunt@ubuntu.com>2015-03-17 11:59:45 +0000
commit0959714025c336ffefb28822ca2493b3ef1946ac (patch)
tree5f01a2a190291c70f920bc74c5d2e229d851b5ba
parent5a86fc986de5d8f2166220b2b87b72a74b4a7c8e (diff)
parentbabb13b953823d99d622eb76710b7d2c5a952607 (diff)
* Sync with lp:snappy.
-rw-r--r--data/completion/snappy-go14
-rw-r--r--debian/install1
-rwxr-xr-xdebian/rules11
-rw-r--r--snappy/build.go1
-rw-r--r--snappy/build_test.go4
-rw-r--r--snappy/snapp.go17
-rw-r--r--snappy/snapp_test.go33
7 files changed, 77 insertions, 4 deletions
diff --git a/data/completion/snappy-go b/data/completion/snappy-go
new file mode 100644
index 0000000000..4fe1a794aa
--- /dev/null
+++ b/data/completion/snappy-go
@@ -0,0 +1,14 @@
+_complete() {
+ # All arguments except the first one
+ args=("${COMP_WORDS[@]:1:$COMP_CWORD}")
+
+ # Only split on newlines
+ local IFS=$'\n'
+
+ # Call completion (note that the first element of COMP_WORDS is
+ # the executable itself)
+ COMPREPLY=($(GO_FLAGS_COMPLETION=1 ${COMP_WORDS[0]} "${args[@]}"))
+ return 0
+}
+
+complete -F _complete snappy-go
diff --git a/debian/install b/debian/install
index 2affa2aa13..c0ee392639 100644
--- a/debian/install
+++ b/debian/install
@@ -1,2 +1,3 @@
debian/*.service /lib/systemd/system/
debian/*.timer /lib/systemd/system/
+data/completion/snappy-go /usr/share/bash-completion/completions/
diff --git a/debian/rules b/debian/rules
index 9318569ec3..5b71b010f7 100755
--- a/debian/rules
+++ b/debian/rules
@@ -11,12 +11,15 @@ export DH_GOPKG := launchpad.net/snappy
override_dh_systemd_enable:
# disabled for now because there is a "boot-ok" service in the python
# snappy implementation as well
- #dh_systemd_enable ubuntu-core-snappy.boot-ok.service
+ dh_systemd_enable --no-enable ubuntu-core-snappy.boot-ok.service
# we want autopilot disabled by default for now
- # it is explicitly listed here so it's not enabled
- # by mistake.
- # dh_systemd_enable snappy-autopilot.timer
+ dh_systemd_enable --no-enable snappy-autopilot.timer snappy-autopilot.service
+
+override_dh_systemd_start:
+ # ensure those disabled units are not started as well
+ dh_systemd_start --no-start ubuntu-core-snappy.boot-ok.service
+ dh_systemd_start --no-start snappy-autopilot.timer snappy-autopilot.service
override_dh_auto_install:
dh_auto_install -O--buildsystem=golang
diff --git a/snappy/build.go b/snappy/build.go
index 1760ad0665..ad7fc16a38 100644
--- a/snappy/build.go
+++ b/snappy/build.go
@@ -237,6 +237,7 @@ func writeClickManifest(buildDir string, m *packageYaml) error {
InstalledSize: installedSize,
Title: title,
Description: description,
+ Maintainer: m.Vendor,
Hooks: m.Integration,
}
manifestContent, err := json.MarshalIndent(cm, "", " ")
diff --git a/snappy/build_test.go b/snappy/build_test.go
index 82c428628f..bcf14d9c49 100644
--- a/snappy/build_test.go
+++ b/snappy/build_test.go
@@ -78,6 +78,7 @@ integration:
"framework": "ubuntu-core-15.04-dev1",
"description": "some description",
"installed-size": "17",
+ "maintainer": "Foo \u003cfoo@example.com\u003e",
"title": "some title",
"hooks": {
"app": {
@@ -121,6 +122,7 @@ binaries:
"framework": "ubuntu-core-15.04-dev1",
"description": "some description",
"installed-size": "17",
+ "maintainer": "Foo \u003cfoo@example.com\u003e",
"title": "some title",
"hooks": {
"hello-world": {
@@ -159,6 +161,7 @@ services:
"framework": "ubuntu-core-15.04-dev1",
"description": "some description",
"installed-size": "17",
+ "maintainer": "Foo \u003cfoo@example.com\u003e",
"title": "some title",
"hooks": {
"foo": {
@@ -211,6 +214,7 @@ vendor: Foo <foo@example.com>
"framework": "ubuntu-core-15.04-dev1",
"description": "fixme-description",
"installed-size": "17",
+ "maintainer": "Foo \u003cfoo@example.com\u003e",
"title": "some title",
"hooks": {
"snappy-config": {
diff --git a/snappy/snapp.go b/snappy/snapp.go
index 8dd012f8e8..e2fd5faba7 100644
--- a/snappy/snapp.go
+++ b/snappy/snapp.go
@@ -83,6 +83,11 @@ type packageYaml struct {
Services []Service `yaml:"services,omitempty"`
Binaries []Binary `yaml:"binaries,omitempty"`
+ // oem snap only
+ Store struct {
+ ID string `yaml:"id,omitempty"`
+ } `yaml:"store,omitempty"`
+
// this is a bit ugly, but right now integration is a one:one
// mapping of click hooks
Integration map[string]clickAppHook
@@ -550,11 +555,23 @@ func NewUbuntuStoreSnapRepository() *SnapUbuntuStoreRepository {
// small helper that sets the correct http headers for the ubuntu store
func setUbuntuStoreHeaders(req *http.Request) {
req.Header.Set("Accept", "application/hal+json")
+
+ // frameworks
frameworks, _ := InstalledSnapNamesByType(SnapTypeFramework)
frameworks = append(frameworks, "ubuntu-core-15.04-dev1")
req.Header.Set("X-Ubuntu-Frameworks", strings.Join(frameworks, ","))
req.Header.Set("X-Ubuntu-Architecture", helpers.Architecture())
+ // check if the oem part sets a custom store-id
+ oems, _ := InstalledSnapsByType(SnapTypeOem)
+ if len(oems) == 1 {
+ storeID := oems[0].(*SnapPart).m.Store.ID
+ if storeID != "" {
+ req.Header.Set("X-Ubuntu-Store", storeID)
+ }
+ }
+
+ // sso
ssoToken, err := ReadStoreToken()
if err == nil {
req.Header.Set("Authorization", makeOauthPlaintextSignature(req, ssoToken))
diff --git a/snappy/snapp_test.go b/snappy/snapp_test.go
index ab5c4cbcd6..7de8dbb93a 100644
--- a/snappy/snapp_test.go
+++ b/snappy/snapp_test.go
@@ -360,6 +360,10 @@ func (s *SnapTestSuite) TestUbuntuStoreRepositoryUpdatesNoSnaps(c *C) {
func (s *SnapTestSuite) TestUbuntuStoreRepositoryDetails(c *C) {
mockServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ // no store ID by default
+ storeID := r.Header.Get("X-Ubuntu-Store")
+ c.Assert(storeID, Equals, "")
+
c.Assert(strings.HasSuffix(r.URL.String(), "xkcd-webserver"), Equals, true)
io.WriteString(w, MockDetailsJSON)
}))
@@ -545,3 +549,32 @@ vendor: Michael Vogt <mvo@ubuntu.com>
c.Assert(err, IsNil)
c.Assert(m.Architectures, DeepEquals, []string{"all"})
}
+
+func (s *SnapTestSuite) TestUbuntuStoreRepositoryOemStoreId(c *C) {
+ mockServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+ // ensure we get the right header
+ storeID := r.Header.Get("X-Ubuntu-Store")
+ c.Assert(storeID, Equals, "my-store")
+ w.WriteHeader(404)
+ }))
+ c.Assert(mockServer, NotNil)
+ defer mockServer.Close()
+
+ // install custom oem snap with store-id
+ packageYaml, err := makeInstalledMockSnap(s.tempdir, `name: oem-test
+version: 1.0
+vendor: mvo
+store:
+ id: my-store
+type: oem
+`)
+ c.Assert(err, IsNil)
+ makeSnapActive(packageYaml)
+
+ storeDetailsURI = mockServer.URL + "/%s"
+ repo := NewUbuntuStoreSnapRepository()
+ c.Assert(repo, NotNil)
+
+ // we just ensure that the right header is set
+ repo.Details("xkcd")
+}