if [ ! -r etc/rc.d/rc.modules ]; then
   mv etc/rc.d/rc.modules.new etc/rc.d/rc.modules
fi

# Install the right module set
if [ "`/bin/arch`" = "sparc64" ]; then
   rm -rf lib/modules/2.2.20pre2/*
   ( cd lib/modules/2.2.20pre2 ; tar -xf ../../../install/64bit-mods.tar )
else
   rm -rf lib/modules/2.2.20pre2/*
   ( cd lib/modules/2.2.20pre2 ; tar -xf ../../../install/32bit-mods.tar )
fi

( cd lib/modules/2.2.20pre2 ; rm -rf build )
( cd lib/modules/2.2.20pre2 ; ln -sf /usr/src/linux-2.2.20pre2 build )

# Build module dependencies
chroot . /sbin/depmod -a 2>/dev/null

# Clean up
rm -rf install/32bit-mods.tar 2> /dev/null
rm -rf install/64bit-mods.tar 2> /dev/null
