Improve build script error checking.

See #1221 for the bug I encountered. It was my bad but this patch should help detecting those missing package problem.