#!/bin/sh

prereqs()
{
	if [ "${BUSYBOX}" = "n" ] || [ ! -f "${BUSYBOX_EXECUTABLE}" ]; then
		echo ''
	else
		# Ensure busybox installs all its commands before
		# checking what we should provide
		echo zz-busybox
	fi
}

case $1 in
prereqs)
	prereqs
	exit 0
	;;
esac

for src in /usr/lib/klibc/bin/*; do
	command="${src##*/}"
	case "$src" in
	gzip | kinit | zcat)
		;;
	*)
		# Don't install commands that already exist in /bin or /sbin
		if ! [ -e "${DESTDIR}/sbin/$command" ]; then
			cp -pnL "$src" "${DESTDIR}/bin"
		fi
		;;
	esac
done
cp -pL /lib/klibc-*.so "${DESTDIR}/lib"
