downstream: Factorize most code

This allows reusing both the same frontend and backend code to mark a
package as downstream-only, or reverting that.