Skip to content

Commit

Permalink
Merge "Support hyperledger fabric build on ppc64le platform"
Browse files Browse the repository at this point in the history
  • Loading branch information
binhn authored and Gerrit Code Review committed Sep 6, 2016
2 parents 8a19aba + ad4645d commit dc2d339
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 5 deletions.
89 changes: 89 additions & 0 deletions devenv/setupUbuntuOnPPC64le.sh
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions docs/dev-setup/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
1 change: 1 addition & 0 deletions images/base/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
33 changes: 28 additions & 5 deletions images/base/scripts/common/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit dc2d339

Please sign in to comment.