#!/bin/sh

set -eux

dpkg --add-architecture amd64
dpkg --add-architecture i386
apt-get -y update
apt-get -y install \
    libsteam-runtime-tools-0-0:amd64 \
    libsteam-runtime-tools-0-0:i386 \
    libsteam-runtime-tools-0-helpers:amd64 \
    libsteam-runtime-tools-0-helpers:i386 \
    steam-runtime-tools-bin \
    ${NULL+}

if command -v python3.5; then
   PYTHON=python3.5
else
   PYTHON=python3
fi

"$PYTHON" pressure-vessel/build-relocatable-install.py \
    --allow-missing-sources \
    --output "${AUTOPKGTEST_TMP}/relocatable-install" \
    --archive "${AUTOPKGTEST_ARTIFACTS}"

"$PYTHON" ./tests/pressure-vessel/relocatable-install.py \
    "${AUTOPKGTEST_TMP}/relocatable-install"

for archive in "${AUTOPKGTEST_ARTIFACTS}"/*.tar.*; do
    echo "==== $(basename "$archive") ===="
    tar -tvf "$archive"
done
