Fix up setuphooks error handling.

Retry on errors since that seems to happen on occasion.  I could
probably put some sleeps or something in there, but at the very least,
the restructuring should make this easier.

cbugg: close bug-655