blob: cc41ff6638ac4e20d85700f78a97d1223336f7cd [file] [log] [blame]
# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
# Azure template for installing dependencies from various package managers,
# necessary for building, testing, and packaging OpenTitan.
#
# This template can be included from pipelines in other repositories.
# In this case, set the the REPO_TOP parameter to point to the root of the
# checked out opentitan repository.
#
# This template executes:
# - apt-get (*) install for all packages listed in apt-requirements.txt
# - pip install for all packages listed in python-requirements.txt
#
# * As an optimization, apt-fast is used instead of apt-get if it is available.
parameters:
- name: REPO_TOP
type: string
default: .
steps:
- bash: |
set -e
# Use apt-fast if available for faster installation.
if command -v apt-fast >/dev/null; then
APT_CMD=apt-fast
else
APT_CMD=apt-get
fi
cd "${{ parameters.REPO_TOP }}"
# Install verilator from experimental OBS repository
# apt-requirements.txt doesn't cover this dependency as we don't support
# using the repository below for anything but our CI (yet).
EDATOOLS_REPO_KEY="https://download.opensuse.org/repositories/home:phiwag:edatools/xUbuntu_$(lsb_release -sr)/Release.key"
EDATOOLS_REPO="deb http://download.opensuse.org/repositories/home:/phiwag:/edatools/xUbuntu_$(lsb_release -sr)/ /"
curl -sL "$EDATOOLS_REPO_KEY" | sudo apt-key add -
sudo sh -c "echo \"$EDATOOLS_REPO\" > /etc/apt/sources.list.d/edatools.list"
cp apt-requirements.txt apt-requirements-ci.txt
echo "verilator-$(VERILATOR_VERSION)" >> apt-requirements-ci.txt
echo "openocd-$(OPENOCD_VERSION)" >> apt-requirements-ci.txt
echo rsync >> apt-requirements-ci.txt
cat apt-requirements-ci.txt
# Ensure apt package index is up-to-date.
sudo $APT_CMD update
# NOTE: We use sed to remove all comments from apt-requirements-ci.txt,
# since apt-get/apt-fast doesn't actually provide such a feature.
sed 's/#.*//' apt-requirements-ci.txt \
| xargs sudo $APT_CMD install -y
# Python requirements are installed to the local user directory so prepend
# appropriate bin directory to the PATH
export PATH=$HOME/.local/bin:$PATH
# Explicitly updating pip and setuptools is required to have these tools
# properly parse Python-version metadata, which some packages uses to
# specify that an older version of a package must be used for a certain
# Python version. If that information is not read, pip installs the latest
# version, which then fails to run.
python3 -m pip install --user -U pip setuptools
pip3 install --user -r python-requirements.txt
# Install Verible
mkdir -p build/verible
cd build/verible
curl -Ls -o verible.tar.gz "https://github.com/google/verible/releases/download/$(VERIBLE_VERSION)/verible-$(VERIBLE_VERSION)-Ubuntu-$(lsb_release -sr)-$(lsb_release -sc)-x86_64.tar.gz"
sudo mkdir -p /tools/verible && sudo chmod 777 /tools/verible
tar -C /tools/verible -xf verible.tar.gz --strip-components=1
# Propagate PATH changes to all subsequent steps of the job
echo "##vso[task.setvariable variable=PATH]/tools/verible/bin:$PATH"
displayName: 'Install package dependencies'