Skip to content

Commit d5eb9ae

Browse files
author
root
committed
Rebase to latest Hyperledger code
1 parent 2f070d5 commit d5eb9ae

File tree

9 files changed

+136
-16
lines changed

9 files changed

+136
-16
lines changed

README.s390x.md

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
This is a fork of the Hyperledger fabric repository which has been patched to compile on Linux s390x. Please follow the steps below to build Hyperledger. The instructions assume a Debian host but should also work on Ubuntu. When appropriate, commands for RHEL or SLES are also given.
2+
3+
####1. Install docker
4+
For RHEL and SLES, you can get it at https://www.ibm.com/developerworks/linux/linux390/docker.html. And for Debian, you can get it here at https://github.com/gongsu832/docker-s390x-debian (statically linked binaries should work on all distros). On Debian and Ubuntu, you may need to install aufs-tools if it's not already installed and you want to use aufs (not recommended) as the storage driver..
5+
6+
```
7+
apt-get install aufs-tools
8+
```
9+
10+
While the docker daemon can automatically pull images on demand, it's better to pull the pre-built Hyperledger base image now since it's more than 1GB. To do that,
11+
12+
```
13+
# docker daemon -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock > /var/log/docker.log 2>&1 &
14+
# docker pull s390xlinux/hyperledger-go1.6-rocksdb4.6
15+
```
16+
17+
Note that -H tcp://0.0.0.0:2375 is not really needed for pulling images. It's for doing the Hyperledger "behave" tests later.
18+
19+
####2. Install go 1.6
20+
Due to legal reasons, IBM cannot yet distribute prebuilt go 1.6 binary for Linux s390x. There are instructions on how to build one yourself from the publically available source but the process is rather involved. Instead, the easiest way is to get a copy that someone else already built.
21+
22+
```
23+
# docker pull brunswickheads/golang-1.6-s390x
24+
# container_id=$(docker create brunswickheads/golang-1.6-s390x /bin/bash)
25+
# docker cp $container_id:/usr/local/go - | tar x -C /opt --no-same-owner --no-same-permissions
26+
# docker rm $container_id
27+
```
28+
29+
This will extract go 1.6 from the docker image into /opt/go. To use it, set GOROOT=/opt/go and add /opt/go/bin to your PATH. You can delete brunswickheads/golang-1.6-s390x image afterwards if you no longer need it.
30+
31+
####3. Install rocksdb
32+
The example below clones into /opt/rocksdb. You can choose wherever you prefer.
33+
34+
```
35+
# cd /opt
36+
# git clone https://github.com/facebook/rocksdb.git
37+
# cd rocksdb
38+
# make shared_lib
39+
```
40+
41+
This generates librocksdb.so in /opt/rocksdb. For compiling code, add -I/opt/rocksdb/include to your compiler flag and -L/opt/rocksdb -lrocksdb to your linker flag. For running code, add /opt/rocksdb to your LD_LIBRARY_PATH.
42+
43+
####4. Build Hyperledger
44+
Once again, the example below uses GOPATH=/opt/openchain and you are free to use wherever you prefer.
45+
46+
```
47+
# apt-get install libbz2-dev libsnappy-dev zlib1g-dev
48+
# cd /opt
49+
# mkdir -p openchain/src/github.com/hyperledger
50+
# cd openchain/src/github.com/hyperledger
51+
# git clone https://github.com/gongsu832/fabric.git
52+
# cd fabric/peer
53+
# export GOPATH=/opt/openchain
54+
# CGO_CFLAGS="-I/opt/rocksdb/include" CGO_LDFLAGS="-L/opt/rocksdb -lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy" go build
55+
```
56+
57+
For RHEL, replace apt-get command with
58+
```
59+
# yum install bzip2-devel snappy-devel zlib-devel
60+
```
61+
62+
For SLES, replace apt-get command with
63+
```
64+
# zypper install libbz2-devel snappy-devel zlib-devel
65+
```
66+
67+
This generates "peer" binary in the current directory.
68+
69+
To build the Hyperledger CA server, which is required when security is enabled,
70+
71+
```
72+
# cd $GOPATH/src/github.com/hyperledger/fabric/membersrvc
73+
# CGO_CFLAGS="-I/opt/rocksdb/include" CGO_LDFLAGS="-L/opt/rocksdb -lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy" go build
74+
```
75+
76+
#####To run the unit tests,
77+
78+
```
79+
# cd $GOPATH/src/github.com/hyperledger/fabric/peer
80+
# ./peer node start > /var/log/peer.log 2>&1 &
81+
# CGO_CFLAGS="-I/opt/rocksdb/include" CGO_LDFLAGS="-L/opt/rocksdb -lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy" go test -timeout=20m $(go list github.com/hyperledger/fabric/...|grep -v /vendor/|grep -v /examples/)
82+
```
83+
84+
You should have no FAIL for any test. Note that to rerun the tests, you need to clean up all the leftover containers and images except s390xlinux/hyperledger-go1.6-rocksdb4.6.
85+
86+
#####To run the behave tests,
87+
88+
Install docker-compose and behave if you haven't already,
89+
90+
```
91+
# apt-get install python-setuptools python-pip
92+
# pip install docker-compose behave
93+
```
94+
95+
For RHEL
96+
```
97+
# yum install python-setuptools
98+
# curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
99+
# python get-pip.py
100+
# pip install docker-compose behave
101+
```
102+
103+
For SLES
104+
```
105+
# zypper install python-devel python-setuptools
106+
# curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
107+
# python get-pip.py
108+
# pip install docker-compose behave
109+
```
110+
111+
Then run the behave tests,
112+
113+
```
114+
# cd $GOPATH/src/github.com/hyperledger/fabric/bddtests
115+
# behave >behave.log 2>&1 &
116+
```
117+
118+
You may have a few failed and skipped tests and it's OK to ignore them if they are not "cannot connect to Docker endpoint" error mentioned below. Note that to rerun the tests, you need to clean up all the leftover containers and images except s390xlinux/hyperledger-go1.6-rocksdb4.6, hyperledger-peer, and membersrvc.
119+
120+
If you have tests failing for reason like "cannot connect to Docker endpoint", check the IP address of interface docker0 on your system. In compose-defaults.yml file, the IP address is assumed to be 172.17.0.1. You must change it to match what you have on your system.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
from hyperledger/fabric-baseimage:latest
1+
from s390xlinux/hyperledger-go1.6-rocksdb4.6:latest
22

33
# Copy GOPATH src and install Peer
44
RUN mkdir -p /var/hyperledger/db
55
RUN mkdir -p /var/hyperledger/production
66
WORKDIR $GOPATH/src/github.com/hyperledger/fabric
77
COPY . .
88
WORKDIR $GOPATH/src/github.com/hyperledger/fabric/peer
9-
RUN CGO_CFLAGS=" " CGO_LDFLAGS="-lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy" go install && cp $GOPATH/src/github.com/hyperledger/fabric/peer/core.yaml $GOPATH/bin
9+
RUN CGO_CFLAGS="-I/opt/rocksdb/include" CGO_LDFLAGS="-L/opt/rocksdb -lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy" go install && cp $GOPATH/src/github.com/hyperledger/fabric/peer/core.yaml $GOPATH/bin
1010
RUN cp $GOPATH/src/github.com/hyperledger/fabric/consensus/obcpbft/config.yaml $GOPATH/bin
1111
# RUN CGO_CFLAGS=" " CGO_LDFLAGS="-lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy" go install
1212
# RUN cd membersrvc && go install

core/container/controller_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func getCodeChainBytesInMem() (io.Reader, error) {
112112
inputbuf := bytes.NewBuffer(nil)
113113
gw := gzip.NewWriter(inputbuf)
114114
tr := tar.NewWriter(gw)
115-
dockerFileContents := []byte("FROM busybox:latest\n\nCMD echo hello")
115+
dockerFileContents := []byte("FROM s390x/busybox:latest\n\nCMD echo hello")
116116
dockerFileSize := int64(len([]byte(dockerFileContents)))
117117

118118
tr.WriteHeader(&tar.Header{Name: "Dockerfile", Size: dockerFileSize, ModTime: startTime, AccessTime: startTime, ChangeTime: startTime})

core/ledger/genesis/genesis_test.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ peer:
4646
networkId: dev
4747

4848
Dockerfile: |
49-
from hyperledger/fabric-baseimage
49+
from s390xlinux/hyperledger-go1.6-rocksdb4.6:latest
5050
# Copy GOPATH src and install Peer
5151
COPY src $GOPATH/src
5252
RUN mkdir -p /var/hyperledger/db
5353
WORKDIR $GOPATH/src/github.com/hyperledger/fabric/peer/
54-
RUN CGO_CFLAGS=" " CGO_LDFLAGS="-lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy" go install && cp $GOPATH/src/github.com/hyperledger/fabric/peer/core.yaml $GOPATH/bin
54+
RUN CGO_CFLAGS="-I/opt/rocksdb/include" CGO_LDFLAGS="-L/opt/rocksdb -lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy" go install && cp $GOPATH/src/github.com/hyperledger/fabric/peer/core.yaml $GOPATH/bin
5555
5656
# The Address this Peer will bind to for providing services
5757
address: 0.0.0.0:30303
@@ -186,7 +186,7 @@ chaincode:
186186

187187
# This is the basis for the Golang Dockerfile. Additional commands will be appended depedendent upon the chaincode specification.
188188
Dockerfile: |
189-
from hyperledger/fabric-baseimage
189+
from s390xlinux/hyperledger-go1.6-rocksdb4.6:latest
190190
COPY src $GOPATH/src
191191
WORKDIR $GOPATH
192192

examples/chaincode/go/utxo/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from hyperledger/fabric-baseimage
1+
from s390xlinux/hyperledger-go1.6-rocksdb4.6:latest
22

33
RUN apt-get update && apt-get install pkg-config autoconf libtool -y
44
RUN cd /tmp && git clone https://github.com/bitcoin/secp256k1.git && cd secp256k1/

membersrvc/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
from hyperledger/fabric-baseimage:latest
1+
from s390xlinux/hyperledger-go1.6-rocksdb4.6:latest
22
# Copy GOPATH src and install Peer
33
RUN mkdir -p /var/hyperledger/db
44
WORKDIR $GOPATH/src/github.com/hyperledger/fabric/
55
COPY . .
66
WORKDIR membersrvc
77
RUN pwd
8-
RUN CGO_CFLAGS=" " CGO_LDFLAGS="-lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy" go install && cp $GOPATH/src/github.com/hyperledger/fabric/membersrvc/membersrvc.yaml $GOPATH/bin
8+
RUN CGO_CFLAGS="-I/opt/rocksdb/include" CGO_LDFLAGS="-L/opt/rocksdb -lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy" go install && cp $GOPATH/src/github.com/hyperledger/fabric/membersrvc/membersrvc.yaml $GOPATH/bin
99
# RUN CGO_CFLAGS=" " CGO_LDFLAGS="-lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy" go install

membersrvc/ca/ca_test.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ peer:
5757
networkId: dev
5858

5959
Dockerfile: |
60-
from hyperledger/fabric-baseimage:latest
60+
from s390xlinux/hyperledger-go1.6-rocksdb4.6:latest
6161
# Copy GOPATH src and install Peer
6262
COPY src $GOPATH/src
6363
RUN mkdir -p /var/hyperledger/db
6464
WORKDIR $GOPATH/src/github.com/hyperledger/fabric/peer/
65-
RUN CGO_CFLAGS=" " CGO_LDFLAGS="-lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy" go install && cp $GOPATH/src/github.com/hyperledger/fabric/peer/core.yaml $GOPATH/bin
65+
RUN CGO_CFLAGS="-I/opt/rocksdb/include" CGO_LDFLAGS="-L/opt/rocksdb -lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy" go install && cp $GOPATH/src/github.com/hyperledger/fabric/peer/core.yaml $GOPATH/bin
6666
6767
# The Address this Peer will listen on
6868
listenAddress: 0.0.0.0:30303
@@ -239,7 +239,7 @@ chaincode:
239239

240240
# This is the basis for the Golang Dockerfile. Additional commands will be appended depedendent upon the chaincode specification.
241241
Dockerfile: |
242-
from hyperledger/fabric-baseimage
242+
from s390xlinux/hyperledger-go1.6-rocksdb4.6:latest
243243
COPY src $GOPATH/src
244244
WORKDIR $GOPATH
245245

peer/core.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@ peer:
9191
networkId: dev
9292

9393
Dockerfile: |
94-
from hyperledger/fabric-baseimage:latest
94+
from s390xlinux/hyperledger-go1.6-rocksdb4.6:latest
9595
# Copy GOPATH src and install Peer
9696
COPY src $GOPATH/src
9797
RUN mkdir -p /var/hyperledger/db
9898
WORKDIR $GOPATH/src/github.com/hyperledger/fabric/peer/
99-
RUN CGO_CFLAGS=" " CGO_LDFLAGS="-lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy" go install && cp $GOPATH/src/github.com/hyperledger/fabric/peer/core.yaml $GOPATH/bin
99+
RUN CGO_CFLAGS="-I/opt/rocksdb/include" CGO_LDFLAGS="-L/opt/rocksdb -lrocksdb -lstdc++ -lm -lz -lbz2 -lsnappy" go install && cp $GOPATH/src/github.com/hyperledger/fabric/peer/core.yaml $GOPATH/bin
100100
101101
102102
# The Address this Peer will listen on
@@ -289,7 +289,7 @@ chaincode:
289289
# This is the basis for the Golang Dockerfile. Additional commands will
290290
# be appended depedendent upon the chaincode specification.
291291
Dockerfile: |
292-
from hyperledger/fabric-baseimage
292+
from s390xlinux/hyperledger-go1.6-rocksdb4.6:latest
293293
#from utxo:0.1.0
294294
COPY src $GOPATH/src
295295
WORKDIR $GOPATH

vendor/github.com/mattn/go-sqlite3/sqlite3_other.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)