# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0

# Azure template for downloading pipeline step outputs and unpacking them.
#
# This template will download all artifacts from upstream jobs (which are
# expected to use upload_artifacts_template.yml) and unpack them.
#
# This template expects that a variable $BUILD_ROOT is set to a writeable
# directory; the results will be available in $BIN_DIR. See
# util/build_consts.sh for more information.

steps:
  - task: DownloadPipelineArtifact@2
    inputs:
      buildType: current
      targetPath: '$(BUILD_ROOT)/downloads'
    displayName: 'Download upstream outputs'
  - bash: |
      set -e
      test -n "$BUILD_ROOT"
      . util/build_consts.sh
      mkdir -p "$BIN_DIR"

      sudo apt-get install -y tree

      tree "$BUILD_ROOT"
      find "$BUILD_ROOT/downloads" \
        -name 'build-bin.tar' \
        -exec \
          tar -C "$BIN_DIR" \
          --strip-components=1 \
          --overwrite \
          -xvf {} \;
      tree "$BUILD_ROOT"
    displayName: 'Unpack upstream outputs'


# Copyright lowRISC contributors.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0

# Azure template for downloading pipeline step outputs and unpacking them.
#
# This template will download all artifacts from upstream jobs (which are
# expected to use upload_artifacts_template.yml) and unpack them.
#
# This template expects that a variable $BUILD_ROOT is set to a writeable
# directory; the results will be available in $BIN_DIR. See
# util/build_consts.sh for more information.

steps:
  - task: DownloadPipelineArtifact@2
    inputs:
      buildType: current
      targetPath: '$(BUILD_ROOT)/downloads'
    displayName: 'Download upstream outputs'
  - bash: |
      set -e
      test -n "$BUILD_ROOT"
      . util/build_consts.sh
      mkdir -p "$BIN_DIR"

      find "$BUILD_ROOT/downloads" \
        -name 'build-bin.tar' \
        -exec \
          tar -C "$BIN_DIR" \
          --strip-components=1 \
          --overwrite \
          -xvf {} \;
    displayName: 'Unpack upstream outputs'

Remove package installation from artifact download job
[ci] Remove package installation from artifact download job

The artifact download job currently installs a package and needs
sudo/root permissions for that, which are not available in all builders.
Remove the sudo call, as it was for debugging only.

Signed-off-by: Philipp Wagner <5a4b10454c30419e54a1570be358a516ff84bb63@lowrisc.org>
