#!/bin/sh -e

BASE=$(mktemp -d)
mkdir $BASE/root/ $BASE/aufs/ $BASE/test/

mount --bind   /     $BASE/root/
mount -t tmpfs tmpfs $BASE/aufs/ -o mode=755,size=401276k
mount -t aufs  aufs  $BASE/test/ -o dirs=$BASE/aufs/=rw:$BASE/root/=ro

systemd-nspawn --setenv=LANG=C.UTF-8 \
  --tmpfs=/tmp/:mode=1777 \
  --bind=/var/cache/apt/archives/ \
  -D $BASE/test/ || true

for dir in $BASE/*; do
  umount -l $dir
  rmdir $dir
done

rmdir $BASE

