Check distvname is defined before comparing it

to avoid several warnings every time the script is run.
Some weird uploads don't have it.

Also add some comments to make it easier to follow.