Fix #1569.

* Change `guessPackageName` to translate arbitrary strings into valid
package names.
* Change type of `packageName` flag from String to PackageName and
reject names that do not pass PackageName's corresponding parse
function.
Merge pull request #1748 from ianbollinger/fix-#1569

Fix #1569.