注意: 这是一个流水账笔记, 故结构逻辑是不完整的,尝试性质的。
尝试接入 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
最终还是没有成功。今天到此为止