#!/bin/ash -efu

. "${0%/*}"/mki-sh-functions

verbose "has started executing."

subdirs="${SUBDIRS:?subdirectories required}"

[ -d "$chroot" ] ||
	fatal "$dir: not look like a work directory of hasher."

for d in $subdirs; do
	outdir="$curdir/$d/$workdirname/$outdirname"

	get_copy_args "$outdir/" "$chroot/"

	mkdir -p -- "$chroot/.in/$d"
	find "$outdir" -mindepth 1 -maxdepth 1 \
		-execdir cp $cp_args -at "$chroot/.in/$d/" -- '{}' '+'

	mki-run -- /.host/find "/.in/$d" -mindepth 1 -maxdepth 1 \
		-execdir cp $verbose -alft /.image/ -- '{}' '+'

	find "$chroot/.in/" -mindepth 1 -maxdepth 1 \
		-execdir rm -rf -- '{}' '+'
done
