Skip to content

Commit

Permalink
many: rename dirs.SnapSnapsDir to SnapMountDir
Browse files Browse the repository at this point in the history
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
  • Loading branch information
zyga committed Aug 24, 2016
1 parent 4ce828f commit f538621
Show file tree
Hide file tree
Showing 17 changed files with 32 additions and 32 deletions.
4 changes: 2 additions & 2 deletions cmd/snap-exec/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func (s *snapExecSuite) TestSnapExecAppIntegration(c *C) {
// launch and verify its run the right way
err := snapExecApp("snapname.app", "42", "stop", []string{"arg1", "arg2"})
c.Assert(err, IsNil)
c.Check(execArgv0, Equals, fmt.Sprintf("%s/snapname/42/stop-app", dirs.SnapSnapsDir))
c.Check(execArgv0, Equals, fmt.Sprintf("%s/snapname/42/stop-app", dirs.SnapMountDir))
c.Check(execArgs, DeepEquals, []string{execArgv0, "arg1", "arg2"})
c.Check(execEnv, testutil.Contains, "LD_LIBRARY_PATH=/some/path\n")
}
Expand All @@ -167,7 +167,7 @@ func (s *snapExecSuite) TestSnapExecHookIntegration(c *C) {
// launch and verify it ran correctly
err := snapExecHook("snapname", "42", "apply-config")
c.Assert(err, IsNil)
c.Check(execArgv0, Equals, fmt.Sprintf("%s/snapname/42/meta/hooks/apply-config", dirs.SnapSnapsDir))
c.Check(execArgv0, Equals, fmt.Sprintf("%s/snapname/42/meta/hooks/apply-config", dirs.SnapMountDir))
c.Check(execArgs, DeepEquals, []string{execArgv0})
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/snap/cmd_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (s *SnapSuite) TestSnapRunSnapExecEnv(c *check.C) {
sort.Strings(env)
c.Check(env, check.DeepEquals, []string{
"PATH=${PATH}:/usr/lib/snapd",
fmt.Sprintf("SNAP=%s/snapname/42", dirs.SnapSnapsDir),
fmt.Sprintf("SNAP=%s/snapname/42", dirs.SnapMountDir),
fmt.Sprintf("SNAP_ARCH=%s", arch.UbuntuArchitecture()),
"SNAP_COMMON=/var/snap/snapname/common",
"SNAP_DATA=/var/snap/snapname/42",
Expand Down
2 changes: 1 addition & 1 deletion daemon/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,7 @@ func iconGet(st *state.State, name string) Response {
}

path := filepath.Clean(snapIcon(info))
if !strings.HasPrefix(path, dirs.SnapSnapsDir) {
if !strings.HasPrefix(path, dirs.SnapMountDir) {
// XXX: how could this happen?
return BadRequest("requested icon is not in snap path")
}
Expand Down
4 changes: 2 additions & 2 deletions daemon/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func (s *apiSuite) SetUpTest(c *check.C) {
dirs.SetRootDir(c.MkDir())
err := os.MkdirAll(filepath.Dir(dirs.SnapStateFile), 0755)
c.Assert(err, check.IsNil)
c.Assert(os.MkdirAll(dirs.SnapSnapsDir, 0755), check.IsNil)
c.Assert(os.MkdirAll(dirs.SnapMountDir, 0755), check.IsNil)

s.rsnaps = nil
s.suggestedCurrency = ""
Expand Down Expand Up @@ -246,7 +246,7 @@ type: gadget
gadget: {store: {id: %q}}
`, store)
snaptest.MockSnap(c, yamlText, &snap.SideInfo{Revision: snap.R(1)})
c.Assert(os.Symlink("1", filepath.Join(dirs.SnapSnapsDir, "test", "current")), check.IsNil)
c.Assert(os.Symlink("1", filepath.Join(dirs.SnapMountDir, "test", "current")), check.IsNil)
}

func (s *apiSuite) TestSnapInfoOneIntegration(c *check.C) {
Expand Down
6 changes: 3 additions & 3 deletions dirs/dirs.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
var (
GlobalRootDir string

SnapSnapsDir string
SnapMountDir string
SnapBlobDir string
SnapDataDir string
SnapDataHomeGlob string
Expand Down Expand Up @@ -81,7 +81,7 @@ func SetRootDir(rootdir string) {
}
GlobalRootDir = rootdir

SnapSnapsDir = filepath.Join(rootdir, "/snap")
SnapMountDir = filepath.Join(rootdir, "/snap")
SnapDataDir = filepath.Join(rootdir, "/var/snap")
SnapDataHomeGlob = filepath.Join(rootdir, "/home/*/snap/")
SnapAppArmorDir = filepath.Join(rootdir, snappyDir, "apparmor", "profiles")
Expand All @@ -106,7 +106,7 @@ func SetRootDir(rootdir string) {
// snapd.firstboot.service to match
SnapFirstBootStamp = filepath.Join(rootdir, snappyDir, "firstboot", "stamp")

SnapBinariesDir = filepath.Join(SnapSnapsDir, "bin")
SnapBinariesDir = filepath.Join(SnapMountDir, "bin")
SnapServicesDir = filepath.Join(rootdir, "/etc/systemd/system")
SnapBusPolicyDir = filepath.Join(rootdir, "/etc/dbus-1/system.d")

Expand Down
6 changes: 3 additions & 3 deletions integration-tests/testutils/refresh/refresh.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,12 @@ func copySnap(c *check.C, snap, targetDir string) {
// check for sideloaded snaps
// XXX: simplify this down to consider only the name (and not origin)
// in the directory once everything is moved to that
baseDir := filepath.Join(dirs.SnapSnapsDir, snap)
baseDir := filepath.Join(dirs.SnapMountDir, snap)
if _, err := os.Stat(baseDir); os.IsNotExist(err) {
snapName := strings.Split(snap, ".")[0]
baseDir = filepath.Join(dirs.SnapSnapsDir, snapName)
baseDir = filepath.Join(dirs.SnapMountDir, snapName)
if _, err := os.Stat(baseDir); os.IsNotExist(err) {
baseDir = filepath.Join(dirs.SnapSnapsDir, snapName+".sideload")
baseDir = filepath.Join(dirs.SnapMountDir, snapName+".sideload")
_, err = os.Stat(baseDir)
c.Assert(err, check.IsNil,
check.Commentf("%s not found from it's original source not sideloaded", snap))
Expand Down
2 changes: 1 addition & 1 deletion overlord/boot/firstboot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ snaps:
c.Assert(err, IsNil)

// and check the snap got correctly installed
c.Check(osutil.FileExists(filepath.Join(dirs.SnapSnapsDir, "foo", "128", "meta", "snap.yaml")), Equals, true)
c.Check(osutil.FileExists(filepath.Join(dirs.SnapMountDir, "foo", "128", "meta", "snap.yaml")), Equals, true)

// verify
r, err := os.Open(dirs.SnapStateFile)
Expand Down
2 changes: 1 addition & 1 deletion snap/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func MinimalPlaceInfo(name string, revision Revision) PlaceInfo {

// MountDir returns the base directory where it gets mounted of the snap with the given name and revision.
func MountDir(name string, revision Revision) string {
return filepath.Join(dirs.SnapSnapsDir, name, revision.String())
return filepath.Join(dirs.SnapMountDir, name, revision.String())
}

// SecurityTag returns the snap-specific security tag.
Expand Down
8 changes: 4 additions & 4 deletions snap/info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ apps:
info.Revision = snap.R(42)

c.Check(info.Apps["bar"].LauncherCommand(), Equals,
fmt.Sprintf("/usr/bin/ubuntu-core-launcher snap.foo.bar snap.foo.bar %s/foo/42/bar-bin -x", dirs.SnapSnapsDir))
fmt.Sprintf("/usr/bin/ubuntu-core-launcher snap.foo.bar snap.foo.bar %s/foo/42/bar-bin -x", dirs.SnapMountDir))
c.Check(info.Apps["foo"].LauncherCommand(), Equals,
fmt.Sprintf("/usr/bin/ubuntu-core-launcher snap.foo.foo snap.foo.foo %s/foo/42/foo-bin", dirs.SnapSnapsDir))
fmt.Sprintf("/usr/bin/ubuntu-core-launcher snap.foo.foo snap.foo.foo %s/foo/42/foo-bin", dirs.SnapMountDir))
}

const sampleYaml = `
Expand Down Expand Up @@ -471,9 +471,9 @@ func verifyExplicitHook(c *C, info *snap.Info, hookName string, plugNames []stri
func (s *infoSuite) TestDirAndFileMethods(c *C) {
dirs.SetRootDir("")
info := &snap.Info{SuggestedName: "name", SideInfo: snap.SideInfo{Revision: snap.R(1)}}
c.Check(info.MountDir(), Equals, fmt.Sprintf("%s/name/1", dirs.SnapSnapsDir))
c.Check(info.MountDir(), Equals, fmt.Sprintf("%s/name/1", dirs.SnapMountDir))
c.Check(info.MountFile(), Equals, "/var/lib/snapd/snaps/name_1.snap")
c.Check(info.HooksDir(), Equals, fmt.Sprintf("%s/name/1/meta/hooks", dirs.SnapSnapsDir))
c.Check(info.HooksDir(), Equals, fmt.Sprintf("%s/name/1/meta/hooks", dirs.SnapMountDir))
c.Check(info.DataDir(), Equals, "/var/snap/name/1")
c.Check(info.UserDataDir("/home/bob"), Equals, "/home/bob/snap/name/1")
c.Check(info.UserCommonDataDir("/home/bob"), Equals, "/home/bob/snap/name/common")
Expand Down
2 changes: 1 addition & 1 deletion snap/snapenv/snapenv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (ts *HTestSuite) TestBasic(c *C) {
sort.Strings(env)

c.Assert(env, DeepEquals, []string{
fmt.Sprintf("SNAP=%s/foo/17", dirs.SnapSnapsDir),
fmt.Sprintf("SNAP=%s/foo/17", dirs.SnapMountDir),
fmt.Sprintf("SNAP_ARCH=%s", arch.UbuntuArchitecture()),
"SNAP_COMMON=/var/snap/foo/common",
"SNAP_DATA=/var/snap/foo/17",
Expand Down
2 changes: 1 addition & 1 deletion snap/snaptest/snaptest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (s *snapTestSuite) TestMockSnap(c *C) {
// Data from SideInfo is used
c.Check(snapInfo.Revision, Equals, snap.R(42))
// The YAML is placed on disk
cont, err := ioutil.ReadFile(filepath.Join(dirs.SnapSnapsDir, "sample", "42", "meta", "snap.yaml"))
cont, err := ioutil.ReadFile(filepath.Join(dirs.SnapMountDir, "sample", "42", "meta", "snap.yaml"))
c.Assert(err, IsNil)

c.Check(string(cont), Equals, sampleYaml)
Expand Down
2 changes: 1 addition & 1 deletion store/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func (t *remoteRepoTestSuite) SetUpTest(c *C) {
t.store = New(nil, "", nil)
t.origDownloadFunc = download
dirs.SetRootDir(c.MkDir())
c.Assert(os.MkdirAll(dirs.SnapSnapsDir, 0755), IsNil)
c.Assert(os.MkdirAll(dirs.SnapMountDir, 0755), IsNil)

t.logbuf = bytes.NewBuffer(nil)
l, err := logger.NewConsoleLog(t.logbuf, logger.DefaultFlags)
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/fakestore/refresh/refresh.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ type info struct {
}

func copySnap(snapName, targetDir string) (*info, error) {
baseDir := filepath.Join(dirs.SnapSnapsDir, snapName)
baseDir := filepath.Join(dirs.SnapMountDir, snapName)
if _, err := os.Stat(baseDir); err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion wrappers/binaries_gen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (s *binariesWrapperGenSuite) TestSnappyGenerateSnapBinaryWrapper(c *C) {
Command: "bin/pastebinit",
}

expected := fmt.Sprintf(expectedWrapper, arch.UbuntuArchitecture(), dirs.SnapSnapsDir)
expected := fmt.Sprintf(expectedWrapper, arch.UbuntuArchitecture(), dirs.SnapMountDir)

generatedWrapper, err := wrappers.GenerateSnapBinaryWrapper(binary)
c.Assert(err, IsNil)
Expand Down
4 changes: 2 additions & 2 deletions wrappers/binaries_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ func (s *binariesTestSuite) TestAddSnapBinariesAndRemove(c *C) {
err := wrappers.AddSnapBinaries(info)
c.Assert(err, IsNil)

wrapper := fmt.Sprintf("%s/bin/hello-snap.hello", dirs.SnapSnapsDir)
wrapper := fmt.Sprintf("%s/bin/hello-snap.hello", dirs.SnapMountDir)

content, err := ioutil.ReadFile(wrapper)
c.Assert(err, IsNil)

needle := fmt.Sprintf(`
exec /usr/bin/ubuntu-core-launcher snap.hello-snap.hello snap.hello-snap.hello %s/hello-snap/11/bin/hello "$@"
`, dirs.SnapSnapsDir)
`, dirs.SnapMountDir)

c.Assert(string(content), Matches, "(?ms).*"+regexp.QuoteMeta(needle)+".*")

Expand Down
6 changes: 3 additions & 3 deletions wrappers/desktop_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ Icon=${SNAP}/meep
Name=foo
Icon=%s/foo/12/meep
# the empty line above is fine`, dirs.SnapSnapsDir))
# the empty line above is fine`, dirs.SnapMountDir))
}

func (s *sanitizeDesktopFileSuite) TestSanitizeFiltersExec(c *C) {
Expand Down Expand Up @@ -183,7 +183,7 @@ Exec=snap.app %U
e := wrappers.SanitizeDesktopFile(snap, "foo.desktop", desktopContent)
c.Assert(string(e), Equals, fmt.Sprintf(`[Desktop Entry]
Name=foo
Exec=env BAMF_DESKTOP_FILE_HINT=foo.desktop %s/bin/snap.app %%U`, dirs.SnapSnapsDir))
Exec=env BAMF_DESKTOP_FILE_HINT=foo.desktop %s/bin/snap.app %%U`, dirs.SnapMountDir))
}

// we do not support TryExec (even if its a valid line), this test ensures
Expand Down Expand Up @@ -254,7 +254,7 @@ apps:

newl, err := wrappers.RewriteExecLine(snap, "foo.desktop", "Exec=snap.app")
c.Assert(err, IsNil)
c.Assert(newl, Equals, fmt.Sprintf("Exec=env BAMF_DESKTOP_FILE_HINT=foo.desktop %s/bin/snap.app", dirs.SnapSnapsDir))
c.Assert(newl, Equals, fmt.Sprintf("Exec=env BAMF_DESKTOP_FILE_HINT=foo.desktop %s/bin/snap.app", dirs.SnapMountDir))
}

func (s *sanitizeDesktopFileSuite) TestTrimLang(c *C) {
Expand Down
8 changes: 4 additions & 4 deletions wrappers/services_gen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ WantedBy=multi-user.target
`

var (
expectedAppService = fmt.Sprintf(expectedServiceFmt, "After=snapd.frameworks.target\nRequires=snapd.frameworks.target", "Type=simple\n", arch.UbuntuArchitecture(), dirs.SnapSnapsDir)
expectedDbusService = fmt.Sprintf(expectedServiceFmt, "After=snapd.frameworks.target\nRequires=snapd.frameworks.target", "Type=dbus\nBusName=foo.bar.baz", arch.UbuntuArchitecture(), dirs.SnapSnapsDir)
expectedAppService = fmt.Sprintf(expectedServiceFmt, "After=snapd.frameworks.target\nRequires=snapd.frameworks.target", "Type=simple\n", arch.UbuntuArchitecture(), dirs.SnapMountDir)
expectedDbusService = fmt.Sprintf(expectedServiceFmt, "After=snapd.frameworks.target\nRequires=snapd.frameworks.target", "Type=dbus\nBusName=foo.bar.baz", arch.UbuntuArchitecture(), dirs.SnapMountDir)
)

var (
Expand All @@ -81,8 +81,8 @@ TimeoutStopSec=30
[Install]
WantedBy=multi-user.target
`
expectedSocketUsingWrapper = fmt.Sprintf(expectedServiceWrapperFmt, "After=snapd.frameworks.target snap.xkcd-webserver.xkcd-webserver.socket\nRequires=snapd.frameworks.target snap.xkcd-webserver.xkcd-webserver.socket", "Type=simple\n", arch.UbuntuArchitecture(), dirs.SnapSnapsDir)
expectedTypeForkingWrapper = fmt.Sprintf(expectedServiceWrapperFmt, "After=snapd.frameworks.target\nRequires=snapd.frameworks.target", "Type=forking\n", arch.UbuntuArchitecture(), dirs.SnapSnapsDir)
expectedSocketUsingWrapper = fmt.Sprintf(expectedServiceWrapperFmt, "After=snapd.frameworks.target snap.xkcd-webserver.xkcd-webserver.socket\nRequires=snapd.frameworks.target snap.xkcd-webserver.xkcd-webserver.socket", "Type=simple\n", arch.UbuntuArchitecture(), dirs.SnapMountDir)
expectedTypeForkingWrapper = fmt.Sprintf(expectedServiceWrapperFmt, "After=snapd.frameworks.target\nRequires=snapd.frameworks.target", "Type=forking\n", arch.UbuntuArchitecture(), dirs.SnapMountDir)
)

func (s *servicesWrapperGenSuite) TestGenerateSnapServiceFile(c *C) {
Expand Down

0 comments on commit f538621

Please sign in to comment.