#!/bin/bash

. /etc/lunar/config
[ -n "$BOOTSTRAP" ] && . $BOOTSTRAP

preserve()
{
	if [ -f $1 ] ; then
		mv -f $1 $1.old
	fi
}

# make backups
preserve $4/vmlinuz-$1
preserve $4/System.map-$1
preserve $4/config.$1

make modules_install
# bzImage
cp $2 $4/vmlinuz-$1
# System.map
cp $3 $4/System.map-$1
# save config as .gz
cp .config $4/config.$1
gzip -f $4/config.$1

# and update bootloader
update_bootloader vmlinuz-$1 $1

[ $? == 2 ] && true

