#!/bin/sh -efu
# if memtest86/memtest86+ is installed as a part of base system,
# its %post is effectively skipped (installkernel won't run with
# DURING_INSTALL set -- which is the case for first and second
# installation stages)
# thanks led@ for the simpler implementation suggestion

. install2-init-functions

MEMTEST="`find $destdir/boot/ -maxdepth 1 -name 'memtest-*.bin' | tail -1`"
[ -n "$MEMTEST" ] || exit 0

MEMTEST_VER="${MEMTEST##*/memtest-}"
MEMTEST_VER="${MEMTEST_VER%%.bin}"

exec_chroot installkernel -m "$MEMTEST_VER"
