Skip to content
Snippets Groups Projects
sniper.sh 2.88 KiB
Newer Older
# Copyright © 2021 Collabora Ltd.
# SPDX-License-Identifier: MIT

set -e
set -u

if [ -n "${TESTS_ONLY-}" ]; then
    echo "1..0 # SKIP This distro is too old to run populate-depot.py"
    exit 0
fi

populate_depot_args=()

if [ -n "${IMAGES_DOWNLOAD_CREDENTIAL-}" ]; then
        --credential-env IMAGES_DOWNLOAD_CREDENTIAL \
fi

if [ -n "${IMAGES_DOWNLOAD_URL-}" ] && [ -n "${IMAGES_DOWNLOAD_CREDENTIAL-}" ]; then
    populate_depot_args=( \
        "${populate_depot_args[@]}" \
        --images-uri "${IMAGES_DOWNLOAD_URL}"/steamrt-SUITE/snapshots \
elif [ -n "${IMAGES_SSH_HOST-}" ] && [ -n "${IMAGES_SSH_PATH-}" ]; then
        --ssh-host "${IMAGES_SSH_HOST}" \
        --ssh-path "${IMAGES_SSH_PATH}" \
else
    # There's no public release of sniper yet, so this won't actually work
    # without supplying a URL and credentials for the non-public version
    echo "1..0 # SKIP no public release of sniper available"
    exit 0

    # When there's a public release, this will probably work
        --version latest-container-runtime-public-beta \
fi

if [ -n "${PRESSURE_VESSEL_DOWNLOAD_URL-}" ] && [ -n "${IMAGES_DOWNLOAD_CREDENTIAL-}" ]; then
    pressure_vessel_args=( \
        --pressure-vessel-uri="${PRESSURE_VESSEL_DOWNLOAD_URL}" \
        --pressure-vessel-version=latest \
    )
elif [ -n "${PRESSURE_VESSEL_SSH_HOST-"${IMAGES_SSH_HOST-}"}" ] && [ -n "${PRESSURE_VESSEL_SSH_PATH-}" ]; then
    pressure_vessel_args=( \
        --pressure-vessel-ssh-host="${PRESSURE_VESSEL_SSH_HOST-"${IMAGES_SSH_HOST}"}" \
        --pressure-vessel-ssh-path="${PRESSURE_VESSEL_SSH_PATH}" \
        --pressure-vessel-version=latest \
    )
else
    pressure_vessel_args=( \
        --pressure-vessel-from-runtime-json='{"version": "latest-container-runtime-public-beta"}' \
    )

rm -fr depots/test-sniper-archives
mkdir -p depots/sniper-archives
python3 ./populate-depot.py \
    --depot=depots/test-sniper-archives \
    --toolmanifest \
    "${populate_depot_args[@]}" \
    "${pressure_vessel_args[@]}" \
    sniper \
    ${NULL+}
find depots/test-sniper-archives -ls > depots/test-sniper-archives.txt
echo "ok 1 - sniper, deploying from archive"

rm -fr depots/test-sniper-unpacked
mkdir -p depots/test-sniper-unpacked
python3 ./populate-depot.py \
    --depot=depots/test-sniper-unpacked \
    --no-include-archives \
    --toolmanifest \
    --versioned-directories \
    "${populate_depot_args[@]}" \
    "${pressure_vessel_args[@]}" \
    sniper \
    ${NULL+}
find depots/test-sniper-unpacked -ls > depots/test-sniper-unpacked.txt
echo "ok 2 - sniper, running from unpacked directory"