#!/bin/sh

set -e

WORKDIR=$AUTOPKGTEST_TMP

run () {
  os=$1
  cpu=$2
  dist=$3
  DEST="$WORKDIR/$os-$cpu-$dist"

  echo
  echo "Installing $os $cpu $dist in $DEST"
  mkdir "$DEST"
  crosshurd -t "$DEST" -s $os -c $cpu -d $dist 2>&1
}

#
# Linux
#
for cpu in x86_64 i386 aarch64
do
  for dist in oldoldstable oldstable stable testing unstable
  do
    # To remove when bulleseye is released
    [ "$cpu" = aarch64 ] && [ "$dist" = oldoldstable ] && continue

    run linux-gnu $cpu $dist
  done
done

#
# Hurd
#
run gnu i386 unstable

for cpu in x86_64 i386
do
  run kfreebsd-gnu $cpu unstable || true
done
