Enable build on unsupported platforms

Should compile now without errors but changes needed to be added for each system so it actually works.
main_unsupported.go is a new file with all the unsupported commands
Fixes #9

Signed-off-by: Marianna <mtesselh@gmail.com>
This commit is contained in:
Marianna
2015-06-29 16:49:13 -07:00
parent 85e264d0b9
commit 5aa82c950d
10 changed files with 72 additions and 33 deletions
+33
View File
@@ -1,14 +1,29 @@
// +build linux
package main
import (
"fmt"
"os"
"runtime"
"github.com/Sirupsen/logrus"
"github.com/codegangsta/cli"
"github.com/opencontainers/runc/libcontainer"
)
func init() {
if len(os.Args) > 1 && os.Args[1] == "init" {
runtime.GOMAXPROCS(1)
runtime.LockOSThread()
factory, _ := libcontainer.New("")
if err := factory.StartInitialization(); err != nil {
fatal(err)
}
panic("--this line should never been executed, congratulations--")
}
}
func execContainer(context *cli.Context, spec *Spec) (int, error) {
config, err := createLibcontainerConfig(spec)
if err != nil {
@@ -48,6 +63,24 @@ func execContainer(context *cli.Context, spec *Spec) (int, error) {
return handler.forward(process)
}
// default action is to execute a container
func runAction(context *cli.Context) {
spec, err := loadSpec(context.Args().First())
if err != nil {
fatal(err)
}
if os.Geteuid() != 0 {
logrus.Fatal("runc should be run as root")
}
status, err := execContainer(context, spec)
if err != nil {
logrus.Fatalf("Container start failed: %v", err)
}
// exit with the container's exit status so any external supervisor is
// notified of the exit with the correct exit status.
os.Exit(status)
}
func destroy(container libcontainer.Container) {
status, err := container.Status()
if err != nil {