1156437Ssam#!/bin/sh
2156437Ssam#
3156437Ssam# $FreeBSD$
4156437Ssam#
5156437Ssam
6156437Ssamif [ "`id -u`" != "0" ]; then
7156437Ssam	echo "Sorry, this must be done as root."
8156437Ssam	exit 1
9156437Ssamfi
10156437Ssamif [ $# -lt 1 ]; then
11156437Ssam	echo "You must specify which kernel to extract."
12156437Ssam	exit 1
13156437Ssamfi
14156437Ssam
15156437SsamCONFIG=$1
16161686SruBOOT=${DESTDIR}/boot
17156437SsamKERNEL=$BOOT/$CONFIG
18156437Ssam
19156437Ssamif [ -d $KERNEL ]; then
20156437Ssam	echo "You are about to extract the $CONFIG kernel distribution into $KERNEL - are you SURE"
21156437Ssam	echo -n "you want to do this over your installed system (y/n)? "
22156437Ssam	read ans 
23156437Ssamelse
24156437Ssam	# new installation; do not prompt
25156437Ssam	ans=y
26156437Ssamfi
27156437Ssamif [ "$ans" = "y" ]; then
28156437Ssam	if [ -d $KERNEL ]; then
29156437Ssam		sav=$KERNEL.sav
30156437Ssam		if [ -d $sav ]; then
31156437Ssam			# XXX remove stuff w/o a prompt
32156437Ssam			echo "Removing existing $sav"
33156437Ssam			rm -rf $sav
34156437Ssam		fi
35156437Ssam		echo "Saving existing $KERNEL as $sav"
36156437Ssam		mv $KERNEL $sav
37156437Ssam	fi
38162164Sru	# translate per Makefile:doTARBALL XXX are we sure to have tr?
39162164Sru	tn=`echo ${CONFIG} | tr 'A-Z' 'a-z'`
40156957Ssam	cat $tn.?? | tar --unlink -xpzf - -C $BOOT
41156437Ssamelse
42156437Ssam	echo "Installation of $CONFIG kernel distribution not done." 
43156437Ssamfi
44