Browse Source

Fix cross compile non cgo and linux systems
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)

Michael Crosby 11 years ago
parent
commit
7a8ea91392

+ 3 - 3
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

+ 1 - 1
daemon/execdriver/native/create.go

@@ -1,4 +1,4 @@
-// +build linux
+// +build linux,cgo
 
 package native
 

+ 1 - 1
daemon/execdriver/native/driver.go

@@ -1,4 +1,4 @@
-// +build linux
+// +build linux,cgo
 
 package native
 

+ 13 - 0
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")
+}

+ 1 - 1
daemon/execdriver/native/info.go

@@ -1,4 +1,4 @@
-// +build linux
+// +build linux,cgo
 
 package native
 

+ 13 - 0
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)
+}

+ 9 - 0
daemon/utils_nolinux.go

@@ -0,0 +1,9 @@
+// +build !linux
+
+package daemon
+
+func selinuxSetDisabled() {
+}
+
+func selinuxFreeLxcContexts(label string) {
+}