Run hooks from xbps-packages at specified phases and remove code provided by hooks.