1
// Copyright 2012-2014 Canonical Ltd.
2
// Licensed under the AGPLv3, see LICENCE file for details.
10
jujuos "github.com/juju/utils/os"
13
// OSDependentEnvVars returns the OS-dependent environment variables that
14
// should be set for a hook context.
15
func OSDependentEnvVars(paths Paths) []string {
16
switch jujuos.HostOS() {
18
return windowsEnv(paths)
20
return ubuntuEnv(paths)
22
return centosEnv(paths)
27
func appendPath(paths Paths) []string {
29
"PATH=" + paths.GetToolsDir() + ":" + os.Getenv("PATH"),
33
func ubuntuEnv(paths Paths) []string {
34
path := appendPath(paths)
36
"APT_LISTCHANGES_FRONTEND=none",
37
"DEBIAN_FRONTEND=noninteractive",
39
env = append(env, path...)
43
func centosEnv(paths Paths) []string {
44
return appendPath(paths)
47
// windowsEnv adds windows specific environment variables. PSModulePath
48
// helps hooks use normal imports instead of dot sourcing modules
49
// its a convenience variable. The PATH variable delimiter is
50
// a semicolon instead of a colon
51
func windowsEnv(paths Paths) []string {
52
charmDir := paths.GetCharmDir()
53
charmModules := filepath.Join(charmDir, "lib", "Modules")
55
"Path=" + paths.GetToolsDir() + ";" + os.Getenv("Path"),
56
"PSModulePath=" + os.Getenv("PSModulePath") + ";" + charmModules,