sort packages after determining what will be built

This also removes duplicates
fix logging bugs found while testing
fix run_unix implementation on Linux