#!/bin/bash
[ ${UID} -ne 0 ] && exec sudo "$0" "$@"
set -e
cd /usr/local/src/blackfin/svn/colinux/trunk/debian
chroot debian apt-get clean
pushd debian >/dev/null

if [ -e proc/self ] ; then
	echo "still mounted ?" 1>&1
	exit 1
fi

echo 'nameserver 10.0.2.3' > etc/resolv.conf
echo colinux > etc/hostname
if ! grep -q colinux etc/hosts ; then
	sed -i '/127.0.0.1.*localhost/s:$: colinux:' etc/hosts
fi
rm -f root/.bash_history
rm -f root/.lesshst
#rm -f etc/udev/rules.d/75-cd-aliases-generator.rules
rm -f etc/udev/rules.d/70-persistent-{cd,net}.rules
rm -f etc/udev/rules.d/75-persistent-net-generator.rules

for l in \
	daemon.log \
	debug \
	dpkg.log \
	messages \
	syslog \
	apt/term.log \
	exim4/mainlog \
	exim4/paniclog \
	samba/core \
	samba/log.nmbd \
	samba/log.smbd \
; do
	> var/log/${l}
done
rm -rf var/log/installer
find var/run/samba/ -type f -exec rm {} +
find var/run/ -name '*.pid' -exec rm {} +

ls -a root/
popd >/dev/null
tar pcf blackfin-root.tar -C debian .
#scp blackfin-root.tar vapier@G5:/usr/local/src/blackfin/svn/colinux/trunk/tarballs/
