1#!/bin/sh
2#
3# $FreeBSD$
4#
5
6if [ "`id -u`" != "0" ]; then
7	echo "Sorry, this must be done as root."
8	exit 1
9fi
10if [ $# -lt 1 ]; then
11	echo "You must specify which kernel to extract."
12	exit 1
13fi
14
15CONFIG=$1
16BOOT=${DESTDIR}/boot
17KERNEL=$BOOT/$CONFIG
18
19if [ -d $KERNEL ]; then
20	echo "You are about to extract the $CONFIG kernel distribution into $KERNEL - are you SURE"
21	echo -n "you want to do this over your installed system (y/n)? "
22	read ans 
23else
24	# new installation; do not prompt
25	ans=y
26fi
27if [ "$ans" = "y" ]; then
28	if [ -d $KERNEL ]; then
29		sav=$KERNEL.sav
30		if [ -d $sav ]; then
31			# XXX remove stuff w/o a prompt
32			echo "Removing existing $sav"
33			rm -rf $sav
34		fi
35		echo "Saving existing $KERNEL as $sav"
36		mv $KERNEL $sav
37	fi
38	# translate per Makefile:doTARBALL XXX are we sure to have tr?
39	tn=`echo ${CONFIG} | tr 'A-Z' 'a-z'`
40	cat $tn.?? | tar --unlink -xpzf - -C $BOOT
41else
42	echo "Installation of $CONFIG kernel distribution not done." 
43fi
44