Would it be possible to make a script that could install a generic program using chroot and ldd?

EDIT: Also, what about things like apt-get?