1#!/usr/bin/env bash 2# Copyright 2021 The ChromiumOS Authors 3# Use of this source code is governed by a BSD-style license that can be 4# found in the LICENSE file. 5set -ex 6 7sudo apt-get install --yes --no-install-recommends \ 8 black \ 9 ca-certificates \ 10 clang \ 11 cloud-image-utils \ 12 curl \ 13 dpkg-dev \ 14 expect \ 15 g++ \ 16 gcc \ 17 git \ 18 jq \ 19 libavcodec-dev \ 20 libavutil-dev \ 21 libcap-dev \ 22 libclang-dev \ 23 libdbus-1-dev \ 24 libdrm-dev \ 25 libepoxy-dev \ 26 libglib2.0-dev \ 27 libguestfs-tools \ 28 libslirp-dev \ 29 libssl-dev \ 30 libswscale-dev \ 31 libva-dev \ 32 libwayland-dev \ 33 libxext-dev \ 34 lld \ 35 make \ 36 meson \ 37 mypy \ 38 nasm \ 39 ncat \ 40 ninja-build \ 41 openssh-client \ 42 pipx \ 43 pkg-config \ 44 protobuf-compiler \ 45 python3 \ 46 python3-argh \ 47 python3-pip \ 48 python3-rich \ 49 qemu-system-x86 \ 50 rsync \ 51 screen \ 52 strace \ 53 tmux \ 54 wayland-protocols \ 55 wget 56 57# mdformat is not available as a debian package. Install via pipx instead. 58pipx install mdformat 59pipx inject mdformat mdformat-gfm mdformat-footnote 60pipx ensurepath 61 62# Install rustup if not available yet 63if ! command -v rustup &>/dev/null; then 64 wget "https://static.rust-lang.org/rustup/archive/1.25.1/x86_64-unknown-linux-gnu/rustup-init" 65 echo "5cc9ffd1026e82e7fb2eec2121ad71f4b0f044e88bca39207b3f6b769aaa799c *rustup-init" | sha256sum -c - 66 chmod +x rustup-init 67 ./rustup-init -y --no-modify-path --profile minimal --default-toolchain none 68 source ${CARGO_HOME:-~/.cargo}/env 69 rm rustup-init 70fi 71 72# Install required rust components. 73# This will also ensure the toolchain required by ./rust-toolchain is installed. 74rustup component add cargo clippy rustfmt 75 76# LLVM tools are used to generate and process coverage files 77rustup component add llvm-tools-preview 78 79# Allow cross-compilation via mingw64 80rustup target add x86_64-pc-windows-gnu 81 82# Allow cross-compilation for android 83rustup target add aarch64-linux-android 84 85# Install nightly toolchain. Only used for rustfmt 86rustup toolchain install nightly --profile minimal --component rustfmt 87 88# Cargo extension to install binary packages from github 89curl -L https://github.com/cargo-bins/cargo-binstall/releases/download/v1.4.4/cargo-binstall-x86_64-unknown-linux-gnu.tgz | tar -xzvvf - -C ${CARGO_HOME:-~/.cargo}/bin 90 91# The bindgen tool is required to build a crosvm dependency. 92cargo binstall --no-confirm bindgen-cli --version "0.68.1" 93 94# binutils are wrappers to call the rustup bundled versions of llvm tools. 95cargo binstall --no-confirm cargo-binutils 96 97# The mdbook and mdbook-mermaid tools are used to build the crosvm book. 98cargo binstall --no-confirm mdbook --version "0.4.25" 99cargo binstall --no-confirm mdbook-mermaid --version "0.12.6" 100cargo binstall --no-confirm mdbook-linkcheck --version "0.7.7" 101 102# Nextest is an improved test runner for cargo 103cargo binstall --no-confirm cargo-nextest --version "0.9.49" 104 105Red='\033[0;31m' 106Reset='\033[0m' 107# Check if submodules were initialized. If a submodule is not initialized, git 108# submodule status will be prefixed with `-` 109if git submodule status | grep '^-'; then 110 >&2 echo -e "${Red}ERROR${Reset}: Git modules were not initialized. Run 'git submodule update --init' to initialize them." 111fi 112