#!/bin/sh -e
if [ \! -d package ] || [ \! -d package/bsd ] 
then
	echo "You are not in the right directory." 1>&2 
	exit 100
fi

export CDPATH=

# Create and populate the bsd directory.
install -d -m 0755 bsd
(
	cd package/bsd
	ls -1 .
) | (
	cd bsd	# The syntax of ln -s makes more sense if we are in the target directory.
	while read i
	do
		dir="`dirname $i`"
		# Try to create a hard link, and fall back to a symbolic link.
		# The package and bsd directories aren't necessarily on the same disc volume.
		ln -f ../package/bsd/"$i" "${dir}"/"$i" 2>/dev/null || ln -s -f ../package/bsd/"$i" "${dir}"/"$i"
	done
)
