Made dependency checker more robust

e.g., to `dirname` failures.  For instance, faulty dependencies such as
GNU coreutils built for higher versions of system libraries could cause
the script to halt without an understandable error message.