Split out building a debian version from an upstream commit

based on a patch by Daniel Dehennin

Needed for #672954, #646684, #669171