I don't think you need to test for the existence of `dmd`.  Just install the package, re-installing doesn't do any harm.