#!/bin/sh

set -eu

./tools/init-dev.sh

get_packages() {
  if [ $# -eq 0 ]; then
    set -- $(shuf --head-count=50 config/seed_list)
  fi
  echo "$@"
}

configdir=`./bin/debci config --values-only config_dir`

skipped_list="$(./bin/debci config --values-only arch_skip_list)"
for arch in $(./bin/debci config --values-only arch_list); do
  skip=false
  for skipped in $skipped_list; do
    if [ "${skipped}" = "${arch}" ]; then
      skip=true
      break
    fi
  done
  if [ "${skip}" = "true" ]; then
    continue
  fi
  for suite in $(./bin/debci config --values-only suite_list); do
    get_packages "$@" \
      | xargs ./bin/debci enqueue --arch="$arch" --suite="$suite"
  done
done
