install_deps.sh 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. #!/usr/bin/env bash
  2. #------------------------------------------------------------------------------
  3. # Bash script for installing pre-requisite packages for cpp-ethereum on a
  4. # variety of Linux and other UNIX-derived platforms.
  5. #
  6. # This is an "infrastucture-as-code" alternative to the manual build
  7. # instructions pages which we previously maintained, first as Wiki pages
  8. # and later as readthedocs pages at http://ethdocs.org.
  9. #
  10. # The aim of this script is to simplify things down to the following basic
  11. # flow for all supported operating systems:
  12. #
  13. # - git clone --recursive
  14. # - ./install_deps.sh
  15. # - cmake && make
  16. #
  17. # At the time of writing we are assuming that 'lsb_release' is present for all
  18. # Linux distros, which is not a valid assumption. We will need a variety of
  19. # approaches to actually get this working across all the distros which people
  20. # are using.
  21. #
  22. # See http://unix.stackexchange.com/questions/92199/how-can-i-reliably-get-the-operating-systems-name
  23. # for some more background on this common problem.
  24. #
  25. # TODO - There is no support here yet for cross-builds in any form, only
  26. # native builds. Expanding the functionality here to cover the mobile,
  27. # wearable and SBC platforms covered by doublethink and EthEmbedded would
  28. # also bring in support for Android, iOS, watchOS, tvOS, Tizen, Sailfish,
  29. # Maemo, MeeGo and Yocto.
  30. #
  31. # The documentation for cpp-ethereum is hosted at http://cpp-ethereum.org
  32. #
  33. # ------------------------------------------------------------------------------
  34. # This file is part of cpp-ethereum.
  35. #
  36. # cpp-ethereum is free software: you can redistribute it and/or modify
  37. # it under the terms of the GNU General Public License as published by
  38. # the Free Software Foundation, either version 3 of the License, or
  39. # (at your option) any later version.
  40. #
  41. # cpp-ethereum is distributed in the hope that it will be useful,
  42. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  43. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  44. # GNU General Public License for more details.
  45. #
  46. # You should have received a copy of the GNU General Public License
  47. # along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>
  48. #
  49. # (c) 2016 cpp-ethereum contributors.
  50. #------------------------------------------------------------------------------
  51. set -e
  52. # Check for 'uname' and abort if it is not available.
  53. uname -v > /dev/null 2>&1 || { echo >&2 "ERROR - cpp-ethereum requires 'uname' to identify the platform."; exit 1; }
  54. case $(uname -s) in
  55. #------------------------------------------------------------------------------
  56. # macOS
  57. #------------------------------------------------------------------------------
  58. Darwin)
  59. case $(sw_vers -productVersion | awk -F . '{print $1"."$2}') in
  60. 10.9)
  61. echo "Installing cpp-ethereum dependencies on OS X 10.9 Mavericks."
  62. ;;
  63. 10.10)
  64. echo "Installing cpp-ethereum dependencies on OS X 10.10 Yosemite."
  65. ;;
  66. 10.11)
  67. echo "Installing cpp-ethereum dependencies on OS X 10.11 El Capitan."
  68. ;;
  69. 10.12)
  70. echo "Installing cpp-ethereum dependencies on macOS 10.12 Sierra."
  71. echo ""
  72. echo "NOTE - You are in unknown territory with this preview OS."
  73. echo "Even Homebrew doesn't have official support yet, and there are"
  74. echo "known issues (see https://github.com/ethereum/webthree-umbrella/issues/614)."
  75. echo "If you would like to partner with us to work through these issues, that"
  76. echo "would be fantastic. Please just comment on that issue. Thanks!"
  77. ;;
  78. *)
  79. echo "Unsupported macOS version."
  80. echo "We only support Mavericks, Yosemite and El Capitan, with work-in-progress on Sierra."
  81. exit 1
  82. ;;
  83. esac
  84. # Check for Homebrew install and abort if it is not installed.
  85. brew -v > /dev/null 2>&1 || { echo >&2 "ERROR - cpp-ethereum requires a Homebrew install. See http://brew.sh."; exit 1; }
  86. # And finally install all the external dependencies.
  87. brew install \
  88. cryptopp \
  89. leveldb \
  90. libmicrohttpd \
  91. miniupnpc
  92. ;;
  93. #------------------------------------------------------------------------------
  94. # FreeBSD
  95. #------------------------------------------------------------------------------
  96. FreeBSD)
  97. echo "Installing cpp-ethereum dependencies on FreeBSD."
  98. echo "ERROR - 'install_deps.sh' doesn't have FreeBSD support yet."
  99. echo "Please let us know if you see this error message, and we can work out what is missing."
  100. echo "At https://gitter.im/ethereum/cpp-ethereum-development."
  101. exit 1
  102. ;;
  103. #------------------------------------------------------------------------------
  104. # Linux
  105. #------------------------------------------------------------------------------
  106. Linux)
  107. #------------------------------------------------------------------------------
  108. # Arch Linux
  109. #------------------------------------------------------------------------------
  110. if [ -f "/etc/arch-release" ]; then
  111. echo "Installing cpp-ethereum dependencies on Arch Linux."
  112. # The majority of our dependencies can be found in the
  113. # Arch Linux official repositories.
  114. # See https://wiki.archlinux.org/index.php/Official_repositories
  115. sudo pacman -Sy --noconfirm \
  116. autoconf \
  117. automake \
  118. gcc \
  119. libtool \
  120. boost \
  121. cmake \
  122. crypto++ \
  123. git \
  124. leveldb \
  125. libcl \
  126. libmicrohttpd \
  127. miniupnpc \
  128. opencl-headers
  129. fi
  130. case $(lsb_release -is) in
  131. #------------------------------------------------------------------------------
  132. # Alpine Linux
  133. #------------------------------------------------------------------------------
  134. Alpine)
  135. #Alpine
  136. echo "Installing cpp-ethereum dependencies on Alpine Linux."
  137. echo "ERROR - 'install_deps.sh' doesn't have Alpine Linux support yet."
  138. echo "See http://cpp-ethereum.org/building-from-source/linux.html for manual instructions."
  139. echo "If you would like to get 'install_deps.sh' working for AlpineLinux, that would be fantastic."
  140. echo "Drop us a message at https://gitter.im/ethereum/cpp-ethereum-development."
  141. echo "See also https://github.com/ethereum/webthree-umbrella/issues/495 where we are working through Alpine support."
  142. exit 1
  143. ;;
  144. #------------------------------------------------------------------------------
  145. # Debian
  146. #------------------------------------------------------------------------------
  147. Debian)
  148. #Debian
  149. case $(lsb_release -cs) in
  150. wheezy)
  151. #wheezy
  152. echo "Installing cpp-ethereum dependencies on Debian Wheezy (7.x)."
  153. echo "See http://cpp-ethereum.org/building-from-source/linux.html for manual instructions."
  154. echo "If you would like to get 'install_deps.sh' working for Debian Wheezy, that would be fantastic."
  155. echo "Drop us a message at https://gitter.im/ethereum/cpp-ethereum-development."
  156. ;;
  157. jessie)
  158. #jessie
  159. echo "Installing cpp-ethereum dependencies on Debian Jessie (8.x)."
  160. ;;
  161. stretch)
  162. #stretch
  163. echo "Installing cpp-ethereum dependencies on Debian Stretch (9.x)."
  164. ;;
  165. *)
  166. #other Debian
  167. echo "Installing 'install_deps.sh' dependencies on unknown Debian version."
  168. echo "ERROR - Debian Jessie and Debian Stretch are the only Debian versions which cpp-ethereum has been tested on."
  169. echo "If you are using a different release and would like to get 'install_deps.sh'"
  170. echo "working for that release that would be fantastic."
  171. echo "Drop us a message at https://gitter.im/ethereum/cpp-ethereum-development."
  172. exit 1
  173. ;;
  174. esac
  175. # Install "normal packages"
  176. sudo apt-get -y update
  177. sudo apt-get -y install \
  178. build-essential \
  179. cmake \
  180. g++ \
  181. gcc \
  182. git \
  183. libboost-all-dev \
  184. libcurl4-openssl-dev \
  185. libgmp-dev \
  186. libleveldb-dev \
  187. libmicrohttpd-dev \
  188. libminiupnpc-dev \
  189. libz-dev \
  190. mesa-common-dev \
  191. ocl-icd-libopencl1 \
  192. opencl-headers \
  193. unzip
  194. # All the Debian releases until Stretch have shipped with CryptoPP 5.6.1,
  195. # but we need 5.6.2 or newer, so we build it from source.
  196. #
  197. # - https://packages.debian.org/wheezy/libcrypto++-dev (5.6.1)
  198. # - https://packages.debian.org/jessie/libcrypto++-dev (5.6.1)
  199. # - https://packages.debian.org/stretch/libcrypto++-dev (5.6.3)
  200. mkdir cryptopp && cd cryptopp
  201. wget https://www.cryptopp.com/cryptopp563.zip
  202. unzip -a cryptopp563.zip
  203. make dynamic
  204. make libcryptopp.so
  205. sudo make install PREFIX=/usr/local
  206. cd ..
  207. # All the Debian releases until Stretch have shipped with versions of CMake
  208. # which are too old for cpp-ethereum to build successfully. CMake v3.0.x
  209. # should be the minimum version, but the v3.0.2 which comes with Jessie
  210. # doesn't work properly, so maybe our minimum version should actually be
  211. # CMake v3.1.x? Anyway - we just build and install CMake from source
  212. # here, so that it works on any distro.
  213. #
  214. # - https://packages.debian.org/wheezy/cmake (2.8.9)
  215. # - https://packages.debian.org/jessie/cmake (3.0.2)
  216. # - https://packages.debian.org/stretch/cmake (3.5.2)
  217. wget https://cmake.org/files/v3.5/cmake-3.5.2.tar.gz
  218. tar -xf cmake-3.5.2.tar.gz
  219. cd cmake-3.5.2/
  220. cmake .
  221. ./bootstrap --prefix=/usr --system-curl
  222. make -j 2
  223. sudo make install
  224. source ~/.profile
  225. cd ..
  226. rm -rf cmake-3.5.2
  227. rm cmake-3.5.2.tar.gz
  228. ;;
  229. #------------------------------------------------------------------------------
  230. # Fedora
  231. #------------------------------------------------------------------------------
  232. Fedora)
  233. #Fedora
  234. echo "Installing cpp-ethereum dependencies on Fedora."
  235. # Install "normal packages"
  236. # See https://fedoraproject.org/wiki/Package_management_system.
  237. dnf install \
  238. autoconf \
  239. automake \
  240. boost-devel \
  241. cmake \
  242. cryptopp-devel \
  243. curl-devel \
  244. gcc \
  245. gcc-c++ \
  246. git \
  247. gmp-devel \
  248. leveldb-devel \
  249. libtool \
  250. mesa-dri-drivers \
  251. miniupnpc-devel \
  252. snappy-devel
  253. ;;
  254. #------------------------------------------------------------------------------
  255. # OpenSUSE
  256. #------------------------------------------------------------------------------
  257. "openSUSE project")
  258. #openSUSE
  259. echo "Installing cpp-ethereum dependencies on openSUSE."
  260. echo "ERROR - 'install_deps.sh' doesn't have openSUSE support yet."
  261. echo "See http://cpp-ethereum.org/building-from-source/linux.html for manual instructions."
  262. echo "If you would like to get 'install_deps.sh' working for openSUSE, that would be fantastic."
  263. echo "See https://github.com/ethereum/webthree-umbrella/issues/552."
  264. exit 1
  265. ;;
  266. #------------------------------------------------------------------------------
  267. # Ubuntu
  268. #
  269. # TODO - I wonder whether all of the Ubuntu-variants need some special
  270. # treatment?
  271. #
  272. # TODO - We should also test this code on Ubuntu Server, Ubuntu Snappy Core
  273. # and Ubuntu Phone.
  274. #
  275. # TODO - Our Ubuntu build is only working for amd64 and i386 processors.
  276. # It would be good to add armel, armhf and arm64.
  277. # See https://github.com/ethereum/webthree-umbrella/issues/228.
  278. #------------------------------------------------------------------------------
  279. Ubuntu|LinuxMint)
  280. #Ubuntu or LinuxMint
  281. case $(lsb_release -cs) in
  282. trusty|rosa|rafaela|rebecca|qiana)
  283. #trusty or compatible LinuxMint distributions
  284. echo "Installing cpp-ethereum dependencies on Ubuntu Trusty Tahr (14.04)."
  285. echo "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-3.9 main" \
  286. | sudo tee -a /etc/apt/sources.list > /dev/null
  287. ;;
  288. utopic)
  289. #utopic
  290. echo "Installing cpp-ethereum dependencies on Ubuntu Utopic Unicorn (14.10)."
  291. ;;
  292. vivid)
  293. #vivid
  294. echo "Installing cpp-ethereum dependencies on Ubuntu Vivid Vervet (15.04)."
  295. ;;
  296. wily)
  297. #wily
  298. echo "Installing cpp-ethereum dependencies on Ubuntu Wily Werewolf (15.10)."
  299. ;;
  300. xenial|sarah)
  301. #xenial
  302. echo "Installing cpp-ethereum dependencies on Ubuntu Xenial Xerus (16.04)."
  303. echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-3.9 main" \
  304. | sudo tee -a /etc/apt/sources.list > /dev/null
  305. ;;
  306. yakkety)
  307. #yakkety
  308. echo "Installing cpp-ethereum dependencies on Ubuntu Yakkety Yak (16.10)."
  309. echo ""
  310. echo "NOTE - You are in unknown territory with this preview OS."
  311. echo "We will need to update the Ethereum PPAs, work through build and runtime breaks, etc."
  312. echo "See https://github.com/ethereum/webthree-umbrella/issues/624."
  313. echo "If you would like to partner with us to work through these, that"
  314. echo "would be fantastic. Please just comment on that issue. Thanks!"
  315. ;;
  316. *)
  317. #other Ubuntu
  318. echo "ERROR - Unknown or unsupported Ubuntu version."
  319. echo "We only support Trusty, Utopic, Vivid, Wily and Xenial, with work-in-progress on Yakkety."
  320. exit 1
  321. ;;
  322. esac
  323. # The Ethereum PPA is required for the handful of packages where we need newer versions than
  324. # are shipped with Ubuntu itself. We can likely minimize or remove the need for the PPA entirely
  325. # as we switch more to a "build from source" model, as Pawel has recently done for LLVM in evmjit.
  326. #
  327. # See https://launchpad.net/~ethereum/+archive/ubuntu/ethereum
  328. #
  329. # The version of CMake which shipped with Trusty was too old for our codebase (we need 3.0.0 or newer),
  330. # so the Ethereum PPA contains a newer release (3.2.2):
  331. #
  332. # - http://packages.ubuntu.com/trusty/cmake (2.8.12.2)
  333. # - http://packages.ubuntu.com/wily/cmake (3.2.2)
  334. # - http://packages.ubuntu.com/xenial/cmake (3.5.1)
  335. # - http://packages.ubuntu.com/yakkety/cmake (3.5.2)
  336. #
  337. # All the Ubuntu releases until Yakkety have shipped with CryptoPP 5.6.1, but we need 5.6.2
  338. # or newer. Also worth of note is that the package name is libcryptopp in our PPA but
  339. # libcrypto++ in the official repositories.
  340. #
  341. # - http://packages.ubuntu.com/trusty/libcrypto++-dev (5.6.1)
  342. # - http://packages.ubuntu.com/wily/libcrypto++-dev (5.6.1)
  343. # - http://packages.ubuntu.com/xenial/libcrypto++-dev (5.6.1)
  344. # - http://packages.ubuntu.com/yakkety/libcrypto++-dev (5.6.3)
  345. #
  346. # NOTE - We actually want to remove the dependency in CryptoPP from our codebase entirely,
  347. # which would make this versioning problem moot.
  348. #
  349. # See https://github.com/ethereum/webthree-umbrella/issues/103
  350. if [ TRAVIS ]; then
  351. # On Travis CI llvm package conficts with the new to be installed.
  352. sudo apt-get -y remove llvm
  353. fi
  354. sudo apt-get -y update
  355. # this installs the add-apt-repository command
  356. sudo apt-get install -y --no-install-recommends software-properties-common
  357. sudo add-apt-repository -y ppa:ethereum/ethereum
  358. sudo apt-get -y update
  359. sudo apt-get install -y --no-install-recommends --allow-unauthenticated \
  360. build-essential \
  361. cmake \
  362. git \
  363. libboost-all-dev \
  364. libcurl4-openssl-dev \
  365. libcryptopp-dev \
  366. libgmp-dev \
  367. libleveldb-dev \
  368. libmicrohttpd-dev \
  369. libminiupnpc-dev \
  370. libz-dev \
  371. llvm-3.9-dev \
  372. mesa-common-dev \
  373. ocl-icd-libopencl1 \
  374. opencl-headers
  375. ;;
  376. *)
  377. #------------------------------------------------------------------------------
  378. # Other (unknown) Linux
  379. # Major and medium distros which we are missing would include Mint, CentOS,
  380. # RHEL, Raspbian, Cygwin, OpenWrt, gNewSense, Trisquel and SteamOS.
  381. #------------------------------------------------------------------------------
  382. #other Linux
  383. echo "ERROR - Unsupported or unidentified Linux distro."
  384. echo "See http://cpp-ethereum.org/building-from-source/linux.html for manual instructions."
  385. echo "If you would like to get your distro working, that would be fantastic."
  386. echo "Drop us a message at https://gitter.im/ethereum/cpp-ethereum-development."
  387. exit 1
  388. ;;
  389. esac
  390. ;;
  391. #------------------------------------------------------------------------------
  392. # Other platform (not Linux, FreeBSD or macOS).
  393. # Not sure what might end up here?
  394. # Maybe OpenBSD, NetBSD, AIX, Solaris, HP-UX?
  395. #------------------------------------------------------------------------------
  396. *)
  397. #other
  398. echo "ERROR - Unsupported or unidentified operating system."
  399. echo "See http://cpp-ethereum.org/building-from-source/ for manual instructions."
  400. echo "If you would like to get your operating system working, that would be fantastic."
  401. echo "Drop us a message at https://gitter.im/ethereum/cpp-ethereum-development."
  402. ;;
  403. esac