#!/bin/sh

set -eu

usage() {
  cat <<EOF
usage: backends/podman+rocm/test-package [OPTIONS] PACKAGE OUTPUTDIR [EXTRA-AUTOPKGTEST-ARGS]

$@
EOF
}

# TODO ckk: Replace this by properly exporting debci_distro_name
# determine whether it's Debian or Ubuntu
script="/usr/share/debootstrap/scripts/${debci_suite:?}"
if [ -r "$script" ]; then
  if grep -q ubuntu.com "$script"; then
    distro=ubuntu
  elif grep -q kali.org "$script"; then
    distro=kali
  else
    distro=debian
  fi
else
  echo "ERROR: $script does not exist; debootstrap is not installed, or $debci_suite is an unknown suite" >&2
  exit 1
fi

# shellcheck disable=SC2086 # intentional word splitting of backend args
debci-autopkgtest --user debci --apt-upgrade "$@" \
  -- podman+rocm "debci/${distro}:${debci_suite:?}" ${debci_autopkgtest_args_podmanrocm:-}
