Attempt to fix softwarefactory role rebuild

This patch should fix the non expected rebuild of softwarefactory
role when the upstream role is similar. A git clean
is performed before computing the md5s.

Locale is set to C, this make the sort behavior
consistency between nodes.

This patch also include a little refactoring of the
build_role function.

Change-Id: I451b7d992a2d64fe57d6af482d069880b9d4057e