注意: 這是一個流水賬筆記, 故結構邏輯是不完整的,嘗試性質的。
嘗試接入 EOS testnet
使用的文檔 https://github.com/EOSIO/eos
clone eos 代碼
git clone https://github.com/EOSIO/eos.git
運行 eosio_build.sh 腳本
運行出錯
Hit:10 http://mirrors.aliyun.com/ubuntu trusty-security InRelease
Hit:11 http://mirrors.aliyun.com/ubuntu trusty-updates InRelease
Hit:12 http://mirrors.aliyun.com/ubuntu trusty-proposed InRelease
Hit:13 http://mirrors.aliyun.com/ubuntu trusty-backports InRelease
Hit:14 http://mirrors.aliyun.com/ubuntu trusty Release
Hit:20 https://deb.nodesource.com/node_8.x xenial InRelease
Reading package lists... Done
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package lldb-4.0 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Unable to locate package clang-4.0
E: Couldn't find any package by glob 'clang-4.0'
E: Couldn't find any package by regex 'clang-4.0'
E: Package 'lldb-4.0' has no installation candidate
E: Unable to locate package libclang-4.0-dev
E: Couldn't find any package by glob 'libclang-4.0-dev'
E: Couldn't find any package by regex 'libclang-4.0-dev'
DPKG dependency failed.
Exiting now.
提示找不到如上這些包
我本地環境為 ubuntu-16.04
$ cat /etc/os-release
NAME="Ubuntu"
VERSION="16.04.1 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.1 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
VERSION_CODENAME=xenial
UBUNTU_CODENAME=xenial
找一個包試試看, 比如 clang-4.0
$ apt-cache search clang-
...
clang-3.9 - C, C++ and Objective-C compiler (LLVM based)
...
能找到clang的最高版本號為 3.9 .
第一步build 就過不去。 注意看文檔,有這么一句. 也就釋然了。
As of February 2018, master is under heavy development and is not suitable for experimentation.
eos 所支持的 操作系統要求 ubuntu 是 16.04 and higher , 看樣子, ubuntu 16.04 是不支持的, 需要至少 ubuntu 16.10 .
尋求其他路徑 Docker
參考這個文檔 https://github.com/EOSIO/eos/blob/master/Docker/README.md
其中要求 docker版本號為 Docker 17.05 or higher , 我本地的docker 版本為 1.12 (Docker版本命名規則有變更過, Docker 17.05 大概是 docker 1.13 后一兩個版本) ,本地版本不滿足要求, 先運行了看看, 會有什么錯誤
$ docker build . -t eosio/eos
Sending build context to Docker daemon 16.38 kB
Step 1 : FROM ubuntu:16.04 as builder
Error parsing reference: "ubuntu:16.04 as builder" is not a valid repository/tag
報錯是 "ubuntu:16.04 as builder" is not a valid repository/tag
, 看一下 Dockerfile
FROM ubuntu:16.04 as builder
LABEL maintainer="Huang-Ming Huang <huangh@objectcomputing.com>" version="0.1.1" \
description="This is a base image for building eosio/eos"
這個語法, 目前docker 1.12 和 1.13 是不支持的, 必須升級到 Docker 17
這條路, 也不是很好走。
嘗試使用手工安裝步驟
是用這個文檔
https://github.com/EOSIO/eos#clean-install-ubuntu-1604--higher
從Dockerfile中, 可以看出, 需要添加一個軟件源
echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-4.0 main" >> /etc/apt/sources.list.d/llvm.list
運行完畢之后, 再運行
sudo apt-get update
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -
sudo apt-get install clang-4.0 lldb-4.0 libclang-4.0-dev cmake make \
libbz2-dev libssl-dev libgmp3-dev \
autotools-dev build-essential \
libbz2-dev libicu-dev python-dev \
autoconf libtool git
報了其他錯誤
The following packages have unmet dependencies:
clang-4.0 : Depends: libjsoncpp1 but it is not installable
Depends: libobjc-5-dev but it is not installable
Recommends: llvm-4.0-dev but it is not going to be installed
libbz2-dev : Depends: libbz2-1.0 (= 1.0.6-5) but 1.0.6-8 is to be installed
libclang-4.0-dev : Depends: libobjc-5-dev but it is not installable
libgmp3-dev : Depends: libgmp-dev (= 2:5.1.3+dfsg-1ubuntu1) but it is not going to be installed
libssl-dev : Depends: libssl1.0.0 (= 1.0.1f-1ubuntu2.23) but 1.0.2g-1ubuntu4.10 is to be installed
Depends: zlib1g-dev but it is not going to be installed
Recommends: libssl-doc but it is not going to be installed
lldb-4.0 : Depends: llvm-4.0-dev but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
依然是運行不起來, 真的必須是 ubntu 16.10 才行嗎?
再次嘗試Docker
可能Docker 更靠譜一些。 我的宿主機可能運行時間太久, 有太多不兼容的地方, 現在也沒有必要去找了。
讀了一下他的 Dockerfile, 覺得是可以手工解決需要 高版本 Docker的問題的, 我將Dockerfile 拆分了一下, build 部分拆分成
FROM ubuntu:16.04
MAINTAINER "Huang-Ming Huang <huangh@objectcomputing.com>"
ADD sources.list /etc/apt/sources.list
RUN echo 'APT::Install-Recommends 0;' >> /etc/apt/apt.conf.d/01norecommends \
&& echo 'APT::Install-Suggests 0;' >> /etc/apt/apt.conf.d/01norecommends \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y sudo wget curl net-tools ca-certificates unzip
RUN echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-4.0 main" >> /etc/apt/sources.list.d/llvm.list \
&& wget -O - http://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add - \
&& apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y git-core automake autoconf libtool build-essential pkg-config libtool \
mpi-default-dev libicu-dev python-dev python3-dev libbz2-dev zlib1g-dev libssl-dev libgmp-dev \
clang-4.0 lldb-4.0 lld-4.0 llvm-4.0-dev libclang-4.0-dev ninja-build \
&& rm -rf /var/lib/apt/lists/*
RUN update-alternatives --install /usr/bin/clang clang /usr/lib/llvm-4.0/bin/clang 400 \
&& update-alternatives --install /usr/bin/clang++ clang++ /usr/lib/llvm-4.0/bin/clang++ 400
RUN wget --no-check-certificate https://cmake.org/files/v3.9/cmake-3.9.6-Linux-x86_64.sh \
&& bash cmake-3.9.6-Linux-x86_64.sh --prefix=/usr/local --exclude-subdir --skip-license \
&& rm cmake-3.9.6-Linux-x86_64.sh
ENV CC clang
ENV CXX clang++
RUN wget https://dl.bintray.com/boostorg/release/1.64.0/source/boost_1_64_0.tar.bz2 -O - | tar -xj \
&& cd boost_1_64_0 \
&& ./bootstrap.sh --prefix=/usr/local \
&& echo 'using clang : 4.0 : clang++-4.0 ;' >> project-config.jam \
&& ./b2 -d0 -j4 --with-thread --with-date_time --with-system --with-filesystem --with-program_options \
--with-signals --with-serialization --with-chrono --with-test --with-context --with-locale --with-coroutine --with-iostreams toolset=clang link=static install \
&& cd .. && rm -rf boost_1_64_0
RUN wget https://github.com/mongodb/mongo-c-driver/releases/download/1.8.0/mongo-c-driver-1.8.0.tar.gz -O - | tar -xz \
&& cd mongo-c-driver-1.8.0 \
&& ./configure --disable-automatic-init-and-cleanup --prefix=/usr/local \
&& make install \
&& cd .. && rm -rf mongo-c-driver-1.8.0
RUN git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/llvm.git \
&& git clone --depth 1 --single-branch --branch release_40 https://github.com/llvm-mirror/clang.git llvm/tools/clang \
&& cd llvm \
&& cmake -H. -Bbuild -GNinja -DCMAKE_INSTALL_PREFIX=/opt/wasm -DLLVM_TARGETS_TO_BUILD= -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD=WebAssembly -DCMAKE_BUILD_TYPE=Release \
&& cmake --build build --target install \
&& cd .. && rm -rf llvm
RUN wget https://github.com/WebAssembly/binaryen/archive/1.37.21.tar.gz -O - | tar -xz \
&& cd binaryen-1.37.21 \
&& cmake -H. -Bbuild -GNinja -DCMAKE_BUILD_TYPE=Release \
&& cmake --build build --target install \
&& cd .. && rm -rf binaryen-1.37.21
RUN git clone --depth 1 git://github.com/cryptonomex/secp256k1-zkp \
&& cd secp256k1-zkp \
&& ./autogen.sh \
&& ./configure --prefix=/usr/local \
&& make install \
&& cd .. && rm -rf secp256k1-zkp
RUN git clone --depth 1 -b releases/stable git://github.com/mongodb/mongo-cxx-driver \
&& cd mongo-cxx-driver \
&& cmake -H. -Bbuild -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local\
&& cmake --build build --target install
### If you don't want to change the depedencies, you can comment out above lines and uncomnent the following line to get faster build time.
# FROM huangminghuang/eos_builder as builder
RUN git clone -b master --depth 1 https://github.com/EOSIO/eos.git --recursive \
&& cd eos \
&& cmake -H. -B"/tmp/build" -GNinja -DCMAKE_BUILD_TYPE=Release -DWASM_LLVM_CONFIG=/opt/wasm/bin/llvm-config -DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_C_COMPILER=clang -DCMAKE_INSTALL_PREFIX=/opt/eos -DSecp256k1_ROOT_DIR=/usr/local \
&& cmake --build /tmp/build --target install
這里添加了 aliyun的源, 因為默認的源在國內,太慢了。
sources.list
文件如下
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu/ xenial-security main restricted
deb http://security.ubuntu.com/ubuntu/ xenial-security universe
deb-src http://security.ubuntu.com/ubuntu/ xenial-security universe
deb http://security.ubuntu.com/ubuntu/ xenial-security multiverse
運行如下命令, build
docker build . -f Dockerfile-build -t eos-build
dockerfile build 時,非常慢, 原因是有好幾個文件需要下載, 在國內下載的速度非常慢 。
以下是這個幾個文件的連接
wget --no-check-certificate https://cmake.org/files/v3.9/cmake-3.9.6-Linux-x86_64.sh
wget https://dl.bintray.com/boostorg/release/1.64.0/source/boost_1_64_0.tar.bz2
wget https://github.com/mongodb/mongo-c-driver/releases/download/1.8.0/mongo-c-driver-1.8.0.tar.gz
wget https://github.com/WebAssembly/binaryen/archive/1.37.21.tar.gz
為了加快速度, 需要提前下載好這幾個文件
docker.com 編譯
本地build , 實在是太慢了。 可以使用 cloud.docker.com 進行build, docker.com 可以和 github.com 連接, 通過github的代碼觸發 docker.com 自動編譯。
我們去fork一下 eos 的代碼, 然后在 docker.com 上新建一個新的倉庫, docker路徑填寫為 Docker/Dockerfile
即使是 docker.com 去 build , 仍然是很慢的。
本地編譯
下載好如上幾個文件之后, 修改dockerfile
被一個問題,搞了半天。 原因是 Docker 的ADD 指令會去解壓文件, 因此 解壓命令一直報錯, 提示 boost_1_64_0.tar.bz2: Cannot read: Is a directory
, 換成 COPY 即可
Step 13 : RUN tar -xjf boost_1_64_0.tar.bz2
---> Running in ad59e6850348
tar (child): boost_1_64_0.tar.bz2: Cannot read: Is a directory
tar (child): At beginning of tape, quitting now
tar (child): Error is not recoverable: exiting now
bzip2: Compressed file ends unexpectedly;
perhaps it is corrupted? *Possible* reason follows.
bzip2: Inappropriate ioctl for device
Input file = (stdin), output file = (stdout)
It is possible that the compressed file(s) have become corrupted.
You can use the -tvv option to test integrity of such files.
You can use the `bzip2recover' program to attempt to recover
data from undamaged sections of corrupted files.
tar: Child returned status 2
tar: Error is not recoverable: exiting now
最終還是沒有成功。今天到此為止