#!/bin/ash -efu
#
# mki-cache-copy-tree
#
# This file is part of mkimage
# Copyright (C) 2007-2009  Alexey Gladkov <gladkov.alexey@gmail.com>
#
# This file is covered by the GNU General Public License,
# which should be included with mkimage as the file COPYING.
#

data_tree="${COPY_TREE:?Data tree required}"

payload() {
	stat --printf='%A\t%s\t%Y\n' "$makefile"

	local d dir
	for dir in $COPY_TREE; do
		d="$(readlink -ve "$dir")" ||
			fatal "$dir: not available."

		if [ -d "$d" ]; then
			cd "$d"
			find -mindepth 1 -printf '%M\t%s\t%T@\t%p\n'
		else
			cd "${d%/*}"
			stat --printf='%A\t%s\t%Y\t%n\n' "${d##*/}"
		fi
		cd - >/dev/null
	done
}
