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

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

verbose "has started executing."

BOOT_TYPE="${BOOT_TYPE:?boot type required}"

outname="${MKI_OUTNAME:-outname}"
outname="${outname##*/}"

types=
for b in ${BOOT_TYPE:-}; do
	case "$b" in
		isolinux|pxelinux|syslinux|yaboot|efiboot) types="$types $b " ;;
		*) fatal "Unknown boot type" ;;
	esac
done

[ -z "${EFI_BOOTLOADER:-}" -o -z "${types##* efiboot *}" ] ||
	types="$types efiboot "

[ -n "$types" ] ||
	fatal "Boot type required"

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

[ -z "${PROPAGATOR_MAR_MODULES:-}" ] ||
	mki-build-propagator

for b in $types; do
	mki-copy-$b
done

[ -n "${types##* isolinux *}" ] ||
	exec mki-pack-isoboot

[ -n "${types##* yaboot *}" ] ||
	exec mki-pack-yaboot

exec mki-pack-data
