Merge pull request #1428 from Rastusik/osx

Compatibility with OSX. The commit also contains instructions for set…
This commit is contained in:
Alain Jobart 2016-01-12 12:15:30 -08:00
Родитель 935c201ba6 8ba57d88d2
Коммит 6cef6d30a4
5 изменённых файлов: 106 добавлений и 25 удалений

Просмотреть файл

@ -14,6 +14,15 @@ function fail() {
exit 1
}
function zk_patch_mac() {
if [ `uname -s` == "Darwin" ]; then
cd zookeeper-$zk_ver && \
wget https://issues.apache.org/jira/secure/attachment/12673210/ZOOKEEPER-2049.noprefix.branch-3.4.patch && \
patch -p0 < ZOOKEEPER-2049.noprefix.branch-3.4.patch && \
cd ..
fi
}
[ -f bootstrap.sh ] || fail "bootstrap.sh must be run from its current directory"
[ "$USER" != "root" ] || fail "Vitess cannot run as root. Please bootstrap with a non-root user."
@ -37,6 +46,7 @@ else
(cd $VTROOT/dist && \
wget http://archive.apache.org/dist/zookeeper/zookeeper-$zk_ver/zookeeper-$zk_ver.tar.gz && \
tar -xzf zookeeper-$zk_ver.tar.gz && \
zk_patch_mac && \
mkdir -p $zk_dist/lib && \
cp zookeeper-$zk_ver/contrib/fatjar/zookeeper-$zk_ver-fatjar.jar $zk_dist/lib && \
(cd zookeeper-$zk_ver/src/c && \
@ -92,6 +102,7 @@ repos="github.com/golang/glog \
google.golang.org/grpc \
google.golang.org/cloud \
google.golang.org/cloud/storage \
golang.org/x/crypto/ssh/terminal \
"
# Packages for uploading code coverage to coveralls.io (used by Travis CI).
@ -188,5 +199,13 @@ fi
echo "creating git pre-commit hooks"
ln -sf $VTTOP/misc/git/pre-commit $VTTOP/.git/hooks/pre-commit
if [ `uname -s` == "Darwin" ]; then
echo "Setting up Apple System Integrity Protection (https://support.apple.com/en-us/HT204899)"
echo "A sudoer password is required in this step:"
sudo install_name_tool -change libgrpc.dylib $VTROOT/dist/grpc/lib/libgrpc.dylib $VTROOT/dist/grpc/lib/python2.7/site-packages/grpc/_adapter/_c.so
sudo install_name_tool -change libgpr.dylib $VTROOT/dist/grpc/lib/libgpr.dylib $VTROOT/dist/grpc/lib/python2.7/site-packages/grpc/_adapter/_c.so
sudo install_name_tool -change libgpr.dylib $VTROOT/dist/grpc/lib/libgpr.dylib $VTROOT/dist/grpc/lib/libgrpc.dylib
fi
echo
echo "bootstrap finished - run 'source dev.env' in your shell before building."

Просмотреть файл

@ -67,6 +67,9 @@ Vitess without Docker.
### Install Dependencies
We currently test Vitess regularly on Ubuntu 14.04 (Trusty) and Debian 8 (Jessie).
OS X 10.11 (El Capitan) should work as well, the installation instructions are below.
#### Ubuntu and Debian
In addition, Vitess requires the software and libraries listed below.
@ -122,6 +125,80 @@ In addition, Vitess requires the software and libraries listed below.
``` sh
$ sudo apt-get install openjdk-7-jre
```
#### OS X
1. [Install Homebrew](http://brew.sh/). If your /usr/local directory is not empty and you never used Homebrew before,
it will be
[mandatory](https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/El_Capitan_and_Homebrew.md)
to run the following command:
``` sh
sudo chown -R $(whoami):admin /usr/local
```
2. On OS X, MySQL 5.6 has to be used, MariaDB doesn't work for some reason yet. It should be installed from Homebrew
(install steps are below).
3. If Xcode is installed (with Console tools, which should be bundled automatically since the 7.1 version), all
the dev dependencies should be satisfied in this step. If no Xcode is present, it is necessery to install pkg-config.
``` sh
brew install pkg-config
```
4. ZooKeeper is used as lock service.
5. Run the following commands:
``` sh
brew install go automake libtool memcached python mercurial git bison curl wget homebrew/versions/mysql56
pip install --upgrade pip setuptools
pip install virtualenv
pip install MySQL-python
```
6. Install Java runtime from this URL: https://support.apple.com/kb/dl1572?locale=en_US
Apple only supports Java 6. If you need to install a newer version, this link might be helpful:
[http://osxdaily.com/2015/10/17/how-to-install-java-in-os-x-el-capitan/](http://osxdaily.com/2015/10/17/how-to-install-java-in-os-x-el-capitan/)
7. The Vitess bootstrap script makes some checks for the go runtime, so it is recommended to have the following
commands in your ~/.profile or ~/.bashrc or ~/.zshrc:
``` sh
export PATH=/usr/local/opt/go/libexec/bin:$PATH
export GOROOT=/usr/local/opt/go/libexec
```
8. There is a problem with installing the enum34 Python package using pip, so the following file has to be edited:
```
/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/distutils.cfg
```
and this line:
```
prefix=/usr/local
```
has to be commented out:
```
# prefix=/usr/local
```
After running the ./bootstrap.sh script from the next step, you can revert the change.
9. For the Vitess hostname resolving functions to work correctly, a new entry has to be added into the /etc/hosts file
with the current LAN IP address of the computer (preferably IPv4) and the current hostname, which you get by
typing the 'hostname' command in the terminal.
It is also a good idea to put the following line to [force the Go DNS resolver](https://golang.org/doc/go1.5#net)
in your ~/.profile or ~/.bashrc or ~/.zshrc:
```
export GODEBUG=netdns=go
```
### Build Vitess
@ -140,8 +217,8 @@ In addition, Vitess requires the software and libraries listed below.
``` sh
export MYSQL_FLAVOR=MariaDB
or
export MYSQL_FLAVOR=MySQL56
# or (mandatory for OS X)
# export MYSQL_FLAVOR=MySQL56
```
1. If your selected database installed in a location other than `/usr/bin`,
@ -151,6 +228,9 @@ In addition, Vitess requires the software and libraries listed below.
``` sh
export VT_MYSQL_ROOT=/usr/local/mysql
# on OS X, this is the correct value:
# export VT_MYSQL_ROOT=/usr/local/opt/mysql56
```
Note that the command indicates that the `mysql` executable should

Просмотреть файл

@ -17,9 +17,9 @@ import (
log "github.com/golang/glog"
"github.com/youtube/vitess/go/exit"
"github.com/youtube/vitess/go/terminal"
"github.com/youtube/vitess/go/vt/logutil"
"github.com/youtube/vitess/go/zk"
"golang.org/x/crypto/ssh/terminal"
"launchpad.net/gozk/zookeeper"
)
@ -578,7 +578,7 @@ func cmdCat(subFlags *flag.FlagSet, args []string) error {
fmt.Printf("%v:\n", zkPath)
}
fmt.Print(data)
if len(data) > 0 && data[len(data)-1] != '\n' && (terminal.IsTerminal(os.Stdout.Fd()) || *longListing) {
if len(data) > 0 && data[len(data)-1] != '\n' && (terminal.IsTerminal(int(os.Stdout.Fd())) || *longListing) {
fmt.Print("\n")
}
}

Просмотреть файл

@ -1,18 +0,0 @@
// Copyright 2012, Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package terminal detects whether a file descriptor is a terminal.
package terminal
import (
"syscall"
"unsafe"
)
// IsTerminal returns true if the given file descriptor is a terminal.
func IsTerminal(fd uintptr) bool {
var termios syscall.Termios
_, _, err := syscall.Syscall6(syscall.SYS_IOCTL, fd, syscall.TCGETS, uintptr(unsafe.Pointer(&termios)), 0, 0, 0)
return err == 0
}

Просмотреть файл

@ -11,9 +11,9 @@ if [ "$protobuf_dist" != "" ]; then
cd $protobuf_dist
fi
wget https://github.com/google/protobuf/archive/v3.0.0-beta-1.tar.gz
tar -xvzf v3.0.0-beta-1.tar.gz
cd protobuf-3.0.0-beta-1
wget https://github.com/google/protobuf/archive/v3.0.0-beta-2.tar.gz
tar -xvzf v3.0.0-beta-2.tar.gz
cd protobuf-3.0.0-beta-2
./autogen.sh
if [ "$protobuf_dist" != "" ]; then
./configure --prefix=$protobuf_dist