dpkg reimplemented in Python