#! /bin/bash

# We have to be root to do these things
if test $USER != root
then	echo Become root first
	exec sudo $0 $*
fi

# This is the necessary RamDisk size
SIZE=$((4*1024))

# Group activity under a single basename
P=pivot-initrd
R=2.4.24-rmk2

# Create and mount the ramdisk
rm -f $P.gz
dd if=/dev/zero of=$P bs=1k count=$SIZE
mkfs.ext2 -T news -b 1024 -m 0 -N 750 \
	-F -L initrd $P
mkdir -p $P.mnt
mount -o loop -t ext2 $P $P.mnt

# Copy the modules and utilities in
z=`pwd`
pushd pivot-linux
make MODLIB=$z/$P.mnt/$R modules_install
popd
pushd $P.mnt
tar -xzf ../$P.tar.gz
popd

# Now convert it into a download
df $P.mnt
umount $P.mnt
rmdir  $P.mnt
gzip -9 $P

# Done

