#!/bin/bash

#sanify check

if [ $# -lt 1 ] ; then
	echo "usage $0 ROOTDIR"
	exit 1
fi

rootdir=$1
    
if [ -z "$rootdir" ]; then
	echo "ROOTDIR is not set."
	exit 1
fi
		
# Check root directory
if [ ! -d $rootdir ]; then
	echo "$rootdir: should be a directory."
	exit 1
fi

pushd $rootdir > /dev/null
# Bootstrap a minimal chroot tree for the rest installation
mkdir -p var/lib/rpm
mkdir -p var/tmp
mkdir -p dev

chmod 666 dev/null
mknod dev/random c 1 8
chmod 644 dev/random
mknod dev/urandom c 1 9
chmod 644 dev/urandom
popd > /dev/null
