Skip to content

Commit ad4645d

Browse files
committed
Support hyperledger fabric build on ppc64le platform
Change-Id: I1b840d303674b7469d537aa3f70a87530f757b06 Signed-off-by: Srirama Sharma <[email protected]>
1 parent 5925f57 commit ad4645d

File tree

4 files changed

+133
-5
lines changed

4 files changed

+133
-5
lines changed

devenv/setupUbuntuOnPPC64le.sh

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!/bin/bash
2+
3+
# Development on Power (ppc64le) systems is done outside of vagrant, on the
4+
# native OS. This script helps setup the dev env on ppc64le Ubuntu.
5+
#
6+
# See https://github.com/hyperledger/fabric/blob/master/docs/dev-setup/install.md#building-outside-of-vagrant-
7+
#
8+
# NOTE: This script assumes that
9+
# - OS specific apt-sources / repositories are already set appropriately.
10+
# - Host's GOPATH environment variable is set.
11+
#
12+
# To get started on a fresh Ubuntu install:
13+
# mkdir -p $GOPATH/src/github.com/hyperledger
14+
# cd $GOPATH/src/github.com/hyperledger
15+
# git clone http://gerrit.hyperledger.org/r/fabric
16+
# sudo ./fabric/devenv/setupUbuntuOnPPC64el.sh
17+
# cd $GOPATH/src/github.com/hyperledger/fabric
18+
# make dist-clean all
19+
20+
if [ xroot != x$(whoami) ]
21+
then
22+
echo "You must run as root (Hint: Try prefix 'sudo' while executing the script)"
23+
exit
24+
fi
25+
26+
if [ ! -d "$GOPATH/src/github.com/hyperledger/fabric" ]
27+
then
28+
echo "Ensure fabric code is under $GOPATH/src/github.com/hyperledger/fabric"
29+
exit
30+
fi
31+
32+
#####################################
33+
# Install pre-requisite OS packages #
34+
#####################################
35+
apt-get update
36+
apt-get -y install software-properties-common curl git sudo wget
37+
38+
#####################################
39+
# Install and setup Docker services #
40+
#####################################
41+
# 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.
42+
apt-get -y install docker.io aufs-tools
43+
44+
# Set DOCKER_OPTS and restart Docker daemon.
45+
sed -i '/#DOCKER_OPTS=/a DOCKER_OPTS="-H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock"' /etc/default/docker
46+
systemctl restart docker
47+
48+
####################################
49+
# Install Go and set env variable #
50+
####################################
51+
# Golang binaries for ppc64le are publicly available from Unicamp and is recommended as it includes certain platform specific tuning/optimization.
52+
# Alternativley package part of Ubuntu disto repo can also be used.
53+
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
54+
dpkg -i advance-toolchain-at9.0-golang_9.0-3_ppc64el.deb
55+
rm -f advance-toolchain-at9.0-golang_9.0-3_ppc64el.deb
56+
57+
# Create links under /usr/bin using update-alternatives
58+
update-alternatives --install /usr/bin/go go /usr/local/go/bin/go 9
59+
update-alternatives --install /usr/bin/gofmt gofmt /usr/local/go/bin/gofmt 9
60+
61+
# Set the GOROOT env variable
62+
export GOROOT="/usr/local/go"
63+
64+
####################################
65+
# Build and install RocksDB #
66+
####################################
67+
68+
apt-get -y install libsnappy-dev zlib1g-dev libbz2-dev "build-essential"
69+
70+
cd /tmp
71+
git clone https://github.com/facebook/rocksdb.git
72+
cd rocksdb
73+
git checkout tags/v4.1
74+
echo There were some bugs in 4.1. This was fixed in dev stream and newer releases like 4.5.1.
75+
sed -ibak 's/ifneq ($(MACHINE),ppc64)/ifeq (,$(findstring ppc64,$(MACHINE)))/g' Makefile
76+
PORTABLE=1 make shared_lib
77+
INSTALL_PATH=/usr/local make install-shared
78+
ldconfig
79+
cd - ; rm -rf /tmp/rocksdb
80+
81+
################################################
82+
# Install PIP tools, behave and docker-compose #
83+
################################################
84+
85+
apt-get -y install python-pip
86+
pip install --upgrade pip
87+
pip install behave nose docker-compose
88+
89+
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

docs/dev-setup/build.md

+15
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,21 @@ cd $GOPATH/src/github.com/hyperledger/fabric
158158
make peer unit-test behave
159159
```
160160

161+
### Building on Power Platform
162+
163+
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.
164+
165+
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:
166+
167+
```
168+
mkdir -p $GOPATH/src/github.com/hyperledger
169+
cd $GOPATH/src/github.com/hyperledger
170+
git clone http://gerrit.hyperledger.org/r/fabric
171+
sudo ./fabric/devenv/setupUbuntuOnPPC64le.sh
172+
cd $GOPATH/src/github.com/hyperledger/fabric
173+
make dist-clean all
174+
```
175+
161176
### Building natively on OSX
162177
First, install Docker, as described [here](https://docs.docker.com/engine/installation/mac/).
163178
The database by default writes to /var/hyperledger. You can override this in the `core.yaml` configuration file, under `peer.fileSystemPath`.

images/base/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ VAGRANTIMAGE=packer_virtualbox-iso_virtualbox.box
66

77
DOCKER_BASE_x86_64=ubuntu:trusty
88
DOCKER_BASE_s390x=s390x/ubuntu:xenial
9+
DOCKER_BASE_ppc64le=ppc64le/ubuntu:xenial
910

1011
DOCKER_BASE=$(DOCKER_BASE_$(ARCH))
1112

images/base/scripts/common/setup.sh

+28-5
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,33 @@ apt-get dist-upgrade -qqy
1616
# install git
1717
apt-get install --yes git
1818

19+
MACHINE=`uname -m`
20+
if [ x$MACHINE = xppc64le ]
21+
then
22+
# install sudo
23+
apt-get install --yes sudo
24+
fi
25+
1926
# Set Go environment variables needed by other scripts
2027
export GOPATH="/opt/gopath"
2128

2229
#install golang
2330
#apt-get install --yes golang
2431
mkdir -p $GOPATH
25-
MACHINE=`uname -m`
2632
if [ x$MACHINE = xs390x ]
2733
then
2834
apt-get install --yes golang
2935
export GOROOT="/usr/lib/go-1.6"
30-
elif [ x$MACHINE = xppc64 ]
36+
elif [ x$MACHINE = xppc64le ]
3137
then
32-
echo "TODO: Add PPC support"
33-
exit
38+
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
39+
dpkg -i advance-toolchain-at9.0-golang_9.0-3_ppc64el.deb
40+
rm advance-toolchain-at9.0-golang_9.0-3_ppc64el.deb
41+
42+
update-alternatives --install /usr/bin/go go /usr/local/go/bin/go 9
43+
update-alternatives --install /usr/bin/gofmt gofmt /usr/local/go/bin/gofmt 9
44+
45+
export GOROOT="/usr/local/go"
3446
elif [ x$MACHINE = xx86_64 ]
3547
then
3648
export GOROOT="/opt/go"
@@ -45,6 +57,9 @@ then
4557
mv go $GOROOT
4658
chmod 775 $GOROOT
4759
rm go$GO_VER.linux-${ARCH}.tar.gz
60+
else
61+
echo "TODO: Add $MACHINE support"
62+
exit
4863
fi
4964

5065
PATH=$GOROOT/bin:$GOPATH/bin:$PATH
@@ -59,6 +74,9 @@ EOF
5974
# Install NodeJS
6075

6176
if [ x$MACHINE = xs390x ]
77+
then
78+
apt-get install --yes nodejs
79+
elif [ x$MACHINE = xppc64le ]
6280
then
6381
apt-get install --yes nodejs
6482
else
@@ -120,9 +138,14 @@ cd rocksdb
120138
git checkout tags/v4.1
121139
if [ x$MACHINE = xs390x ]
122140
then
123-
echo There were some bugs in 4.1 for x/p, dev stream has the fix, living dangereously, fixing in place
141+
echo There were some bugs in 4.1 for z/p, dev stream has the fix, living dangereously, fixing in place
124142
sed -i -e "s/-march=native/-march=z196/" build_tools/build_detect_platform
125143
sed -i -e "s/-momit-leaf-frame-pointer/-DDUMBDUMMY/" Makefile
144+
elif [ x$MACHINE = xppc64le ]
145+
then
146+
echo There were some bugs in 4.1 for z/p, dev stream has the fix, living dangereously, fixing in place.
147+
echo Below changes are not required for newer releases of rocksdb.
148+
sed -ibak 's/ifneq ($(MACHINE),ppc64)/ifeq (,$(findstring ppc64,$(MACHINE)))/g' Makefile
126149
fi
127150

128151
PORTABLE=1 make shared_lib

0 commit comments

Comments
 (0)