blob: ae28b05d3946ccadc251fb66beccb5d3b98025ec [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_16.04/Release.key"
EDATOOLS_REPO="deb http://download.opensuse.org/repositories/home:/phiwag:/edatools/xUbuntu_16.04/ /"
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
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 installing six is a workaround for pip dependency resolution:
# six is already installed as system package with a version below the
# required one. Explicitly installing six through pip gets us a supported
# version.
#
# 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.
pip3 install --user -U pip six
# There's been a bit of a kerfuffle about setuptools version 50, which
# breaks importing distutils on Debian/Ubuntu systems. Make sure we don't
# pick it up until the dust has settled and things work again.
pip3 install --user -U 'setuptools < 50.0.0'
pip3 install --user -U -r python-requirements.txt
# Propagate PATH changes to all subsequent steps of the job
echo "##vso[task.setvariable variable=PATH]$PATH"
displayName: 'Install package dependencies'