From f48be61b0ab68d07eb3c03241d796f1fff27983b Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Wed, 16 Jul 2014 16:39:15 -0700 Subject: [PATCH] Fix cross compile non cgo and linux systems Docker-DCO-1.1-Signed-off-by: Michael Crosby (github: crosbymichael) Upstream-commit: 7a8ea91392e0cc97caf2a6edc3b262b33a5b446d Component: engine --- components/engine/daemon/daemon.go | 6 +++--- .../engine/daemon/execdriver/native/create.go | 2 +- .../engine/daemon/execdriver/native/driver.go | 2 +- .../execdriver/native/driver_unsupported_nocgo.go | 13 +++++++++++++ components/engine/daemon/execdriver/native/info.go | 2 +- components/engine/daemon/utils_linux.go | 13 +++++++++++++ components/engine/daemon/utils_nolinux.go | 9 +++++++++ 7 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 components/engine/daemon/execdriver/native/driver_unsupported_nocgo.go create mode 100644 components/engine/daemon/utils_linux.go create mode 100644 components/engine/daemon/utils_nolinux.go diff --git a/components/engine/daemon/daemon.go b/components/engine/daemon/daemon.go index c45b8b9d32..d3f73f413c 100644 --- a/components/engine/daemon/daemon.go +++ b/components/engine/daemon/daemon.go @@ -13,7 +13,6 @@ import ( "time" "github.com/docker/libcontainer/label" - "github.com/docker/libcontainer/selinux" "github.com/dotcloud/docker/archive" "github.com/dotcloud/docker/daemon/execdriver" "github.com/dotcloud/docker/daemon/execdriver/execdrivers" @@ -300,7 +299,8 @@ func (daemon *Daemon) Destroy(container *Container) error { if err := os.RemoveAll(container.root); err != nil { return fmt.Errorf("Unable to remove filesystem for %v: %v", container.ID, err) } - selinux.FreeLxcContexts(container.ProcessLabel) + + selinuxFreeLxcContexts(container.ProcessLabel) return nil } @@ -761,7 +761,7 @@ func NewDaemon(config *daemonconfig.Config, eng *engine.Engine) (*Daemon, error) func NewDaemonFromDirectory(config *daemonconfig.Config, eng *engine.Engine) (*Daemon, error) { if !config.EnableSelinuxSupport { - selinux.SetDisabled() + selinuxSetDisabled() } // Create the root directory if it doesn't exists diff --git a/components/engine/daemon/execdriver/native/create.go b/components/engine/daemon/execdriver/native/create.go index a96270d8b3..280ad70a6e 100644 --- a/components/engine/daemon/execdriver/native/create.go +++ b/components/engine/daemon/execdriver/native/create.go @@ -1,4 +1,4 @@ -// +build linux +// +build linux,cgo package native diff --git a/components/engine/daemon/execdriver/native/driver.go b/components/engine/daemon/execdriver/native/driver.go index 711f29429a..37c21d6f94 100644 --- a/components/engine/daemon/execdriver/native/driver.go +++ b/components/engine/daemon/execdriver/native/driver.go @@ -1,4 +1,4 @@ -// +build linux +// +build linux,cgo package native diff --git a/components/engine/daemon/execdriver/native/driver_unsupported_nocgo.go b/components/engine/daemon/execdriver/native/driver_unsupported_nocgo.go new file mode 100644 index 0000000000..9979099386 --- /dev/null +++ b/components/engine/daemon/execdriver/native/driver_unsupported_nocgo.go @@ -0,0 +1,13 @@ +// +build linux,!cgo + +package native + +import ( + "fmt" + + "github.com/dotcloud/docker/daemon/execdriver" +) + +func NewDriver(root, initPath string) (execdriver.Driver, error) { + return nil, fmt.Errorf("native driver not supported on non-linux") +} diff --git a/components/engine/daemon/execdriver/native/info.go b/components/engine/daemon/execdriver/native/info.go index a27d5640a4..601b97e810 100644 --- a/components/engine/daemon/execdriver/native/info.go +++ b/components/engine/daemon/execdriver/native/info.go @@ -1,4 +1,4 @@ -// +build linux +// +build linux,cgo package native diff --git a/components/engine/daemon/utils_linux.go b/components/engine/daemon/utils_linux.go new file mode 100644 index 0000000000..bff2a787b1 --- /dev/null +++ b/components/engine/daemon/utils_linux.go @@ -0,0 +1,13 @@ +// +build linux + +package daemon + +import "github.com/docker/libcontainer/selinux" + +func selinuxSetDisabled() { + selinux.SetDisabled() +} + +func selinuxFreeLxcContexts(label string) { + selinux.FreeLxcContexts(label) +} diff --git a/components/engine/daemon/utils_nolinux.go b/components/engine/daemon/utils_nolinux.go new file mode 100644 index 0000000000..399376dbd4 --- /dev/null +++ b/components/engine/daemon/utils_nolinux.go @@ -0,0 +1,9 @@ +// +build !linux + +package daemon + +func selinuxSetDisabled() { +} + +func selinuxFreeLxcContexts(label string) { +}