1#!/bin/bash 2 3DRY_RUN="" 4if [ $# -gt 0 ]; then 5 if [ "$1" == "--dry-run" ]; then 6 DRY_RUN="echo " 7 fi 8fi 9 10SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" 11PARENT_DIR="$(echo ${SCRIPT_DIR} | rev | cut -d '/' -f 2- | rev )" 12 13TMP_DIR=$(mktemp -d) 14OUT_DIR="${TMP_DIR}/out" 15 16trap ctrl_c INT 17 18function ctrl_c() { 19 echo -n "Cleaning up..." 20 rm -rf "${TMP_DIR}" 21 echo "Done." 22 exit 1 23} 24 25# APT dependencies 26APT_REQUIRED="git curl wget flatbuffers-compiler flex g++-multilib gcc-multilib generate-ninja \ 27gnupg gperf libc++-dev libdbus-1-dev libevent-dev libflatbuffers-dev libflatbuffers1 \ 28libgl1-mesa-dev libglib2.0-dev liblz4-tool libncurses5 libnss3-dev libprotobuf-dev libre2-9 \ 29libssl-dev libtinyxml2-dev libx11-dev libxml2-utils ninja-build openssl protobuf-compiler unzip \ 30x11proto-core-dev xsltproc zip zlib1g-dev libc++abi-dev cmake debmake ninja-build libgtest-dev \ 31libgmock-dev" 32 33${DRY_RUN} sudo apt install ${APT_REQUIRED} 34 35# Install rustup 36curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh 37${DRY_RUN} rustup update 38 39${DRY_RUN} cargo install cxxbridge-cmd || ctrl_c 40${DRY_RUN} cargo install cargo-proc-macro || ctrl_c 41 42echo "Building and installing modp-b64..." 43# dir name is different than package name :'( 44${DRY_RUN} pushd "${PARENT_DIR}/modp_b64/" 45${DRY_RUN} ./gen-src-pkg.sh "${OUT_DIR}" || crtl_c 46${DRY_RUN} sudo dpkg -i "${OUT_DIR}"/modp-b64*.deb || ctrl_c 47${DRY_RUN} popd 48 49echo "Building and installing libchrome..." 50${DRY_RUN} pushd "${PARENT_DIR}/libchrome/" 51${DRY_RUN} ./gen-src-pkg.sh "${OUT_DIR}" || crtl_c 52${DRY_RUN} sudo dpkg -i "${OUT_DIR}"/libchrome*.deb || ctrl_c 53${DRY_RUN} popd 54 55HAS_EXPORT="$(cat \$HOME/.bashrc|grep '.cargo/bin')" 56if [ "${HAS_EXPORT}" == "" ]; then 57 ${DRY_RUN} echo "export PATH=\$PATH:\$HOME/.cargo/bin" >> ~/.bashrc 58fi 59 60HAS_EXPORT="$(cat \$HOME/.bashrc|grep '$HOME/bin')" 61if [ "${HAS_EXPORT}" == "" ]; then 62 ${DRY_RUN} echo "export PATH=\$PATH:\$HOME/bin" >> ~/.bashrc 63fi 64 65# Put the GN binary in the bin...it isn't the right spot, but avoids adding a second directory 66# to the environmental PATH 67${DRY_RUN} mkdir -p ~/bin 68${DRY_RUN} wget -O ~/bin/gn wget http://commondatastorage.googleapis.com/chromeos-localmirror/distfiles/gn-3e43fac03281e2f5e5ae5f27c8e9a6bb45966ea9.bin 69${DRY_RUN} chmod +x ~/bin/gn 70 71rm -rf "${TMP_DIR}" 72echo "DONE" 73