EOS 运行笔记

注意: 这是一个流水账笔记, 故结构逻辑是不完整的,尝试性质的。

尝试接入 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

最终还是没有成功。今天到此为止

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 212,222评论 6 493
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 90,455评论 3 385
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 157,720评论 0 348
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 56,568评论 1 284
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 65,696评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,879评论 1 290
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,028评论 3 409
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,773评论 0 268
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,220评论 1 303
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,550评论 2 327
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,697评论 1 341
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,360评论 4 332
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,002评论 3 315
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,782评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,010评论 1 266
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,433评论 2 360
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,587评论 2 350

推荐阅读更多精彩内容