Better handling of unneeded actions

We now check whether we need to install a package before trying to
perform any of its prerequisites.  This prevents us from building and
staging a package if we're not going to package and install the result.