#!/bin/ash -efu
#
# mki-copy-pxelinux
#
# 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

pkgs="${PACKAGES_REQUIRED_COPY_PXELINUX:-}"

verbose "has started executing."

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

mki-install $pkgs ||
	fatal "faild to install packages: $pkgs."

[ -d "$chroot/.image/syslinux/pxelinux.cfg" ] ||
	message 'Warning: /.image/tftpboot/pxelinux.cfg: not found.'

run_chrooted "$chroot" <<EOF
#!/bin/sh -efu
mkdir $verbose -p -- /.image/syslinux/alt0
cp $verbose -aLf /boot/vmlinuz /.image/syslinux/alt0/vmlinuz
[ ! -f /boot/full.cz ] ||
	cp $verbose -aLf /boot/full.cz /.image/syslinux/alt0/full.cz
cp $verbose -f /usr/lib/syslinux/pxelinux.0 /.image/syslinux/
EOF
