#!/bin/ash -efu
#
# mki-cache-pack-image
#
# 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.
#

aptbox="$dir/aptbox"

workdir_check_status() {
	[ ! -d "$workdir_changed" ]
}

workdir_change_status() {
	[ ! -d "$workdir_changed" ] ||
		rmdir -- "$workdir_changed"
}

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

	printf '%s\n' "${MKI_OUTNAME:-}"

	if [ -d "$aptbox/var" ]; then
		cd "$aptbox/var"
		find -name '*_release' -exec cat '{}' '+'
		cd - >/dev/null
	fi

	if [ -d "$outdir" ]; then
		cd "$outdir"
		find -mindepth 1 -printf '%M\t%s\t%T@\t%p\n'
		cd - >/dev/null
	fi

	local d outdir
	for d in ${SUBDIRS:-}; do
		[ -d "$curdir/$d/$workdirname/$outdirname" ] ||
			continue

	    	cd "$curdir/$d/$workdirname/$outdirname"
		find -mindepth 1 -printf '%M\t%s\t%T@\t%p\n'
		cd - >/dev/null
	done
}
