Miguel Young de la Sota | 9438391 | 2019-12-05 14:34:04 -0600 | [diff] [blame] | 1 | # Copyright lowRISC contributors. |
| 2 | # Licensed under the Apache License, Version 2.0, see LICENSE for details. |
| 3 | # SPDX-License-Identifier: Apache-2.0 |
| 4 | |
| 5 | # Azure template for installing dependencies from various package managers, |
| 6 | # necessary for building, testing, and packaging OpenTitan. |
| 7 | # |
Philipp Wagner | 4fbe98f | 2020-02-25 12:54:20 +0000 | [diff] [blame] | 8 | # This template can be included from pipelines in other repositories. |
| 9 | # In this case, set the the REPO_TOP parameter to point to the root of the |
| 10 | # checked out opentitan repository. |
| 11 | # |
Miguel Young de la Sota | 9438391 | 2019-12-05 14:34:04 -0600 | [diff] [blame] | 12 | # This template executes: |
Philipp Wagner | 161bb0c | 2020-03-30 15:54:33 +0100 | [diff] [blame] | 13 | # - apt-get (*) install for all packages listed in apt-requirements.txt |
Miguel Young de la Sota | 9438391 | 2019-12-05 14:34:04 -0600 | [diff] [blame] | 14 | # - pip install for all packages listed in python-requirements.txt |
Philipp Wagner | 161bb0c | 2020-03-30 15:54:33 +0100 | [diff] [blame] | 15 | # |
| 16 | # * As an optimization, apt-fast is used instead of apt-get if it is available. |
Miguel Young de la Sota | 9438391 | 2019-12-05 14:34:04 -0600 | [diff] [blame] | 17 | |
Philipp Wagner | 4fbe98f | 2020-02-25 12:54:20 +0000 | [diff] [blame] | 18 | parameters: |
| 19 | - name: REPO_TOP |
| 20 | type: string |
| 21 | default: . |
| 22 | |
Miguel Young de la Sota | 9438391 | 2019-12-05 14:34:04 -0600 | [diff] [blame] | 23 | steps: |
| 24 | - bash: | |
| 25 | set -e |
Philipp Wagner | 4fbe98f | 2020-02-25 12:54:20 +0000 | [diff] [blame] | 26 | |
Philipp Wagner | 161bb0c | 2020-03-30 15:54:33 +0100 | [diff] [blame] | 27 | # Use apt-fast if available for faster installation. |
| 28 | if command -v apt-fast >/dev/null; then |
| 29 | APT_CMD=apt-fast |
| 30 | else |
| 31 | APT_CMD=apt-get |
| 32 | fi |
| 33 | |
Philipp Wagner | 4fbe98f | 2020-02-25 12:54:20 +0000 | [diff] [blame] | 34 | cd "${{ parameters.REPO_TOP }}" |
| 35 | |
Philipp Wagner | 0599e76 | 2020-02-25 12:57:25 +0000 | [diff] [blame] | 36 | # Ensure apt package index is up-to-date. |
Philipp Wagner | 161bb0c | 2020-03-30 15:54:33 +0100 | [diff] [blame] | 37 | sudo $APT_CMD update |
Philipp Wagner | 0599e76 | 2020-02-25 12:57:25 +0000 | [diff] [blame] | 38 | |
Miguel Young de la Sota | 9438391 | 2019-12-05 14:34:04 -0600 | [diff] [blame] | 39 | # NOTE: We use sed to remove all comments from apt-requirements.txt, |
Philipp Wagner | 161bb0c | 2020-03-30 15:54:33 +0100 | [diff] [blame] | 40 | # since apt-get/apt-fast doesn't actually provide such a feature. |
Miguel Young de la Sota | 9438391 | 2019-12-05 14:34:04 -0600 | [diff] [blame] | 41 | sed 's/#.*//' apt-requirements.txt \ |
Philipp Wagner | 161bb0c | 2020-03-30 15:54:33 +0100 | [diff] [blame] | 42 | | xargs sudo $APT_CMD install -y |
Philipp Wagner | 4fbe98f | 2020-02-25 12:54:20 +0000 | [diff] [blame] | 43 | |
Greg Chadwick | fe07c7c | 2020-02-11 11:24:09 +0000 | [diff] [blame] | 44 | # Python requirements are installed to the local user directory so prepend |
| 45 | # appropriate bin directory to the PATH |
| 46 | export PATH=$HOME/.local/bin:$PATH |
Philipp Wagner | 4fbe98f | 2020-02-25 12:54:20 +0000 | [diff] [blame] | 47 | |
Greg Chadwick | fe07c7c | 2020-02-11 11:24:09 +0000 | [diff] [blame] | 48 | # Explicitly installing six is a workaround for pip dependency resolution: |
| 49 | # six is already installed as system package with a version below the |
| 50 | # required one. Explicitly installing six through pip gets us a supported |
| 51 | # version. |
| 52 | # |
| 53 | # Explicitly updating pip and setuptools is required to have these tools |
| 54 | # properly parse Python-version metadata, which some packages uses to |
| 55 | # specify that an older version of a package must be used for a certain |
| 56 | # Python version. If that information is not read, pip installs the latest |
| 57 | # version, which then fails to run. |
| 58 | pip3 install --user -U setuptools pip six |
| 59 | pip3 install --user -U -r python-requirements.txt |
Philipp Wagner | 4fbe98f | 2020-02-25 12:54:20 +0000 | [diff] [blame] | 60 | |
Greg Chadwick | fe07c7c | 2020-02-11 11:24:09 +0000 | [diff] [blame] | 61 | # Propagate PATH changes to all subsequent steps of the job |
| 62 | echo "##vso[task.setvariable variable=PATH]$PATH" |
Miguel Young de la Sota | 9438391 | 2019-12-05 14:34:04 -0600 | [diff] [blame] | 63 | displayName: 'Install package dependencies' |