#!/bin/zsh
DO=$0
main() {
	args build_dir! fstab= filename=$DO:h/work/$TARGET.squash compressor=
	eval $(getvars)

	fstab-mounted

	dep_add_dir_mtimes $build_dir
	if [[ -n $compressor ]]; then
		(cd $build_dir && exec find -print0) \
			| (cd $build_dir && exec cpio -o -0) \
			| $compressor > $filename
		(( ${(j.|.)pipestatus} )) \
			&& die "$DO: Failed to create file: ${(qqq)filename}"
	else
		(cd $build_dir && exec find -print0) \
			| (cd $build_dir && exec cpio -o -0) \
			> $filename
		(( ${(j.|.)pipestatus} )) \
			&& die "$DO: Failed to create file: ${(qqq)filename}"
	fi
	dep_add_file $filename
}
. ./common.zsh
# vim: fileencoding=utf8 ft=zsh noet sw=4 ts=4 sts=4