- mkdir -p "$BUILD_OUTPUT"/boot/isolinux
- cp /boot/memtest86+.bin "$BUILD_OUTPUT"/boot/isolinux/memtest
- # do not keep the initrd inside the chroot, let's save space instead:
- mv "$CHROOT_OUTPUT"/boot/initrd* "$BUILD_OUTPUT"/boot/isolinux/initrd.gz
- cp "$CHROOT_OUTPUT"/boot/vmlinuz* "$BUILD_OUTPUT"/boot/isolinux/linux26
- cp /usr/lib/syslinux/chain.c32 "$BUILD_OUTPUT"/boot/isolinux/
- cp /usr/lib/syslinux/isolinux.bin "$BUILD_OUTPUT"/boot/isolinux/
- cp /usr/lib/syslinux/memdisk "$BUILD_OUTPUT"/boot/isolinux/
- cp /usr/lib/syslinux/menu.c32 "$BUILD_OUTPUT"/boot/isolinux/
+ [ -d "$BUILD_OUTPUT"/boot/isolinux ] || mkdir -p "$BUILD_OUTPUT"/boot/isolinux
+ cp /boot/memtest86+.bin "$BUILD_OUTPUT"/boot/isolinux/memtest
+
+ # if we don't have an initrd we a) can't boot and b) there was an error
+ # during build, so check for the file:
+ INITRD="$(ls $CHROOT_OUTPUT/boot/initrd* 2>/dev/null| grep -v '.bak$' | sort -r | head -1)"
+ if [ -n "$INITRD" ] ; then
+ cp $INITRD "$BUILD_OUTPUT"/boot/isolinux/initrd.gz
+ find $CHROOT_OUTPUT/boot/ -name initrd\*.bak -exec rm {} \;
+ else
+ log "No initrd found inside $CHROOT_OUTPUT/boot/ - Exiting"
+ eerror "No initrd found inside $CHROOT_OUTPUT/boot/ - Exiting" ; eend 1
+ bailout 10
+ fi
+
+ KERNEL_IMAGE="$(ls $CHROOT_OUTPUT/boot/vmlinuz* 2>/dev/null | sort -r | head -1)"
+ if [ -n "$KERNEL_IMAGE" ] ; then
+ cp "$KERNEL_IMAGE" "$BUILD_OUTPUT"/boot/isolinux/linux26
+ else
+ log "No kernel found inside $CHROOT_OUTPUT/boot/ - Exiting"
+ eerror "No kernel found inside $CHROOT_OUTPUT/boot/ - Exiting" ; eend 1
+ bailout 11
+ fi