一,安装工具
VBOX
vagrant
vagrant proxy
golang
二,下载源代码
hyperledge
gotools
三.
1.
==> default: package golang.org/x/tools/go/gcimporter15: unrecognized import path "golang.org/x/tools/go/gcimporter15" (https fetch: Get https://golang.org/x/tools/go/gcimporter15?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
==> default: Makefile:: recipe for target 'gotool.golint' failed
==> default: make[]: Leaving directory '/opt/gopath/src/github.com/hyperledger/fabric/gotools'
==> default: make[]: *** [gotool.golint] Error
==> default: Makefile:: recipe for target 'build/gopath/bin/golint' failed
==> default: make[]: Leaving directory '/opt/gopath/src/github.com/hyperledger/fabric/gotools'
==> default: make[]: *** [build/gopath/bin/golint] Error
==> default: Makefile:: recipe for target 'gotools' failed
==> default: make: *** [gotools] Error
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.
export fabric_path=~/gopath/fabric
mkdir -p $fabric_path/gotools/build/gopath/src/golang.org/x/
git clone https://github.com/golang/tools.git
mv tools $fabric_path/gotools/build/gopath/src/golang.org/x/
cd $fabric_path/devenv
vagrant destroy
vagrant up
2.
是在执行如下命令是出错
curl -L https://github.com/hyperledger/fabric-chaintool/releases/download/$(CHAINTOOL_RELEASE)/chaintool > $@
https://github-cloud.s3.amazonaws.com/releases/52034138/f54fb054-9560-11e6-934a-5272acfba1b8?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAISTNZFOVBIJMK3TQ%2F20161128%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20161128T075224Z&X-Amz-Expires=300&X-Amz-Signature=a7eb3348572a9fa9a9bf044e54805cda9e6bbfcdfd6f21e1bd0783bd3964c5d9&X-Amz-SignedHeaders=host&actor_id=10493939&response-content-disposition=attachment%3B%20filename%3Dchaintool&response-content-type=application%2Foctet-stream
最终下载的地址是这个,由于s3.amazonaws.com被墙,所以下载失败;可以手工下载让后覆盖到 build/bin 下继续执行 make peer
解决办法
1)编辑Makefile文件(在宿主机中操作),将130行注释掉
build/bin/chaintool: Makefile
@echo "Installing chaintool"
@mkdir -p $(@D)
#curl -L https://github.com/hyperledger/fabric-chaintool/releases/download/$(CHAINTOOL_RELEASE)/chaintool > $@
chmod +x $@
2)将下载的chaintool复制到指定目录
export fabric_path=~/gopath/fabric
#宿主机中执行
cp ~/Downloads/chaintool $fabric_path/build/bin
cd $fabric_path/devenv
#
vagrant ssh
cd $GOPATH/src/github.com/hyperledger/fabric
make peer
3).
vagrant@hyperledger-devenv:v0.2.1-f046f3c:/opt/gopath/src/github.com/hyperledger/fabric$ make peer
make[]: Entering directory '/opt/gopath/src/github.com/hyperledger/fabric/gotools'
Building github.com/golang/lint/golint -> golint
package golang.org/x/tools/go/gcimporter15: unrecognized import path "golang.org/x/tools/go/gcimporter15" (https fetch: Get https://golang.org/x/tools/go/gcimporter15?go-get=1: dial tcp 216.239.37.1:443: i/o timeout)
make[]: *** [gotool.golint] Error
Makefile:: recipe for target 'gotool.golint' failed
make[]: Leaving directory '/opt/gopath/src/github.com/hyperledger/fabric/gotools'
Makefile:: recipe for target '/opt/gotools/obj/gopath/bin/golint' failed
make: *** [/opt/gotools/obj/gopath/bin/golint] Error
Makefile:: recipe for target 'build/docker/gotools' failed
make: *** [build/docker/gotools] Error
#生成gotools二进制文件
make gotools
#复制到build/docker/gotools目录
cp -r ./gotools/build/gopath/bin ./build/docker/gotools/
make peer
4).
build javaenv时下载gradle-2.12-bin.zip很长时间无响应
是由于RUN wget https://services.gradle.org/distributions/gradle-2.12-bin.zip -P /tmp --quiet 命令连接国外服务器太慢导致,可以使用迅雷下载到本地,复制到
$fabric_path/build/image/javaenv目录下,同时修改$fabric_path/image/javaenv下的Dockerfile.in文件后继续执行make peer即可
FROM hyperledger/fabric-baseimage:_BASE_TAG_
#RUN wget https://services.gradle.org/distributions/gradle-2.12-bin.zip -P /tmp --quiet
ADD gradle-2.12-bin.zip /tmp
RUN unzip -q /tmp/gradle-2.12-bin.zip -d /opt && rm /tmp/gradle-2.12-bin.zip
RUN ln -s /opt/gradle-2.12/bin/gradle /usr/bin
ADD payload/javashim.tar.bz2 /root
ADD payload/protos.tar.bz2 /root
ADD payload/settings.gradle /root
WORKDIR /root
# Build java shim after copying proto files from fabric/proto
RUN core/chaincode/shim/java/javabuild.sh
5).
Step : RUN core/chaincode/shim/java/javabuild.sh
---> Running in 868d72341738
修改$fabric_path/core/chaincode/shim/java/build.gradle文件,增加maven的阿里源
buildscript {
repositories {
maven { url "http://maven.aliyun.com/nexus/content/groups/public" }
mavenLocal()
mavenCentral()
jcenter()
}
dependencies {
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.7.6'
}
}
cp build/docker/gotools/bin/protoc-gen-go build/bin/chaintool build/goshim.tar.bz2 build/image/ccenv/payload
cp: cannot stat 'build/docker/gotools/bin/protoc-gen-go': No such file or directory
Makefile:: recipe for target 'build/image/ccenv/payload' failed
make: *** [build/image/ccenv/payload] Error
cp gotools/build/gopath/bin/* build/docker/gotools/bin
make peer
vagrant下载镜像经常失败的问题
#使用迅雷下载 virtualbox.box
#https://atlas.hashicorp.com/hyperledger/boxes/fabric-baseimage/versions/0.3.0/providers/virtualbox.box
#https://atlas.hashicorp.com/hyperledger/boxes/fabric-baseimage
#复制virtualbox.box文件到 ~/.vagrant.d/boxes/virtualbox.box
vagrant box add -name hyperledger/fabric-baseimage ~/.vagrant.d/boxes/virtualbox.box -c --force
#修改 ~/.vagrant.d/boxes/hyperledger-VAGRANTSLASH-fabric-baseimage文件夹下的文件0的名称为0.3.0
#http://stackoverflow.com/questions/28399324/download-vagrant-box-file-locally-from-atlas-and-configuring-it
vagrant up