Make apt upgrade=dist work and make its argument handling more idiomatic

Fixes #2287.