diff --git a/devenv/setupUbuntuOnPPC64le.sh b/devenv/setupUbuntuOnPPC64le.sh new file mode 100755 index 00000000000..4745c5a0f69 --- /dev/null +++ b/devenv/setupUbuntuOnPPC64le.sh @@ -0,0 +1,89 @@ +#!/bin/bash + +# Development on Power (ppc64le) systems is done outside of vagrant, on the +# native OS. This script helps setup the dev env on ppc64le Ubuntu. +# +# See https://github.com/hyperledger/fabric/blob/master/docs/dev-setup/install.md#building-outside-of-vagrant- +# +# NOTE: This script assumes that +# - OS specific apt-sources / repositories are already set appropriately. +# - Host's GOPATH environment variable is set. +# +# To get started on a fresh Ubuntu install: +# mkdir -p $GOPATH/src/github.com/hyperledger +# cd $GOPATH/src/github.com/hyperledger +# git clone http://gerrit.hyperledger.org/r/fabric +# sudo ./fabric/devenv/setupUbuntuOnPPC64el.sh +# cd $GOPATH/src/github.com/hyperledger/fabric +# make dist-clean all + +if [ xroot != x$(whoami) ] +then + echo "You must run as root (Hint: Try prefix 'sudo' while executing the script)" + exit +fi + +if [ ! -d "$GOPATH/src/github.com/hyperledger/fabric" ] +then + echo "Ensure fabric code is under $GOPATH/src/github.com/hyperledger/fabric" + exit +fi + +##################################### +# Install pre-requisite OS packages # +##################################### +apt-get update +apt-get -y install software-properties-common curl git sudo wget + +##################################### +# Install and setup Docker services # +##################################### +# Along with docker.io, aufs-tools also needs to be installed as 'auplink' which is part of aufs-tools package gets invoked during behave tests. +apt-get -y install docker.io aufs-tools + +# Set DOCKER_OPTS and restart Docker daemon. +sed -i '/#DOCKER_OPTS=/a DOCKER_OPTS="-H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock"' /etc/default/docker +systemctl restart docker + +#################################### +# Install Go and set env variable # +#################################### +# Golang binaries for ppc64le are publicly available from Unicamp and is recommended as it includes certain platform specific tuning/optimization. +# Alternativley package part of Ubuntu disto repo can also be used. +wget ftp://ftp.unicamp.br/pub/linuxpatch/toolchain/at/ubuntu/dists/trusty/at9.0/binary-ppc64el/advance-toolchain-at9.0-golang_9.0-3_ppc64el.deb +dpkg -i advance-toolchain-at9.0-golang_9.0-3_ppc64el.deb +rm -f advance-toolchain-at9.0-golang_9.0-3_ppc64el.deb + +# Create links under /usr/bin using update-alternatives +update-alternatives --install /usr/bin/go go /usr/local/go/bin/go 9 +update-alternatives --install /usr/bin/gofmt gofmt /usr/local/go/bin/gofmt 9 + +# Set the GOROOT env variable +export GOROOT="/usr/local/go" + +#################################### +# Build and install RocksDB # +#################################### + +apt-get -y install libsnappy-dev zlib1g-dev libbz2-dev "build-essential" + +cd /tmp +git clone https://github.com/facebook/rocksdb.git +cd rocksdb +git checkout tags/v4.1 +echo There were some bugs in 4.1. This was fixed in dev stream and newer releases like 4.5.1. +sed -ibak 's/ifneq ($(MACHINE),ppc64)/ifeq (,$(findstring ppc64,$(MACHINE)))/g' Makefile +PORTABLE=1 make shared_lib +INSTALL_PATH=/usr/local make install-shared +ldconfig +cd - ; rm -rf /tmp/rocksdb + +################################################ +# Install PIP tools, behave and docker-compose # +################################################ + +apt-get -y install python-pip +pip install --upgrade pip +pip install behave nose docker-compose + +pip install -I flask==0.10.1 python-dateutil==2.2 pytz==2014.3 pyyaml==3.10 couchdb==1.0 flask-cors==2.0.1 requests==2.4.3 grpcio==0.13.1 diff --git a/docs/dev-setup/build.md b/docs/dev-setup/build.md index 6b1cea40903..642eaf79ec2 100644 --- a/docs/dev-setup/build.md +++ b/docs/dev-setup/build.md @@ -158,6 +158,21 @@ cd $GOPATH/src/github.com/hyperledger/fabric make peer unit-test behave ``` +### Building on Power Platform + +Development and build on Power (ppc64le) systems is done outside of vagrant as outlined [here](#building-outside-of-vagrant-). For ease of setting up the dev environment on Ubuntu, invoke [this script](https://github.com/hyperledger/fabric/tree/master/devenv/setupUbuntuOnPPC64le.sh) as root. This script has been validated on Ubuntu 16.04 and assumes certain things (like, development system has OS repositories in place, firewall setting etc) and in general can be improvised further. + +To get started on Power server installed with Ubuntu, first ensure you have properly setup your Host's [GOPATH environment variable](https://github.com/golang/go/wiki/GOPATH). Then, execute the following commands to build the fabric code: + +``` +mkdir -p $GOPATH/src/github.com/hyperledger +cd $GOPATH/src/github.com/hyperledger +git clone http://gerrit.hyperledger.org/r/fabric +sudo ./fabric/devenv/setupUbuntuOnPPC64le.sh +cd $GOPATH/src/github.com/hyperledger/fabric +make dist-clean all +``` + ### Building natively on OSX First, install Docker, as described [here](https://docs.docker.com/engine/installation/mac/). The database by default writes to /var/hyperledger. You can override this in the `core.yaml` configuration file, under `peer.fileSystemPath`. diff --git a/images/base/Makefile b/images/base/Makefile index 740274cd045..be148e69668 100644 --- a/images/base/Makefile +++ b/images/base/Makefile @@ -6,6 +6,7 @@ VAGRANTIMAGE=packer_virtualbox-iso_virtualbox.box DOCKER_BASE_x86_64=ubuntu:trusty DOCKER_BASE_s390x=s390x/ubuntu:xenial +DOCKER_BASE_ppc64le=ppc64le/ubuntu:xenial DOCKER_BASE=$(DOCKER_BASE_$(ARCH)) diff --git a/images/base/scripts/common/setup.sh b/images/base/scripts/common/setup.sh index 401585cfb45..6617ef8715e 100755 --- a/images/base/scripts/common/setup.sh +++ b/images/base/scripts/common/setup.sh @@ -16,21 +16,33 @@ apt-get dist-upgrade -qqy # install git apt-get install --yes git +MACHINE=`uname -m` +if [ x$MACHINE = xppc64le ] +then + # install sudo + apt-get install --yes sudo +fi + # Set Go environment variables needed by other scripts export GOPATH="/opt/gopath" #install golang #apt-get install --yes golang mkdir -p $GOPATH -MACHINE=`uname -m` if [ x$MACHINE = xs390x ] then apt-get install --yes golang export GOROOT="/usr/lib/go-1.6" -elif [ x$MACHINE = xppc64 ] +elif [ x$MACHINE = xppc64le ] then - echo "TODO: Add PPC support" - exit + wget ftp://ftp.unicamp.br/pub/linuxpatch/toolchain/at/ubuntu/dists/trusty/at9.0/binary-ppc64el/advance-toolchain-at9.0-golang_9.0-3_ppc64el.deb + dpkg -i advance-toolchain-at9.0-golang_9.0-3_ppc64el.deb + rm advance-toolchain-at9.0-golang_9.0-3_ppc64el.deb + + update-alternatives --install /usr/bin/go go /usr/local/go/bin/go 9 + update-alternatives --install /usr/bin/gofmt gofmt /usr/local/go/bin/gofmt 9 + + export GOROOT="/usr/local/go" elif [ x$MACHINE = xx86_64 ] then export GOROOT="/opt/go" @@ -45,6 +57,9 @@ then mv go $GOROOT chmod 775 $GOROOT rm go$GO_VER.linux-${ARCH}.tar.gz +else + echo "TODO: Add $MACHINE support" + exit fi PATH=$GOROOT/bin:$GOPATH/bin:$PATH @@ -59,6 +74,9 @@ EOF # Install NodeJS if [ x$MACHINE = xs390x ] +then + apt-get install --yes nodejs +elif [ x$MACHINE = xppc64le ] then apt-get install --yes nodejs else @@ -120,9 +138,14 @@ cd rocksdb git checkout tags/v4.1 if [ x$MACHINE = xs390x ] then - echo There were some bugs in 4.1 for x/p, dev stream has the fix, living dangereously, fixing in place + echo There were some bugs in 4.1 for z/p, dev stream has the fix, living dangereously, fixing in place sed -i -e "s/-march=native/-march=z196/" build_tools/build_detect_platform sed -i -e "s/-momit-leaf-frame-pointer/-DDUMBDUMMY/" Makefile +elif [ x$MACHINE = xppc64le ] +then + echo There were some bugs in 4.1 for z/p, dev stream has the fix, living dangereously, fixing in place. + echo Below changes are not required for newer releases of rocksdb. + sed -ibak 's/ifneq ($(MACHINE),ppc64)/ifeq (,$(findstring ppc64,$(MACHINE)))/g' Makefile fi PORTABLE=1 make shared_lib