diff --git a/Dockerfile b/Dockerfile index 9929a10f3c..7fad3d56a1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -68,7 +68,7 @@ ENV GOPATH /go:/go/src/github.com/dotcloud/docker/vendor RUN cd /usr/local/go/src && ./make.bash --no-clean 2>&1 # Compile Go for cross compilation -ENV DOCKER_CROSSPLATFORMS linux/386 linux/arm darwin/amd64 darwin/386 +ENV DOCKER_CROSSPLATFORMS linux/386 linux/arm darwin/amd64 darwin/386 freebsd/amd64 freebsd/386 freebsd/arm # (set an explicit GOARM of 5 for maximum compatibility) ENV GOARM 5 RUN cd /usr/local/go/src && bash -xc 'for platform in $DOCKER_CROSSPLATFORMS; do GOOS=${platform%/*} GOARCH=${platform##*/} ./make.bash --no-clean 2>&1; done' diff --git a/archive/stat_unsupported.go b/archive/stat_unsupported.go new file mode 100644 index 0000000000..004fa0f0a4 --- /dev/null +++ b/archive/stat_unsupported.go @@ -0,0 +1,21 @@ +// +build !linux !amd64 + +package archive + +import "syscall" + +func getLastAccess(stat *syscall.Stat_t) syscall.Timespec { + return syscall.Timespec{} +} + +func getLastModification(stat *syscall.Stat_t) syscall.Timespec { + return syscall.Timespec{} +} + +func LUtimesNano(path string, ts []syscall.Timespec) error { + return ErrNotImplemented +} + +func UtimesNano(path string, ts []syscall.Timespec) error { + return ErrNotImplemented +} diff --git a/hack/vendor.sh b/hack/vendor.sh index 184cb750a5..ac996dde12 100755 --- a/hack/vendor.sh +++ b/hack/vendor.sh @@ -39,7 +39,7 @@ clone() { echo done } -clone git github.com/kr/pty 3b1f6487b +clone git github.com/kr/pty 98c7b80083 clone git github.com/gorilla/context 708054d61e5 diff --git a/pkg/term/termios_freebsd.go b/pkg/term/termios_freebsd.go new file mode 100644 index 0000000000..9acf9dfe15 --- /dev/null +++ b/pkg/term/termios_freebsd.go @@ -0,0 +1,67 @@ +package term + +import ( + "syscall" + "unsafe" +) + +const ( + getTermios = syscall.TIOCGETA + setTermios = syscall.TIOCSETA + + IGNBRK = syscall.IGNBRK + PARMRK = syscall.PARMRK + INLCR = syscall.INLCR + IGNCR = syscall.IGNCR + ECHONL = syscall.ECHONL + CSIZE = syscall.CSIZE + ICRNL = syscall.ICRNL + ISTRIP = syscall.ISTRIP + PARENB = syscall.PARENB + ECHO = syscall.ECHO + ICANON = syscall.ICANON + ISIG = syscall.ISIG + IXON = syscall.IXON + BRKINT = syscall.BRKINT + INPCK = syscall.INPCK + OPOST = syscall.OPOST + CS8 = syscall.CS8 + IEXTEN = syscall.IEXTEN +) + +type Termios struct { + Iflag uint32 + Oflag uint32 + Cflag uint32 + Lflag uint32 + Cc [20]byte + Ispeed uint32 + Ospeed uint32 +} + +// MakeRaw put the terminal connected to the given file descriptor into raw +// mode and returns the previous state of the terminal so that it can be +// restored. +func MakeRaw(fd uintptr) (*State, error) { + var oldState State + if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(getTermios), uintptr(unsafe.Pointer(&oldState.termios))); err != 0 { + return nil, err + } + // C.makeraw() + // return &oldState, nil + + newState := oldState.termios + newState.Iflag &^= (IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON) + newState.Oflag &^= OPOST + newState.Lflag &^= (ECHO | ECHONL | ICANON | ISIG | IEXTEN) + newState.Cflag &^= (CSIZE | PARENB) + newState.Cflag |= CS8 + newState.Cc[syscall.VMIN] = 1 + newState.Cc[syscall.VTIME] = 0 + + if _, _, err := syscall.Syscall(syscall.SYS_IOCTL, fd, uintptr(setTermios), uintptr(unsafe.Pointer(&newState))); err != 0 { + return nil, err + } + + return &oldState, nil +} diff --git a/utils/signal_freebsd.go b/utils/signal_freebsd.go new file mode 100644 index 0000000000..65a700e894 --- /dev/null +++ b/utils/signal_freebsd.go @@ -0,0 +1,42 @@ +package utils + +import ( + "os" + "os/signal" + "syscall" +) + +func CatchAll(sigc chan os.Signal) { + signal.Notify(sigc, + syscall.SIGABRT, + syscall.SIGALRM, + syscall.SIGBUS, + syscall.SIGCHLD, + syscall.SIGCONT, + syscall.SIGFPE, + syscall.SIGHUP, + syscall.SIGILL, + syscall.SIGINT, + syscall.SIGIO, + syscall.SIGIOT, + syscall.SIGKILL, + syscall.SIGPIPE, + syscall.SIGPROF, + syscall.SIGQUIT, + syscall.SIGSEGV, + syscall.SIGSTOP, + syscall.SIGSYS, + syscall.SIGTERM, + syscall.SIGTRAP, + syscall.SIGTSTP, + syscall.SIGTTIN, + syscall.SIGTTOU, + syscall.SIGURG, + syscall.SIGUSR1, + syscall.SIGUSR2, + syscall.SIGVTALRM, + syscall.SIGWINCH, + syscall.SIGXCPU, + syscall.SIGXFSZ, + ) +} diff --git a/vendor/src/github.com/kr/pty/doc.go b/vendor/src/github.com/kr/pty/doc.go index 491c060b28..190cfbea92 100644 --- a/vendor/src/github.com/kr/pty/doc.go +++ b/vendor/src/github.com/kr/pty/doc.go @@ -2,9 +2,14 @@ package pty import ( + "errors" "os" ) +// ErrUnsupported is returned if a function is not +// available on the current platform. +var ErrUnsupported = errors.New("unsupported") + // Opens a pty and its corresponding tty. func Open() (pty, tty *os.File, err error) { return open() diff --git a/vendor/src/github.com/kr/pty/pty_freebsd.go b/vendor/src/github.com/kr/pty/pty_freebsd.go new file mode 100644 index 0000000000..13b64d722e --- /dev/null +++ b/vendor/src/github.com/kr/pty/pty_freebsd.go @@ -0,0 +1,53 @@ +package pty + +import ( + "os" + "strconv" + "syscall" + "unsafe" +) + +const ( + sys_TIOCGPTN = 0x4004740F + sys_TIOCSPTLCK = 0x40045431 +) + +func open() (pty, tty *os.File, err error) { + p, err := os.OpenFile("/dev/ptmx", os.O_RDWR, 0) + if err != nil { + return nil, nil, err + } + + sname, err := ptsname(p) + if err != nil { + return nil, nil, err + } + + t, err := os.OpenFile(sname, os.O_RDWR|syscall.O_NOCTTY, 0) + if err != nil { + return nil, nil, err + } + return p, t, nil +} + +func ptsname(f *os.File) (string, error) { + var n int + err := ioctl(f.Fd(), sys_TIOCGPTN, &n) + if err != nil { + return "", err + } + return "/dev/pts/" + strconv.Itoa(n), nil +} + +func ioctl(fd uintptr, cmd uintptr, data *int) error { + _, _, e := syscall.Syscall( + syscall.SYS_IOCTL, + fd, + cmd, + uintptr(unsafe.Pointer(data)), + ) + if e != 0 { + return syscall.ENOTTY + } + return nil +} diff --git a/vendor/src/github.com/kr/pty/pty_unsupported.go b/vendor/src/github.com/kr/pty/pty_unsupported.go new file mode 100644 index 0000000000..d4958b3583 --- /dev/null +++ b/vendor/src/github.com/kr/pty/pty_unsupported.go @@ -0,0 +1,27 @@ +// +build !linux,!darwin,!freebsd + +package pty + +import ( + "os" +) + +func open() (pty, tty *os.File, err error) { + return nil, nil, ErrUnsupported +} + +func ptsname(f *os.File) (string, error) { + return "", ErrUnsupported +} + +func grantpt(f *os.File) error { + return ErrUnsupported +} + +func unlockpt(f *os.File) error { + return ErrUnsupported +} + +func ioctl(fd, cmd, ptr uintptr) error { + return ErrUnsupported +}