#!/bin/sh
set -eu
export LC_ALL=C.UTF-8

trap "rm -rf /tmp/debian-chroot" EXIT INT TERM

{{ CMD }} --mode=root --variant=apt {{ DIST }} /tmp/debian-chroot {{ MIRROR }}
chroot /tmp/debian-chroot dpkg-query --showformat '${binary:Package}\n' --show >pkglist.txt
# output dev entries which might not get created when creating a directory
# chroot, depending on the system on which this test is run but which are
# needed later when comparing to tarball output
tar -C /tmp/debian-chroot --one-file-system -c . | {
  tar -t
  echo ./dev/console
  echo ./dev/fd
  echo ./dev/full
  echo ./dev/null
  echo ./dev/ptmx
  echo ./dev/pts/
  echo ./dev/random
  echo ./dev/shm/
  echo ./dev/stderr
  echo ./dev/stdin
  echo ./dev/stdout
  echo ./dev/tty
  echo ./dev/urandom
  echo ./dev/zero
} | sort -u >tar1.txt
