Merging trunk

This commit is contained in:
Sergio Schvezov
2015-04-21 10:33:21 -03:00
8 changed files with 110 additions and 31 deletions

View File

@@ -53,6 +53,11 @@ func (x *cmdBuild) Execute(args []string) (err error) {
return err
}
_, err = exec.LookPath(clickReview)
if err != nil {
fmt.Fprintf(os.Stderr, "Warning: could not review package (%s not available)\n", clickReview)
}
cmd := exec.Command(clickReview, snapPackage)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr

6
debian/control vendored
View File

@@ -29,12 +29,14 @@ Description: snappy development go packages.
Package: ubuntu-snappy
Architecture: all
Depends: apparmor-easyprof-ubuntu-snappy,
debsig-verify,
Depends: debsig-verify,
system-image-snappy-cli,
ubuntu-snappy-cli (= ${binary:Version}),
ubuntu-core-upgrader,
ubuntu-core-launcher (>= 0.2.3),
ubuntu-core-security-seccomp,
ubuntu-core-security-apparmor,
ubuntu-core-security-utils,
${misc:Depends}
Description: System components for Ubuntu Core Snappy.
Components and services that take care of an Ubuntu system with snappy.

View File

@@ -357,8 +357,7 @@ func generateSnapBinaryWrapper(binary Binary, pkgPath, aaProfile string, m *pack
set -e
#FIXME: namespace
TMPDIR="/tmp/snaps/{{.Name}}/{{.Version}}/tmp"
TMPDIR="/tmp/snaps/{{.UdevAppName}}/{{.Version}}/tmp"
if [ ! -d "$TMPDIR" ]; then
mkdir -p -m1777 "$TMPDIR"
fi
@@ -412,12 +411,12 @@ ubuntu-core-launcher {{.UdevAppName}} {{.AaProfile}} {{.Target}} "$@"
AaProfile string
UdevAppName string
}{
m.Name,
m.Version,
actualBinPath,
pkgPath,
aaProfile,
udevPartName,
Name: m.Name,
Version: m.Version,
Target: actualBinPath,
Path: pkgPath,
AaProfile: aaProfile,
UdevAppName: udevPartName,
}
t.Execute(&templateOut, wrapperData)
@@ -867,6 +866,10 @@ func installClick(snapFile string, flags InstallFlags, inter interacter, namespa
return "", err
}
if err := m.checkForPackageInstalled(namespace); err != nil {
return "", err
}
if err := m.checkForNameClashes(); err != nil {
return "", err
}

View File

@@ -170,7 +170,7 @@ Pattern: /var/lib/apparmor/click/${id}
c.Assert(err, NotNil)
}
func (s *SnapTestSuite) TestLocalSnapInstall(c *C) {
func (s *SnapTestSuite) testLocalSnapInstall(c *C) string {
snapFile := makeTestSnapPackage(c, "")
name, err := installClick(snapFile, 0, nil, testNamespace)
c.Assert(err, IsNil)
@@ -194,6 +194,19 @@ func (s *SnapTestSuite) TestLocalSnapInstall(c *C) {
snap, err := NewInstalledSnapPart(filepath.Join(baseDir, "meta", "package.yaml"), testNamespace)
c.Assert(err, IsNil)
c.Assert(snap.Hash(), Not(Equals), "")
return snapFile
}
func (s *SnapTestSuite) TestLocalSnapInstall(c *C) {
s.testLocalSnapInstall(c)
}
func (s *SnapTestSuite) TestLocalSnapInstallFailsAlreadyInstalled(c *C) {
snapFile := s.testLocalSnapInstall(c)
_, err := installClick(snapFile, 0, nil, "namespaceother")
c.Assert(err, Equals, ErrPackageNameAlreadyInstalled)
}
func (s *SnapTestSuite) TestLocalSnapInstallDebsigVerifyFails(c *C) {
@@ -694,8 +707,7 @@ const expectedWrapper = `#!/bin/sh
set -e
#FIXME: namespace
TMPDIR="/tmp/snaps/pastebinit/1.4.0.0.1/tmp"
TMPDIR="/tmp/snaps/pastebinit.mvo/1.4.0.0.1/tmp"
if [ ! -d "$TMPDIR" ]; then
mkdir -p -m1777 "$TMPDIR"
fi
@@ -1148,11 +1160,11 @@ Description=A fun webserver
X-Snappy=yes
[Service]
ExecStart=/usr/bin/ubuntu-core-launcher xkcd-webserver%s xkcd-webserver.canonical_xkcd-webserver_0.3.4 /apps/xkcd-webserver.canonical/0.3.4/bin/foo start
WorkingDirectory=/apps/xkcd-webserver.canonical/0.3.4/
Environment="SNAPP_APP_PATH=/apps/xkcd-webserver.canonical/0.3.4/" "SNAPP_APP_DATA_PATH=/var/lib/apps/xkcd-webserver.canonical/0.3.4/" "SNAPP_APP_USER_DATA_PATH=%%h/apps/xkcd-webserver.canonical/0.3.4/" "SNAP_APP_PATH=/apps/xkcd-webserver.canonical/0.3.4/" "SNAP_APP_DATA_PATH=/var/lib/apps/xkcd-webserver.canonical/0.3.4/" "SNAP_APP_USER_DATA_PATH=%%h/apps/xkcd-webserver.canonical/0.3.4/" "SNAP_APP=xkcd-webserver_xkcd-webserver_0.3.4" "TMPDIR=/tmp/snaps/xkcd-webserver/0.3.4/tmp" "SNAP_APP_TMPDIR=/tmp/snaps/xkcd-webserver/0.3.4/tmp"
ExecStop=/apps/xkcd-webserver.canonical/0.3.4/bin/foo stop
ExecStopPost=/apps/xkcd-webserver.canonical/0.3.4/bin/foo post-stop
ExecStart=/usr/bin/ubuntu-core-launcher xkcd-webserver%s xkcd-webserver%[2]s_xkcd-webserver_0.3.4 /apps/xkcd-webserver%[2]s/0.3.4/bin/foo start
WorkingDirectory=/apps/xkcd-webserver%[2]s/0.3.4/
Environment="SNAPP_APP_PATH=/apps/xkcd-webserver%[2]s/0.3.4/" "SNAPP_APP_DATA_PATH=/var/lib/apps/xkcd-webserver%[2]s/0.3.4/" "SNAPP_APP_USER_DATA_PATH=%%h/apps/xkcd-webserver%[2]s/0.3.4/" "SNAP_APP_PATH=/apps/xkcd-webserver%[2]s/0.3.4/" "SNAP_APP_DATA_PATH=/var/lib/apps/xkcd-webserver%[2]s/0.3.4/" "SNAP_APP_USER_DATA_PATH=%%h/apps/xkcd-webserver%[2]s/0.3.4/" "SNAP_APP=xkcd-webserver_xkcd-webserver_0.3.4" "TMPDIR=/tmp/snaps/xkcd-webserver%[2]s/0.3.4/tmp" "SNAP_APP_TMPDIR=/tmp/snaps/xkcd-webserver%[2]s/0.3.4/tmp"
ExecStop=/apps/xkcd-webserver%[2]s/0.3.4/bin/foo stop
ExecStopPost=/apps/xkcd-webserver%[2]s/0.3.4/bin/foo post-stop
TimeoutStopSec=30
%s
@@ -1192,8 +1204,8 @@ func (s *SnapTestSuite) TestSnappyGenerateSnapServiceFmkWrapper(c *C) {
Description: "A fun webserver",
BusName: "foo.bar.baz",
}
pkgPath := "/apps/xkcd-webserver.canonical/0.3.4/"
aaProfile := "xkcd-webserver.canonical_xkcd-webserver_0.3.4"
pkgPath := "/apps/xkcd-webserver/0.3.4/"
aaProfile := "xkcd-webserver_xkcd-webserver_0.3.4"
m := packageYaml{
Name: "xkcd-webserver",
Version: "0.3.4",

View File

@@ -326,8 +326,22 @@ func (m *packageYaml) checkForNameClashes() error {
return nil
}
func (m *packageYaml) FrameworksForClick() string {
fmks := m.Frameworks
func (m *packageYaml) checkForPackageInstalled(namespace string) error {
part := ActiveSnapByName(m.Name)
if part == nil {
return nil
}
if m.Type != SnapTypeFramework {
if part.Namespace() != namespace {
return ErrPackageNameAlreadyInstalled
}
}
return nil
}
func addCoreFmk(fmks []string) []string {
fmkCore := false
for _, a := range fmks {
if a == "ubuntu-core-15.04-dev1" {
@@ -335,10 +349,17 @@ func (m *packageYaml) FrameworksForClick() string {
break
}
}
if !fmkCore {
fmks = append(fmks, "ubuntu-core-15.04-dev1")
}
return fmks
}
func (m *packageYaml) FrameworksForClick() string {
fmks := addCoreFmk(m.Frameworks)
return strings.Join(fmks, ",")
}
@@ -1070,7 +1091,7 @@ func setUbuntuStoreHeaders(req *http.Request) {
// frameworks
frameworks, _ := ActiveSnapNamesByType(SnapTypeFramework)
req.Header.Set("X-Ubuntu-Frameworks", strings.Join(frameworks, ","))
req.Header.Set("X-Ubuntu-Frameworks", strings.Join(addCoreFmk(frameworks), ","))
req.Header.Set("X-Ubuntu-Architecture", string(Architecture()))
req.Header.Set("X-Ubuntu-Release", release.String())

View File

@@ -973,6 +973,42 @@ framework: three, four
c.Assert(err, Equals, ErrInvalidFrameworkSpecInYaml)
}
func (s *SnapTestSuite) TestDetectsAlreadyInstalled(c *C) {
data := "name: afoo\nversion: 1"
yamlPath, err := makeInstalledMockSnap(s.tempdir, data)
c.Assert(err, IsNil)
c.Assert(makeSnapActive(yamlPath), IsNil)
yaml, err := parsePackageYamlData([]byte(data))
c.Assert(err, IsNil)
c.Check(yaml.checkForPackageInstalled("otherns"), Equals, ErrPackageNameAlreadyInstalled)
}
func (s *SnapTestSuite) TestIgnoresAlreadyInstalledSameNamespace(c *C) {
// XXX: should this be allowed? right now it is (=> you can re-sideload the same version of your apps)
// (remote snaps are stopped before clickInstall gets to run)
data := "name: afoo\nversion: 1"
yamlPath, err := makeInstalledMockSnap(s.tempdir, data)
c.Assert(err, IsNil)
c.Assert(makeSnapActive(yamlPath), IsNil)
yaml, err := parsePackageYamlData([]byte(data))
c.Assert(err, IsNil)
c.Check(yaml.checkForPackageInstalled(testNamespace), IsNil)
}
func (s *SnapTestSuite) TestIgnoresAlreadyInstalledFrameworks(c *C) {
data := "name: afoo\nversion: 1\ntype: framework"
yamlPath, err := makeInstalledMockSnap(s.tempdir, data)
c.Assert(err, IsNil)
c.Assert(makeSnapActive(yamlPath), IsNil)
yaml, err := parsePackageYamlData([]byte(data))
c.Assert(err, IsNil)
c.Check(yaml.checkForPackageInstalled("otherns"), IsNil)
}
func (s *SnapTestSuite) TestDetectsNameClash(c *C) {
data := []byte(`name: afoo
version: 1.0

View File

@@ -179,7 +179,7 @@ X-Snappy=yes
[Service]
ExecStart=/usr/bin/ubuntu-core-launcher {{.UdevAppName}} {{.AaProfile}} {{.FullPathStart}}
WorkingDirectory={{.AppPath}}
Environment="SNAPP_APP_PATH={{.AppPath}}" "SNAPP_APP_DATA_PATH=/var/lib{{.AppPath}}" "SNAPP_APP_USER_DATA_PATH=%h{{.AppPath}}" "SNAP_APP_PATH={{.AppPath}}" "SNAP_APP_DATA_PATH=/var/lib{{.AppPath}}" "SNAP_APP_USER_DATA_PATH=%h{{.AppPath}}" "SNAP_APP={{.AppTriple}}" "TMPDIR=/tmp/snaps/{{.AppName}}/{{.Version}}/tmp" "SNAP_APP_TMPDIR=/tmp/snaps/{{.AppName}}/{{.Version}}/tmp"
Environment="SNAPP_APP_PATH={{.AppPath}}" "SNAPP_APP_DATA_PATH=/var/lib{{.AppPath}}" "SNAPP_APP_USER_DATA_PATH=%h{{.AppPath}}" "SNAP_APP_PATH={{.AppPath}}" "SNAP_APP_DATA_PATH=/var/lib{{.AppPath}}" "SNAP_APP_USER_DATA_PATH=%h{{.AppPath}}" "SNAP_APP={{.AppTriple}}" "TMPDIR=/tmp/snaps/{{.UdevAppName}}/{{.Version}}/tmp" "SNAP_APP_TMPDIR=/tmp/snaps/{{.UdevAppName}}/{{.Version}}/tmp"
{{if .Stop}}ExecStop={{.FullPathStop}}{{end}}
{{if .PostStop}}ExecStopPost={{.FullPathPostStop}}{{end}}
{{if .StopTimeout}}TimeoutStopSec={{.StopTimeout.Seconds}}{{end}}

View File

@@ -150,11 +150,11 @@ Description=descr
X-Snappy=yes
[Service]
ExecStart=/usr/bin/ubuntu-core-launcher app%s aa-profile /apps/app/1.0/bin/start
WorkingDirectory=/apps/app/1.0/
Environment="SNAPP_APP_PATH=/apps/app/1.0/" "SNAPP_APP_DATA_PATH=/var/lib/apps/app/1.0/" "SNAPP_APP_USER_DATA_PATH=%%h/apps/app/1.0/" "SNAP_APP_PATH=/apps/app/1.0/" "SNAP_APP_DATA_PATH=/var/lib/apps/app/1.0/" "SNAP_APP_USER_DATA_PATH=%%h/apps/app/1.0/" "SNAP_APP=app_service_1.0" "TMPDIR=/tmp/snaps/app/1.0/tmp" "SNAP_APP_TMPDIR=/tmp/snaps/app/1.0/tmp"
ExecStop=/apps/app/1.0/bin/stop
ExecStopPost=/apps/app/1.0/bin/stop --post
ExecStart=/usr/bin/ubuntu-core-launcher app%s aa-profile /apps/app%[2]s/1.0/bin/start
WorkingDirectory=/apps/app%[2]s/1.0/
Environment="SNAPP_APP_PATH=/apps/app%[2]s/1.0/" "SNAPP_APP_DATA_PATH=/var/lib/apps/app%[2]s/1.0/" "SNAPP_APP_USER_DATA_PATH=%%h/apps/app%[2]s/1.0/" "SNAP_APP_PATH=/apps/app%[2]s/1.0/" "SNAP_APP_DATA_PATH=/var/lib/apps/app%[2]s/1.0/" "SNAP_APP_USER_DATA_PATH=%%h/apps/app%[2]s/1.0/" "SNAP_APP=app_service_1.0" "TMPDIR=/tmp/snaps/app%[2]s/1.0/tmp" "SNAP_APP_TMPDIR=/tmp/snaps/app%[2]s/1.0/tmp"
ExecStop=/apps/app%[2]s/1.0/bin/stop
ExecStopPost=/apps/app%[2]s/1.0/bin/stop --post
TimeoutStopSec=10
%s
@@ -175,7 +175,7 @@ func (s *SystemdTestSuite) TestGenAppServiceFile(c *C) {
ServiceName: "service",
Version: "1.0",
Description: "descr",
AppPath: "/apps/app/1.0/",
AppPath: "/apps/app.mvo/1.0/",
Start: "bin/start",
Stop: "bin/stop",
PostStop: "bin/stop --post",
@@ -214,7 +214,7 @@ func (s *SystemdTestSuite) TestGenServiceFileWithBusName(c *C) {
ServiceName: "service",
Version: "1.0",
Description: "descr",
AppPath: "/apps/app/1.0/",
AppPath: "/apps/app.mvo/1.0/",
Start: "bin/start",
Stop: "bin/stop",
PostStop: "bin/stop --post",