设置开发环境¶
准备工作¶
Go - version 1.12.x
(macOS) Xcode 必须安装
Docker - 17.06.2-ce或者更高版本
Docker Compose - 1.14.0或者更高版本
(macOS)你必须先安装gnutar,因为macOS系统默认使用自带的bsdtar,但是1.4使用了一些gnutar的参数。你可以通过Homebrew来安装gnutar:
brew install gnu-tar
(macOS) If you install gnutar, you should prepend the “gnubin” directory to the $PATH environment variable with something like:
export PATH=/usr/local/opt/gnu-tar/libexec/gnubin:$PATH
(macOS) Libtool。你可以使用Homebrew,参考下面的命令来安装:
brew install libtool
(仅在使用Vagrant的时候需要) - Vagrant - 1.9或者更高版本
(仅在使用Vagrant的时候需要) - VirtualBox - 5.0或者更高版本
BIOS开启虚拟化功能 - 根据硬件变化
提示:BIOS开启虚拟化应该是指在CPU内或者BIOS的安全设置。
步骤¶
设置GOPATH¶
Make sure you have properly setup your Host’s GOPATH environment variable. This allows for both building within the Host and the VM.
In case you installed Go into a different location from the standard one your Go distribution assumes, make sure that you also set GOROOT environment variable.
Note to Windows users¶
If you are running Windows, before running any git clone
commands,
run the following command.
git config --get core.autocrlf
If core.autocrlf
is set to true
, you must set it to false
by
running
git config --global core.autocrlf false
If you continue with core.autocrlf
set to true
, the
vagrant up
command will fail with the error:
./setup.sh: /bin/bash^M: bad interpreter: No such file or directory
Cloning the Hyperledger Fabric source¶
Since Hyperledger Fabric is written in Go
, you’ll need to
clone the source repository to your $GOPATH/src directory. If your $GOPATH
has multiple path components, then you will want to use the first one.
There’s a little bit of setup needed:
cd $GOPATH/src
mkdir -p github.com/hyperledger
cd github.com/hyperledger
Recall that we are using Gerrit
for source control, which has its
own internal git repositories. Hence, we will need to clone from
Gerrit.
For brevity, the command is as follows:
git clone ssh://LFID@gerrit.hyperledger.org:29418/fabric && scp -p -P 29418 LFID@gerrit.hyperledger.org:hooks/commit-msg fabric/.git/hooks/
Note: Of course, you would want to replace LFID
with your own
Linux Foundation ID.