Merge pull request #13542 from kvasdopil/freebsd-work

Make docker build on FreeBSD
This commit is contained in:
Jessie Frazelle 2015-07-29 15:15:37 -07:00
commit 698b089d9e
8 changed files with 79 additions and 4 deletions

View file

@ -1,4 +1,4 @@
// +build linux // +build linux freebsd
package directory package directory

View file

@ -0,0 +1,18 @@
package operatingsystem
import (
"errors"
)
// GetOperatingSystem gets the name of the current operating system.
func GetOperatingSystem() (string, error) {
// TODO: Implement OS detection
return "", errors.New("Cannot detect OS version")
}
// IsContainerized returns true if we are running inside a container.
// No-op on FreeBSD, always returns false.
func IsContainerized() (bool, error) {
// TODO: Implement jail detection
return false, errors.New("Cannot detect if we are in container")
}

23
reexec/command_freebsd.go Normal file
View file

@ -0,0 +1,23 @@
// +build freebsd
package reexec
import (
"os/exec"
)
// Self returns the path to the current process's binary.
// Uses os.Args[0].
func Self() string {
return naiveSelf()
}
// Command returns *exec.Cmd which have Path as current binary.
// For example if current binary is "docker" at "/usr/bin/", then cmd.Path will
// be set to "/usr/bin/docker".
func Command(args ...string) *exec.Cmd {
return &exec.Cmd{
Path: Self(),
Args: args,
}
}

View file

@ -1,4 +1,4 @@
// +build !linux,!windows // +build !linux,!windows,!freebsd
package reexec package reexec

View file

@ -1,4 +1,4 @@
// +build linux // +build linux freebsd
package sockets package sockets

View file

@ -0,0 +1,7 @@
package sysinfo
// TODO FreeBSD
func New(quiet bool) *SysInfo {
sysInfo := &SysInfo{}
return sysInfo
}

27
system/stat_freebsd.go Normal file
View file

@ -0,0 +1,27 @@
package system
import (
"syscall"
)
// fromStatT converts a syscall.Stat_t type to a system.Stat_t type
func fromStatT(s *syscall.Stat_t) (*Stat_t, error) {
return &Stat_t{size: s.Size,
mode: uint32(s.Mode),
uid: s.Uid,
gid: s.Gid,
rdev: uint64(s.Rdev),
mtim: s.Mtimespec}, nil
}
// Stat takes a path to a file and returns
// a system.Stat_t type pertaining to that file.
//
// Throws an error if the file does not exist
func Stat(path string) (*Stat_t, error) {
s := &syscall.Stat_t{}
if err := syscall.Stat(path, s); err != nil {
return nil, err
}
return fromStatT(s)
}

View file

@ -1,4 +1,4 @@
// +build !linux,!windows // +build !linux,!windows,!freebsd
package system package system