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閱讀 230,527評論 6 544
  • 序言:濱河連續發生了三起死亡事件,死亡現場離奇詭異,居然都是意外死亡,警方通過查閱死者的電腦和手機,發現死者居然都...
    沈念sama閱讀 99,687評論 3 429
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人,你說我怎么就攤上這事。” “怎么了?”我有些...
    開封第一講書人閱讀 178,640評論 0 383
  • 文/不壞的土叔 我叫張陵,是天一觀的道長。 經常有香客問我,道長,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 63,957評論 1 318
  • 正文 為了忘掉前任,我火速辦了婚禮,結果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己,他們只是感情好,可當我...
    茶點故事閱讀 72,682評論 6 413
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發上,一...
    開封第一講書人閱讀 56,011評論 1 329
  • 那天,我揣著相機與錄音,去河邊找鬼。 笑死,一個胖子當著我的面吹牛,可吹牛的內容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 44,009評論 3 449
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了?” 一聲冷哼從身側響起,我...
    開封第一講書人閱讀 43,183評論 0 290
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后,有當地人在樹林里發現了一具尸體,經...
    沈念sama閱讀 49,714評論 1 336
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內容為張勛視角 年9月15日...
    茶點故事閱讀 41,435評論 3 359
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發現自己被綠了。 大學時的朋友給我發了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 43,665評論 1 374
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖,靈堂內的尸體忽然破棺而出,到底是詐尸還是另有隱情,我是刑警寧澤,帶...
    沈念sama閱讀 39,148評論 5 365
  • 正文 年R本政府宣布,位于F島的核電站,受9級特大地震影響,放射性物質發生泄漏。R本人自食惡果不足惜,卻給世界環境...
    茶點故事閱讀 44,838評論 3 350
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 35,251評論 0 28
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至,卻和暖如春,著一層夾襖步出監牢的瞬間,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 36,588評論 1 295
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人。 一個月前我還...
    沈念sama閱讀 52,379評論 3 400
  • 正文 我出身青樓,卻偏偏與公主長得像,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當晚...
    茶點故事閱讀 48,627評論 2 380

推薦閱讀更多精彩內容